0
votes

I'm using cmake to build my project with opencv. There are two sub-projects, A and B, under the top directory. A has no opencv function while B uses VideoCapture to get image from webcam. There is no problem at first.

However, after I add the code from B to A, B can still capture image from webcam, but A cannot do the same thing, the error is below:

HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
VIDIOC_STREAMON: Inappropriate ioctl for device

It is strange, and I find that VideoCapture cannot get image in A, the code is below

VideoCapture cam;
cam.open(0);
if(!cam.isOpened()){
  cout << "Failed to open webcam" << endl;
  return false;
}
Mat Image;
cam >> Image;
if(Image.empty())
        cout<<"Image empty"<<endl;

"Image empty" is always in console, which means it just cannot capture the image at all!! I followed some suggestions such as install "v4l2ucp", but there is no folder under "/usr/lib/" named "libv4l", so LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so dose not work.

I will very appreciate it if someone could give me some help to solve the problem in project A.

1

1 Answers

0
votes

The file might not necessarily be there. Try find / -name "*v4l1compat.so*" 2>/dev/null or find / -name "*libv4l*" 2>/dev/null. It should succeed since your project B captures frames just fine. Then try to export found file to LD_PRELOAD. If it won't succeed - check out your libv4l installation.

And make sure you trying to open() the correct camera which is not already in use.