Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【BUG】Video example code is not working... #1531

Open
andersprenger opened this issue Sep 3, 2023 · 2 comments
Open

【BUG】Video example code is not working... #1531

andersprenger opened this issue Sep 3, 2023 · 2 comments

Comments

@andersprenger
Copy link

  • face_recognition version: 1.3.0
  • Python version: 3.9.16
  • Operating System: Rocky Linux 9.2 (Blue Onyx) x86_64

Description

The example facerec_from_video_file.py is not running.

Here's the the terminal output...

$ /bin/python /home/ander/face_recognition/examples/facerec_from_video_file.py
Traceback (most recent call last):
  File "/home/ander/face_recognition/examples/facerec_from_video_file.py", line 50, in <module>
    face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
  File "/home/ander/.local/lib/python3.9/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 "/home/ander/.local/lib/python3.9/site-packages/face_recognition/api.py", line 214, in <listcomp>
    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 0x7f8bc98bb2b0>, array([[[ 8,  3,  0],
        [12,  7,  4],
        [18, 13, 10],
        ...,
        [24,  9,  0],
        [24,  9,  0],
        [24,  9,  0]],

       [[ 8,  3,  0],
        [12,  7,  4],
        [18, 13, 10],
        ...,
        [24,  9,  0],
        [24,  9,  0],
        [24,  9,  0]],

       [[ 7,  2,  0],
        [11,  6,  3],
        [16, 11,  8],
        ...,
        [24,  9,  0],
        [24,  9,  0],
        [24,  9,  0]],

       ...,

       [[ 7,  3,  0],
        [ 7,  3,  0],
        [ 9,  3,  0],
        ...,
        [17,  1,  0],
        [11,  1,  2],
        [11,  1,  2]],

       [[ 7,  3,  0],
        [ 7,  3,  0],
        [ 9,  3,  0],
        ...,
        [17,  2,  0],
        [11,  1,  0],
        [11,  1,  0]],

       [[ 7,  3,  0],
        [ 7,  3,  0],
        [ 9,  3,  0],
        ...,
        [17,  2,  0],
        [11,  1,  0],
        [11,  1,  0]]], dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x7f8ba3186e70>, 1

What I Did

git clone https://github.com/ageitgey/face_recognition.git
cd face_recognition/examples
python facerec_from_video_file.py
@andersprenger
Copy link
Author

I saw a PR #1498 with the following fix:

    # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
    rgb_frame = frame[:, :, ::-1]

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

It seems to fix this issue. I'll let it open to the community see the fix and also for any further discussion.

@Biiddd
Copy link

Biiddd commented Dec 9, 2023

me 2, I was using the webcam example, same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants