import os import cv2 from aip import AipBodyAnalysis from threading import Thread import base64 """ 你的 APPID AK SK """ APP_ID = '**************' API_KEY = '**************' SECRET_KEY = '**************' ''' 调用''' gesture_client = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY) capture = cv2.VideoCapture (0) 0 as the default camera# DEF Camera (): the while True: RET, Frame = capture.read () # cv2.imshow (name image window, the display window) cv2.imshow ( ' Frame ' , Frame) IF cv2.waitKey (. 1) == the ord ( ' Q ' ): BREAK the thread (target = Camera) .start () # introduced at the time of the identified thread to prevent stuck DEF gesture_recognition (): '' ' first ret parameter is True or False, no read representatives image to the second parameter represents a frame of a picture taken to '' ' RET, frame = capture.read () # only accept a base64 image base64_data = base64.b64encode(frame) gesture = gesture_client.gesture(base64_data ) #AipBodyAnalysis内部函数 print(gesture) gesture_recognition()