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.