face_recognition问题与face_encodings函数有关。

huangapple go评论152阅读模式
英文:

face_recognition problem with face_encodings function

问题

我是一个新手,遇到了解决这个问题的困难。

我尝试运行来自face_recognition的示例代码,使用网络摄像头。这两个示例都不适用于我,并且一直抛出这个错误。

我正在使用 Windows 11 上运行的 Python 3.11.2。我已经安装了 face_recognition v1.3.0 和 dlib v19.24.1。

我已经尝试按照 face_recognition 的安装指南重新安装了所有内容。

英文:

I am a newbie and having difficulty on resolving this issue.

What I am trying to do is run the sample code from face_recognition using a webcam. Both of the two example doesn't work on me and keeps on throwing this error.

  1. Traceback (most recent call last):
  2. File "C:\Users\...\Desktop\face_recognition\demo_webcam.py", line 55, in <module>
  3. face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
  4. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5. File "C:\Users\...\AppData\Local\Programs\Python\Python311\Lib\site-packages\face_recognition\api.py", line 214, in face_encodings
  6. return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
  7. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  8. File "C:\Users\...\AppData\Local\Programs\Python\Python311\Lib\site-packages\face_recognition\api.py", line 214, in <listcomp>
  9. return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
  10. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11. TypeError: compute_face_descriptor(): incompatible function arguments. The following argument types are supported:
  12. 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
  13. 2. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], num_jitters: int = 0) -> _dlib_pybind11.vector
  14. 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
  15. 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
  16. 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
  17. Invoked with: <_dlib_pybind11.face_recognition_model_v1 object at 0x000001DAB486B7B0>, array([[[208, 223, 240],
  18. [204, 213, 234],
  19. [191, 208, 229],
  20. ...,
  21. [ 87, 76, 74],
  22. [ 94, 78, 77],
  23. [ 82, 72, 70]],
  24. [[214, 223, 245],
  25. [208, 221, 240],
  26. [197, 217, 235],
  27. ...,
  28. [100, 63, 68],
  29. [104, 74, 71],
  30. [ 87, 78, 75]],
  31. [[220, 231, 249],
  32. [218, 228, 245],
  33. [208, 224, 239],
  34. ...,
  35. [ 96, 86, 84],
  36. [102, 83, 82],
  37. [ 86, 83, 80]],
  38. ...,
  39. [[ 36, 36, 35],
  40. [ 41, 37, 36],
  41. [ 40, 35, 33],
  42. ...,
  43. [107, 65, 41],
  44. [109, 67, 44],
  45. [109, 68, 50]],
  46. [[ 41, 39, 38],
  47. [ 42, 36, 35],
  48. [ 44, 39, 38],
  49. ...,
  50. [107, 64, 45],
  51. [106, 62, 42],
  52. [108, 64, 42]],
  53. [[ 46, 42, 41],
  54. [ 45, 39, 38],
  55. [ 43, 38, 36],
  56. ...,
  57. [104, 67, 51],
  58. [100, 64, 46],
  59. [108, 64, 40]]], dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x000001DAB4EF0370>, 1

I am using Python 3.11.2 running on Windows 11. I have face_recognition v1.3.0 and dlib v19.24.1.

I already tried reinstalling everything based on the installation guide from face_recognition.

答案1

得分: 5

请用以下代码行替换:

  1. rgb_small_frame = numpy.ascontiguousarray(frame_process[:, :, ::-1])
英文:

Please replace the code line,

  1. rgb_small_frame = frame_process[:, :, ::-1]

with below code line,

  1. rgb_small_frame = numpy.ascontiguousarray(frame_process[:, :, ::-1])

答案2

得分: 0

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

your code worked bex

英文:

This is the answer

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

your code worked bex

huangapple
  • 本文由 发表于 2023年4月4日 15:36:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75926662.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定