最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2021年03月17日 11:24:44   作者:可愛的黑精靈  
這篇文章主要介紹了python 使用百度AI接口進行人臉對比的步驟,幫助大家更好的理解和學(xué)習(xí)使用python,感興趣的朋友可以了解下

1. 注冊百度云賬號

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

創(chuàng)建應(yīng)用獲取AppID,API Key,Secret Key。

2. 安裝baidu python api

人臉對比 API 文檔

pip install baidu-aip

調(diào)用:

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)

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)

返回值:

返回主要參數(shù)說明:

參數(shù)名 必選 類型 說明
score float 人臉相似度得分,推薦閾值80分
face_list array 人臉信息列表
face_token string 人臉的唯一標志

3.調(dià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()

4.完整測試程序

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ù)器錯誤')


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接口進行人臉對比的步驟的詳細內(nèi)容,更多關(guān)于python 人臉對比的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論

平顶山市| 台安县| 同德县| 敦煌市| 石家庄市| 兰溪市| 资阳市| 友谊县| 仙桃市| 天长市| 乐平市| 阿鲁科尔沁旗| 辽宁省| 牡丹江市| 株洲市| 苏尼特右旗| 启东市| 宁安市| 绿春县| 韶关市| 新宁县| 东宁县| 萨嘎县| 鹰潭市| 米脂县| 左贡县| 宿松县| 平阳县| 搜索| 侯马市| 喀什市| 河源市| 兰考县| 本溪| 元阳县| 德州市| 乌拉特后旗| 朔州市| 孝感市| 嘉峪关市| 璧山县|