| 參數(shù)名 | 必選 | 類型 | 說(shuō)明 |
|---|---|---|---|
| score | 是 | float | 人臉相似度得分,推薦閾值80分 |
| face_list | 是 | array | 人臉信息列表 |
| face_token | 是 | string | 人臉的唯一標(biāo)志 |
import cv2
cap = cv2.VideoCapture(0) # 打開攝像頭
while True:
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
cv2.imshow('window', frame)
cv2.imwrite('D:/chenjy/2.png', frame) # 保存路徑
cv2.waitKey(2000)
cap.release()
cv2.destroyAllWindows()
import cv2
import base64
from aip import AipFace
APP_ID = '你的 App ID'
API_KEY = '你的 Api Key'
SECRET_KEY = '你的 Secret Key'
client = AipFace(APP_ID, API_KEY, SECRET_KEY)
def get_result():
result = client.match([
{
'image': str(base64.b64encode(open('D:/chenjy/1.png', 'rb').read()), 'utf-8'),
'image_type': 'BASE64',
},
{
'image': str(base64.b64encode(open('D:/chenjy/2.png', 'rb').read()), 'utf-8'),
'image_type': 'BASE64',
}
])
if result['error_msg'] == 'SUCCESS':
score = result['result']['score']
print(result)
print('相似度:'+str(score))
else:
print('服務(wù)器錯(cuò)誤')
cap = cv2.VideoCapture(0) # 打開攝像頭
while True:
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
cv2.imshow('window', frame)
cv2.imwrite('D:/chenjy/2.png', frame) # 保存路徑
cv2.waitKey(2000)
get_result()
cap.release()
cv2.destroyAllWindows()
結(jié)果:
照片加了模糊處理


以上就是python 使用百度AI接口進(jìn)行人臉對(duì)比的步驟的詳細(xì)內(nèi)容,更多關(guān)于python 人臉對(duì)比的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
標(biāo)簽:亳州 興安盟 黔東 拉薩 廊坊 內(nèi)江 渭南 綿陽(yáng)
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python 使用百度AI接口進(jìn)行人臉對(duì)比的步驟》,本文關(guān)鍵詞 python,使用,百度,接口,進(jìn)行,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。