import oss2
import json
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
AccessKeyId="xxxxx"
AccessKeySecret="xxxxxx"
auth = oss2.Auth(AccessKeyId, AccessKeySecret)
bucket = oss2.Bucket(auth, 'https://oss-cn-shanghai.aliyuncs.com', 'ocr-yjs')
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkcore.auth.credentials import StsTokenCredential
credentials = AccessKeyCredential(AccessKeyId, AccessKeySecret)
client = AcsClient(region_id='cn-shanghai', credential=credentials)
import seaborn as sns
"""
https://help.aliyun.com/document_detail/159214.html
手势关键点检测
HandPosture可以获取手势的二十一个关键点信息。
"""
from aliyunsdkfacebody.request.v20191230.HandPostureRequest import HandPostureRequest
request = HandPostureRequest()
request.set_accept_format('json')
filepath="images/手掌.jpg"
with open(filepath, 'rb') as fileobj:
bucket.put_object(filepath, fileobj)
url="https://ocr-yjs.oss-cn-shanghai.aliyuncs.com/"+filepath
request.set_ImageURL(url)
response = client.do_action_with_exception(request)
response=json.loads(str(response, encoding='utf-8'))
print(response)
{'RequestId': '78DC25B8-4675-58C5-B2CD-2B4063BE1BF1', 'Data': {'MetaObject': {'Height': 478, 'Width': 850}, 'Outputs': [{'Results': [{'Hands': {'Confident': 1, 'KeyPoints': [{'Label': '0', 'Positions': [{'Points': [0.4750716984272003, 0.7935550808906555]}]}, {'Label': '1', 'Positions': [{'Points': [0.41993096470832825, 0.712688148021698]}]}, {'Label': '2', 'Positions': [{'Points': [0.3470659554004669, 0.601658284664154]}]}, {'Label': '3', 'Positions': [{'Points': [0.30989059805870056, 0.46409955620765686]}]}, {'Label': '4', 'Positions': [{'Points': [0.27792635560035706, 0.364242821931839]}]}, {'Label': '5', 'Positions': [{'Points': [0.42169979214668274, 0.45184677839279175]}]}, {'Label': '6', 'Positions': [{'Points': [0.4230223298072815, 0.28472110629081726]}]}, {'Label': '7', 'Positions': [{'Points': [0.4261426627635956, 0.17738473415374756]}]}, {'Label': '8', 'Positions': [{'Points': [0.43028169870376587, 0.07360294461250305]}]}, {'Label': '9', 'Positions': [{'Points': [0.4758013188838959, 0.4497516453266144]}]}, {'Label': '10', 'Positions':