TadasBaltrusaitis / OpenFace

OpenFace – a state-of-the art tool intended for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation.
Other
6.86k stars 1.84k forks source link

VIDIOC_REQBUFS: Inappropriate ioctl for device #962

Closed K0RBEY closed 3 years ago

K0RBEY commented 3 years ago

Describe the bug After installing OpenFace (latest release) by following the "Unix Installation" (with download_models.sh and install.sh), I tried to use FaceLandmarkImg and it worked. But when I'm trying to use either FaceLandmarkVid, FaceLandmarkVidMulti or FeatureExtraction it didn't work and it says :

Attempting to read from file: ./Samples/user.avi VIDIOC_REQBUFS: Inappropriate ioctl for device Failed to open the video file at location: ./Samples/user.avi

I checked and this is the right path of my video

So, it seems to be an error with videos and after some research on the internet I found that this is a problem with OpenCV. I tried to reinstall OpenCV but it didn't work. I also tried with a MP4 video and I had the same issue. Do you have any ideas to fix this issue ?

Desktop (please complete the following information):

K0RBEY commented 3 years ago

I fixed the issue

Solution

I deleted the OpenFace folder, then I installed Gstreamer with the following commands :

sudo apt-get install gstreamer1.0* sudo apt install ubuntu-restricted-extras sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

After that I followed the part "Advanced Ubuntu installation" of the Unix Installation Wiki (https://github.com/TadasBaltrusaitis/OpenFace/wiki/Unix-Installation) When you run cmake for OpenCV installation, make sure it displays Gstreamer : YES

Finally, I installed the C++ models (binaries) in OpenFace/build/bin/model/patch_experts (Wiki is here : https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download)

tashrifbillah commented 3 years ago

My GStreamer was already found and enabled:

--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   YES (1.10.4)
--     v4l/v4l2:                    YES (linux/videodev2.h)

Yet I have this issue.

tashrifbillah commented 3 years ago

I have posted my solution here: https://github.com/opencv/opencv/issues/14721#issuecomment-909494365

In a nutshell, I had to build ffmpeg from source and link against OpenCV before attempting OpenFace.

seppalai commented 1 year ago

I am still having this issue. Now the thing is that OpenCV (I built from source) finds both FFMPEG and GStreamer:

  Video I/O:
    DC1394:                      YES (2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (58.54.100)
      avformat:                  YES (58.29.100)
      avutil:                    YES (56.31.100)
      swscale:                   YES (5.5.100)
      avresample:                YES (4.0.0)
    GStreamer:                   YES (1.16.3)
    v4l/v4l2:                    YES (linux/videodev2.h)

and even in the python3 console I can import cv2 and open a video file and it runs nicely (like in https://learnopencv.com/read-write-and-display-a-video-using-opencv-cpp-python/).

But when I test OpenFace like in the documentation: ./bin/FaceLandmarkVid -f "../samples/changeLighting.wmv" -f "../samples/2015-10-15-15-14.avi"

I get the error:

Could not find the HAAR face detector location
Reading the landmark detector/tracker from: ./bin/model/main_ceclm_general.txt
Reading the landmark detector module from: ./bin/model/cen_general.txt
Reading the PDM module from: ./bin/model/pdms/In-the-wild_aligned_PDM_68.txt....Done
Reading the Triangulations module from: ./bin/model/tris_68.txt....Done
Reading the intensity CEN patch experts from: ./bin/model/patch_experts/cen_patches_0.25_of.dat....Done
Reading the intensity CEN patch experts from: ./bin/model/patch_experts/cen_patches_0.35_of.dat....Done
Reading the intensity CEN patch experts from: ./bin/model/patch_experts/cen_patches_0.50_of.dat....Done
Reading the intensity CEN patch experts from: ./bin/model/patch_experts/cen_patches_1.00_of.dat....Done
Reading part based module....left_eye_28
Reading the landmark detector/tracker from: ./bin/model/model_eye/main_clnf_synth_left.txt
Reading the landmark detector module from: ./bin/model/model_eye/clnf_left_synth.txt
Reading the PDM module from: ./bin/model/model_eye/pdms/pdm_28_l_eye_3D_closed.txt....Done
Reading the intensity CCNF patch experts from: ./bin/model/model_eye/patch_experts/left_ccnf_patches_1.00_synth_lid_.txt....Done
Reading the intensity CCNF patch experts from: ./bin/model/model_eye/patch_experts/left_ccnf_patches_1.50_synth_lid_.txt....Done
Could not find the HAAR face detector location
Done
Reading part based module....right_eye_28
Reading the landmark detector/tracker from: ./bin/model/model_eye/main_clnf_synth_right.txt
Reading the landmark detector module from: ./bin/model/model_eye/clnf_right_synth.txt
Reading the PDM module from: ./bin/model/model_eye/pdms/pdm_28_eye_3D_closed.txt....Done
Reading the intensity CCNF patch experts from: ./bin/model/model_eye/patch_experts/ccnf_patches_1.00_synth_lid_.txt....Done
Reading the intensity CCNF patch experts from: ./bin/model/model_eye/patch_experts/ccnf_patches_1.50_synth_lid_.txt....Done
Could not find the HAAR face detector location
Done
Reading the landmark validation module....Done
Attempting to read from file: ../samples/changeLighting.wmv
VIDIOC_REQBUFS: Inappropriate ioctl for device
Failed to open the video file at location: ../samples/changeLighting.wmv

I'm running this on WSL2 (Ubuntu 20.04) so I'm thinking if that might add another layer of difficulty...

qin123xyz commented 1 year ago

have you solved the problem? my bug is the same as your: Could not find the HAAR face detector location VIDIOC_REQBUFS: Inappropriate ioctl for device my ubuntu version is also 20.04

satheesh3 commented 10 months ago

Any luck with this running on ubuntu 20.04 ?

brmarkus commented 10 months ago

Sure! ("Could not find the HAAR face detector location" usually is harmless as HAAR is optional)

HarryXD2018 commented 7 months ago

If you are using Ubuntu 18.08 and run into the same problem, here is my solution:

I ran the ./install.sh to install, and I found this during compiling opencv:

Video I/O:
--     DC1394:                      YES (2.2.5)
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)

To avoid this, I run the following commands and it shows different status (sorry I didn't copy but the FFMPEG related changed to YES).

 sudo apt-get install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
 sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev

Hope my solution helps! (now I am stepping to the next error, may edit later)