ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.34k stars 13.48k forks source link

Windows face_recognition run time error #1548

Open SATHISHK108 opened 10 months ago

SATHISHK108 commented 10 months ago

windows 11 python 3.10.0 face_recognition 1.3.0 dlib 19.24.2

import cv2 import face_recognition

def identify_known_face(): pass

def main(): count = 0 cap = cv2.VideoCapture(0) while True: ret, img = cap.read()

    if not ret:
        break

    count += 1
    if count % 4 != 0:
        continue

    small_frame = cv2.resize(img, (0, 0), fx=0.25, fy=0.25)
    rgb_small_frame = small_frame[:, :, ::-1]

    face_locations = face_recognition.face_locations(rgb_small_frame)

    face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
    cv2.imshow('Webcam Feed', img)

    if cv2.waitKey(1) == 27:
        break

cap.release()
cv2.destroyAllWindows()

if name == "main": main()

(.venv) PS D:\sathish\face_recognition> python main.py
Traceback (most recent call last): File "D:\sathish\face_recognition\main.py", line 36, in main() File "D:\sathish\face_recognition\main.py", line 26, in main face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations) File "D:\sathish\face_recognition.venv\lib\site-packages\face_recognition\api.py", line 214, in face_encodings return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks] File "D:\sathish\face_recognition.venv\lib\site-packages\face_recognition\api.py", line 214, in return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks] TypeError: compute_face_descriptor(): incompatible function arguments. The following argument types are supported:

  1. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], face: _dlib_pybind11.full_object_detection, num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vector
  2. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], num_jitters: int = 0) -> _dlib_pybind11.vector
  3. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], faces: _dlib_pybind11.full_object_detections, num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vectors
  4. (self: _dlib_pybind11.face_recognition_model_v1, batch_img: List[numpy.ndarray[(rows,cols,3),numpy.uint8]], batch_faces: List[_dlib_pybind11.full_object_detections], num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vectorss
  5. (self: _dlib_pybind11.face_recognition_model_v1, batch_img: List[numpy.ndarray[(rows,cols,3),numpy.uint8]], num_jitters: int = 0) -> _dlib_pybind11.vectors

Invoked with: <_dlib_pybind11.face_recognition_model_v1 object at 0x00000261A75546B0>, array([[[187, 183, 173], [190, 183, 172], [190, 183, 170], ..., [138, 121, 103], [136, 119, 104], [137, 118, 102]],

   [[189, 184, 174],
    [189, 185, 175],
    [188, 184, 174],
    ...,
    [139, 121, 107],
    [137, 121, 103],
    [132, 121, 104]],

   [[190, 185, 175],
    [190, 185, 175],
    [189, 185, 175],
    ...,
    [137, 122, 103],
    [137, 121, 105],
    [133, 122, 106]],

   ...,

   [[150, 151, 145],
    [153, 153, 147],
    [153, 154, 147],
    ...,
    [ 66,  50,  33],
    [ 62,  48,  30],
    [ 59,  45,  27]],

   [[149, 150, 140],
    [152, 153, 146],
    [154, 154, 150],
    ...,
    [ 67,  50,  33],
    [ 63,  47,  30],
    [ 62,  45,  29]],

   [[149, 148, 139],
    [150, 150, 142],
    [152, 153, 144],
    ...,
    [ 65,  49,  33],
    [ 61,  44,  30],
    [ 60,  45,  30]]], dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x00000261A7564930>, 1
15380831711 commented 8 months ago
        rgb_small_frame = small_frame[:, :, ::-1]

        code = cv2.COLOR_BGR2RGB
        rgb_small_frame = cv2.cvtColor(rgb_small_frame, code)