cnfan
#人脸比对
#导入百度ai和opencv
from aip import AipFace
import cv2

# 定义常量
APP_ID = \'10736496\'
API_KEY = \'xLwFVx76ZmGujNxFGSGp8wUc\'
SECRET_KEY = \'H6jpVPX3wRdcxKf59r0qoGvG6zfHnMEk\'

# 初始化AipFace对象
client = AipFace(APP_ID, API_KEY, SECRET_KEY)

""" 读取图片 """
def get_file_content(filePath):
    with open(filePath, \'rb\') as fp:
        return fp.read()

images = [
    get_file_content(\'0.jpg\'),
    get_file_content(\'1.jpg\'),
    get_file_content(\'2.jpg\'),
]

""" 调用人脸比对 """
result=client.match(images)

#输出比对结果
for k in range(3):
  print("图片%s和图片%s相似度:"%(result[ "result"][k]["index_i"],result[ "result"][k]["index_j"]))
  print(result[ "result"][k]["score"])

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-15
  • 2021-12-03
  • 2021-12-04
  • 2021-12-04
  • 2021-12-28
  • 2021-09-13
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2022-01-16
  • 2021-12-18
  • 2021-12-19
  • 2022-12-23
  • 2021-05-06
相关资源
相似解决方案