作者:yymse17883 | 来源:互联网 | 2023-05-19 17:26
经过Python3使用微软人脸API-1.2创建人员组人员训练识别后通过训练后识别(相似度问题)微软的人脸识别API中上传一张图片查找相似度是根据人员的相似度返回的数据#检测相似度
经过Python3使用微软人脸API-1.2创建人员组人员训练识别后
通过训练后识别(相似度问题)
微软的人脸识别API中上传一张图片查找相似度是根据人员的相似度返回的数据
#检测相似度
def identifyFace(personGroupId,faceIds,maxNumOfCandidatesReturned,confidenceThreshold):
try:
#maxNumOfCandidatesReturned=1
#cOnfidenceThreshold=0.5
Content_Type1='application/octet-stream'
Content_Type2='application/json'
headers = {
# Request headers
'Content-Type': Content_Type2,
'Ocp-Apim-Subscription-Key': subscription_key,
}
params = urllib.parse.urlencode({
})
stra='{"personGroupId":"'
strb='","faceIds":["'
strc='"],"maxNumOfCandidatesReturned":'
strd=',"confidenceThreshold": '
stre='}'
body='%s%s%s%s%s%s%s%s%s'%(stra,personGroupId,strb,faceIds,strc,maxNumOfCandidatesReturned,strd,confidenceThreshold,stre)
print(body)
cOnn= http.client.HTTPSConnection('api.cognitive.azure.cn')
conn.request("POST", "/face/v1.0/identify?%s" % params, body, headers)
respOnse= conn.getresponse()
data = response.read()
data=data.decode()
data=data.strip('[]')
data=eval(data)
faceIdr=data["faceId"]
candidates=data["candidates"]
print(candidates[0]["personId"])
print(candidates[0]["confidence"])
conn.close()
except Exception as e:
print('Error:')
print(e)
返回与人员组中与各个人员比较的相似度,可以通过判断相似度大于0.76进行筛选
到这一步基本上就可以完成各种识别分类,也可以通过微软人脸API中的智能识别对大量数据进行筛选,例如找20-30岁的男性,带着眼镜等等。
结合图片管理可以做一个图片分类,比如某某人分类在一个单独的文件夹显示
结合摄像头处理也可以做一个速度与激情8中所出现的极简版的“天眼”,当然,对摄像头的清晰度要求还是比较。
利用现有的人脸API缩减了开发时间,但是也降低了开发门槛,如果是真的学习人脸识别等等还是从看opencv看起吧,然后一步一步走,毕竟用别人的API所谓的核心竞争力都是别人的,只不过作为一个创意来做点有意思的事情还是不错的。
附上API地址作为结束吧
https://dev.cognitive.azure.cn/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236/console