HIGHGUI ERROR: V4L: index 0 is not correct

Screenshot-cw418@hud-desktop: ~-workspace-readwebcam-src

When I moved the openCV development platform from the home to the office, a wired thing happened – the programme that I debugged smoothly in the home did not work at all in the office – even the simplest openCV camera view example, and the error said that – ‘HIGHGUI ERROR: V4L: index 0 is not correct‘ – but nothing of openCV configurations were changed at all!

So, where was the error from and, how to fix that wired error?

What caused this error?

Firstly I searched google for ‘HIGHGUI ERROR: V4L: index 0 is not correct’. This issue should be relevant with V4L.

Some pages the search results suggested to remove the v4l in Ubuntu, and then reinstall it again cleanly.

Some others suggested that re-configure and compile the openCV 2.3.1 might be solving the problem – as there was a file called ‘cvcap_libv4l.cpp’ in the source compiling folder, and a bug function was called in that file – find a line with ‘mman‘ function, and it supposed to be ‘libv4l_mman‘.

But, reconfiguring and re-compiling the openCV? That would take ages!

The unexpected solution

Before starting the re-compiling thing, be aware of this – the camera, yes, the camera!

Changing another camera may help? Why not bother to have a dead try?!

Oh-my— my camera was not plugged in!!!

Plugged in the camera, bingo~ everything worked fine.

Appendix – reading images from the webcam

#include “opencv2/video/tracking.hpp”
#include “opencv2/imgproc/imgproc.hpp”
#include “opencv2/highgui/highgui.hpp”
#include “opencv2/core/core.hpp”

#include
using namespace std;
using namespace cv;

int main(int, char**)
{
VideoCapture cap(0); // open the default camera, here generates the camera issue
if(!cap.isOpened()) // check if webcam open succeeded
{cout<<"!!!camera not opened."<> frame; // get a new frame from camera
imshow(“edges”, frame);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}

Author: Andol Li

A HCI researcher, a digital media lecturer, an information product designer, and a python/php/java coder.

4 Comments On “ HIGHGUI ERROR: V4L: index 0 is not correct”

Leave a comment
Due to technical adjustments, the comment function is shortly closed and will be re-openning soon. Thanks.


Copyrights 2006-2017 © All rights reserved
Theme Tree2, re-designed by Andol Li, powered by WordPress and Bootsrap
WWW.ANDOL.ME | 浙ICP备15040508号-1
公安备案图标 浙公网安备33010602004018号
Back to top