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

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

Closed
5ong opened this issue Mar 20, 2017 · 5 comments
Closed

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

5ong opened this issue Mar 20, 2017 · 5 comments

Comments

@5ong
Copy link

5ong commented Mar 20, 2017

  • 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

@abala003
Copy link

abala003 commented Mar 20, 2017

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.

@5ong
Copy link
Author

5ong commented Mar 21, 2017

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

@vishwassathish
Copy link

vishwassathish commented Jun 30, 2017

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 ?

@karlxuthus
Copy link

My operating System is win10 .
Can I follow it ?

@daniel-onyenwee
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants