濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > python 使用百度AI接口進(jìn)行人臉對(duì)比的步驟

python 使用百度AI接口進(jìn)行人臉對(duì)比的步驟

熱門標(biāo)簽:n400電話申請(qǐng)多少錢 女王谷地圖標(biāo)注 ai地圖標(biāo)注 百應(yīng)ai電銷機(jī)器人鄭州 長春人工智能電銷機(jī)器人官網(wǎng) 廈門crm外呼系統(tǒng)如何 地圖標(biāo)注推廣單頁 如何在地圖標(biāo)注文字 西藏快速地圖標(biāo)注地點(diǎn)

1. 注冊(cè)百度云賬號(hào)

注冊(cè)百度智能云,提交申請(qǐng)。

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

2. 安裝baidu python api

人臉對(duì)比 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 人臉的唯一標(biāo)志

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ù)器錯(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)文章!

您可能感興趣的文章:
  • Python基于百度AI的文字識(shí)別的示例
  • python利用百度AI實(shí)現(xiàn)文字識(shí)別功能
  • Python3調(diào)用百度AI識(shí)別圖片中的文字功能示例【測試可用】
  • Python基于百度AI實(shí)現(xiàn)OCR文字識(shí)別
  • python調(diào)用百度AI接口實(shí)現(xiàn)人流量統(tǒng)計(jì)
  • Python基于百度AI實(shí)現(xiàn)抓取表情包
  • python 百度aip實(shí)現(xiàn)文字識(shí)別的實(shí)現(xiàn)示例
  • Python調(diào)用百度AI實(shí)現(xiàn)圖片上文字識(shí)別功能實(shí)例
  • Python調(diào)用百度AI實(shí)現(xiàn)圖片上表格識(shí)別功能

標(biāo)簽:亳州 興安盟 黔東 拉薩 廊坊 內(nèi)江 渭南 綿陽

巨人網(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)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《python 使用百度AI接口進(jìn)行人臉對(duì)比的步驟》相關(guān)的同類信息!
  • 本頁收集關(guān)于python 使用百度AI接口進(jìn)行人臉對(duì)比的步驟的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章

    上一篇:解決Pyinstaller打包為可執(zhí)行文件編碼錯(cuò)誤的問題

    下一篇:關(guān)于Pyinstaller閃退的補(bǔ)救措施

    峨眉山市| 开阳县| 山阴县| 昌江| 兴山县| 宜阳县| 桂平市| 资源县| 赣榆县| 建湖县| 丹东市| 九龙城区| 广宁县| 右玉县| 淮阳县| 松江区| 许昌县| 平南县| 融水| 铁岭市| 鲁山县| 营山县| 康保县| 印江| 南木林县| 时尚| 彭阳县| 东乌| 泸州市| 来凤县| 舒兰市| 南昌市| 买车| 河南省| 司法| 义乌市| 宜川县| 故城县| 射阳县| 新津县| 安福县|