久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

python 使用百度AI接口進行人臉對比的步驟

瀏覽:54日期:2022-06-24 15:33:58
1. 注冊百度云賬號

注冊百度智能云,提交申請。

創建應用獲取AppID,API Key,Secret Key。

2. 安裝baidu python api

人臉對比 API 文檔

pip install baidu-aip

調用:

import base64from aip import AipFaceAPP_ID = ’你的 App ID’API_KEY = ’你的 Api Key’SECRET_KEY = ’你的 Secret Key’client = AipFace(APP_ID, API_KEY, SECRET_KEY)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’, } ])print(result)

返回值:

python 使用百度AI接口進行人臉對比的步驟

返回主要參數說明:

參數名 必選 類型 說明 score 是 float 人臉相似度得分,推薦閾值80分 face_list 是 array 人臉信息列表 face_token 是 string 人臉的唯一標志 3.調用攝像頭

import cv2cap = 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()4.完整測試程序

import cv2import base64from aip import AipFaceAPP_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(’服務器錯誤’)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()

結果:

照片加了模糊處理

python 使用百度AI接口進行人臉對比的步驟

python 使用百度AI接口進行人臉對比的步驟

以上就是python 使用百度AI接口進行人臉對比的步驟的詳細內容,更多關于python 人臉對比的資料請關注好吧啦網其它相關文章!

標簽: 百度 Python
相關文章:
主站蜘蛛池模板: 南漳县| 新巴尔虎右旗| 新乐市| 和林格尔县| 铁岭市| 兴城市| 陇川县| 康乐县| 丰顺县| 勃利县| 呼图壁县| 临江市| 阳东县| 北辰区| 璧山县| 海城市| 芦溪县| 南投县| 南康市| 中西区| 兴化市| 泗水县| 乌拉特后旗| 和静县| 遵化市| 沙雅县| 略阳县| 澎湖县| 甘谷县| 海口市| 阿尔山市| 泽州县| 昭苏县| 西林县| 红河县| 宝丰县| 张家口市| 莎车县| 余干县| 石狮市| 建昌县|