类型错误:__call__():不兼容的函数参数.支持以下参数类型:



我使用了face_recognition。

一开始当所有东西都是默认的(型号=HOG(时,我可以运行这个

import cv2
import face_recognition
cap = cv2.VideoCapture(0)
Nichapa_im1 = face_recognition.load_image_file("C:\Users\ACER\Desktop\facetest\data01\Nichapa04.jpg")
A_encoding1 = face_recognition.face_encodings(Nichapa_im1)[0]
person_face_encodings = [A_encoding1]
person_face_names = ["NICHAPA"]
data_locations = []
data_encodings = []
data_names = []
frameProcess = True

while True:
ret, frame = cap.read()
resizing = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
rgb_resizing = resizing[:, :, ::-1]

if frameProcess:
data_locations = face_recognition.face_locations(rgb_resizing)
data_encodings = face_recognition.face_encodings(rgb_resizing, data_locations)
data_names = []
for dc in data_encodings:
matches = face_recognition.compare_faces(person_face_encodings, dc)
name = "UNKNOWN"
if True in matches:
first_match_index = matches.index(True)
name = person_face_names[first_match_index]
data_names.append(name)

frameProcess = not frameProcess
for (top, right, bottom, left), name in zip(data_locations, data_names):
top *= 4
right *= 4
bottom *= 4
left *= 4
cv2.rectangle(frame, (left, top), (right, bottom), (255, 0, 0), 2)
cv2.rectangle(frame, (left, bottom - 20), (right, bottom), (255, 0, 0), cv2.FILLED)
font = cv2.FONT_HERSHEY_SIMPLEX  
cv2.putText(frame, name, (left + 6, bottom - 6), font, 0.7, (255, 255, 255), 2)

cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('x'):
break
cap.release()
cv2.destroyAllWindows()

我所做的我在api.py中将检测模型更改为cnn(model=cnn(然后我运行了相同的代码,结果出现了这个错误。

TypeError: __call__(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.shape_predictor, image: array, box: _dlib_pybind11.rectangle) -> _dlib_pybind11.full_object_detection
Invoked with: <_dlib_pybind11.shape_predictor object at 0x0000024D4FAC83B0>, array([[[199, 210, 202],
[199, 210, 202],
[200, 211, 203],
......lots of array here......
...,
[251, 237, 228],
[251, 237, 228],
[252, 238, 229]]], dtype=uint8), <_dlib_pybind11.mmod_rectangle object at 0x0000024D4E8705F0>

我该怎么办,我想使用带有cnn型号的dlib

loc = face_recognition.api.face_locations(img, number_of_times_to_upsample=1, model='cnn|hog')

使用此链接并参考以下链接以了解更多

[https://face-recognition.readthedocs.io/en/latest/face_recognition.html][1]

最新更新