Skip to content

RuntimeError: Unsupported image type, must be 8bit gray or RGB image #21

Closed

Description

@5ong
  • face_recognition version: 0.1.9
  • Python version: 3.5.2
  • Operating System: Ubuntu 16

Hello and thank you for this great resource, please see if you can help me to the right direction to fix this error:

"I tried to run this example "facerec_from_webcam.py" and got the following error"
Traceback (most recent call last):
File "facecam.py", line 22, in
face_locations = face_recognition.face_locations(frame)
File "/home/namong/.local/lib/python3.5/site-packages/face_recognition/api.py", line 85, in face_locations
return [_rect_to_css(face) for face in _raw_face_locations(img, number_of_times_to_upsample)]
File "/home/namong/.local/lib/python3.5/site-packages/face_recognition/api.py", line 74, in _raw_face_locations
return face_detector(img, number_of_times_to_upsample)
RuntimeError: Unsupported image type, must be 8bit gray or RGB image."

-namong

Activity

  1. abala003 commented on Mar 20, 2017

    @abala003

    I got the same error. There could be two reasons,

    1. There is no image (video frame) received from your webcam. Meaning its not initialized right. You can confirm this using "cv2.VideoCapture.open (device ID)". This should return a True if all is good.
    2. There is no image (video frame) received from your webcam. The device ID mentioned on this line "video_capture = cv2.VideoCapture(0)" could be other than 0 if you are using an webcam via USB.

    Solution:

    1. cv2 doesn't compile with FFmpeg be default. Pip uninstall Opencv and follow the steps mentioned in this link
      http://www.wiomax.com/compile-opencv-and-ffmpeg-on-ubuntu/

    2. verify if the webcam has a device ID 0.

    Hope this helps.

  2. 5ong commented on Mar 21, 2017

    @5ong
    Author

    Thank you for your response, visionanand. The instruction in that link does not work for me, there are several errors when I tried those commands. It probably because i am using Ubuntu 16. I will give it another try sometime tomorrow then

    -namong

  3. vishwassathish commented on Jun 30, 2017

    @vishwassathish

    When i try to run this command
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON this Cmake error pops up :

    CMake Error: The source directory "/home/quantum/Quantum/Machine Learning/face_recognition-master/opencv-3.2.0/build/WITH_OPENGL=ON" does not exist.
    what do i do ?

  4. karlxuthus commented on Mar 9, 2018

    @karlxuthus

    My operating System is win10 .
    Can I follow it ?

  5. daniel-onyenwee commented on Aug 14, 2024

    @daniel-onyenwee

    The problem is simple the image format is in RGBA, so convert the image to RGB it works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions