face_recognition
face_recognition copied to clipboard
【BUG】Video example code is not working...
- 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
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.
me 2, I was using the webcam example, same problem