def __init__(self,hass,face:dict,config:dict,users:dict,regex:dict): self.hass=hass self.face=aip.AipFace(str(face["appId"]),face["apiKey"],face["secretKey"]) if self.face.getGroupUsers("werobot")["error_code"] != 0: raise AuthenticationError("人脸识别认证错误!") self.robot = werobot.WeRoBot() for k,v in config.items(): self.robot.config[k]=v self.users=users self.regex=regex self.robot.config['HOST'] = '0.0.0.0' self.robot.add_handler(self.subscribe, "subscribe_event") self.robot.add_handler(self.recv,"text") self.robot.add_handler(self.recv, "voice") self.robot.add_handler(self.recv, "image")
def face(self, b64_img, face_field=appid.FIELD): self.faceAPI = aip.AipFace(self.__ID, self.__KEY, self.__SK) self.respond = self.faceAPI.detect(b64_img, self.imageType, self.options) return self.respond
import aip import cam import FileDialog client = aip.AipFace("Enter Your APP_ID", "Enter Your API_KEY", "Enter Your SECRET_KEY") cam.photo_capture("d:\\1.jpg", "q") print( client.match(FileDialog.getOneFile(), FileDialog.getOneFile(), options={})["score"])