import oss2
import json
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
AccessKeyId="xxxxxx"
AccessKeySecret="xxxxxxx"
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/159145.html
人体姿态关键点
BodyPosture可以获取人体的十八个关键点信息。包括:nose、neck、right_shoudler、
right_elbow、right_wrist、left_shoudler、left_elbow、left_wrist、right_hip、right_knee、right_ankle、left_hip、
left_knee、left_ankle、right_eye、left_eye、right_ear、left_ear"""
from aliyunsdkfacebody.request.v20191230.BodyPostureRequest import BodyPostureRequest
request = BodyPostureRequest()
request.set_accept_format('json')
filepath="images/人体2.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': '5D3902BB-BD33-5748-AF57-B93E22C4BD6A', 'Data': {'MetaObject': {'Height': 800, 'Width': 533}, 'Outputs': [{'Results': [{'Bodies': [{'Confident': 0.7394627332687378, 'Label': 'nose', 'Positions': [{'Points': [0.5694444179534912, 0.14130434393882751]}]}, {'Confident': 0.688110888004303, 'Label': 'neck', 'Positions': [{'Points': [0.5879629850387573, 0.25]}]}, {'Confident': 0.6811688542366028, 'Label': 'right_shoudler', 'Positions': [{'Points': [0.46759259700775146, 0.2554347813129425]}]}, {'Confident': 0.6633850336074829, 'Label': 'right_elbow', 'Positions': [{'Points': [0.42129629850387573, 0.3804347813129425]}]}, {'Confident': 0.6713557243347168, 'Label': 'right_wrist', 'Positions': [{'Points': [0.49074074625968933, 0.45108696818351746]}]}, {'Confident': 0.6367168426513672, 'Label': 'left_shoudler', 'Positions': [{'Points': [0.7037037014961243, 0.25]}]}, {'Confident': 0.739377498626709, 'Label': 'left_elbow', 'Positions': [{'Points': [0.7361111044883728, 0.3695652186870575]}]}, {'Confident': 0.7219