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

Comments

Projects
None yet
6 participants
@5ong

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

This comment has been minimized.

Show comment
Hide comment
@abala003

abala003 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.

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

This comment has been minimized.

Show comment
Hide comment
@5ong

5ong 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

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

@ageitgey ageitgey closed this Mar 24, 2017

@carlosjs23

This comment has been minimized.

Show comment
Hide comment
@carlosjs23

carlosjs23 Apr 6, 2017

@5ong follow this for 16.04:

Install dependencies

sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

Install ffmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure –-enable-nonfree –-enable-pic –-enable-shared
make
sudo make install

Install opencv

wget https://github.com/opencv/opencv/archive/3.2.0.tar.gz
tar xf 3.2.0.tar.gz
cd opencv-3.2.0
mkdir build
cd build

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 ..

make
sudo make install

I hope this work for you.

carlosjs23 commented Apr 6, 2017

@5ong follow this for 16.04:

Install dependencies

sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

Install ffmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure –-enable-nonfree –-enable-pic –-enable-shared
make
sudo make install

Install opencv

wget https://github.com/opencv/opencv/archive/3.2.0.tar.gz
tar xf 3.2.0.tar.gz
cd opencv-3.2.0
mkdir build
cd build

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 ..

make
sudo make install

I hope this work for you.

@vishwassathish

This comment has been minimized.

Show comment
Hide comment
@vishwassathish

vishwassathish 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 ?

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

This comment has been minimized.

Show comment
Hide comment
@karlxuthus

karlxuthus Mar 9, 2018

My operating System is win10 .
Can I follow it ?

karlxuthus commented Mar 9, 2018

My operating System is win10 .
Can I follow it ?

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