Camera is not detected by opencv only ?
My laptop camera is working with cheese. it works even with ffmpg from terminal by
ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 out.avi
when i do
ls /dev/video*
, it shows
dev/Video0
so camera works.
but with opencv it doesn't detect at all. if i replace 0 with "some video file" in VideoCapture, the video runs. my code is
#include "opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main() {
VideoCapture videoIn(0);
if (!videoIn.isOpened()) {
cout << "yo, i ain't see no camera";
return -1;
}
namedWindow("out", 1);
for (;;) {
Mat frame;
videoIn >> frame;
imshow("out", frame);
if (waitKey(30) >= 0)
break;
}
return 1;
}
I use Sony C series laptop with Ubuntu 13.04 and opencv 2 in Eclipse IDE.
Basically switch to openCV 2.4.6, tons of bugs with the video interface have been reported in the last versions and fixes have been written. Try first to get it to work in 2.4.6, if bug still persists, report back!
If you work with OpenCV 2.4.6, try 2.4.6.1. There is the error with v4l camera in 2.4.6, more details on opencv.org website.
i typed
for knowing exact package version and it returned 2.4.6 if i run
it says package 'libcv2' is not installed.
and one more concern. in my /usr/local/include there are two folders. one is opencv and another is opencv2. is it because i have somehow installed both opencv 1 and 2 ? and the program is getting compiled by opencv 1. ?
when i start a project in eclipse, i use usr/local/include/opencv2 as the include path in project properties.
you need the 2.4.6.1 package, not the 2.4.6 package...
Wow.. a truckload of thanks.. totally worked after installing 2.4.6.1.. thnx for the support..
Just like @Alexander Shishkov proposed :) Will post the solution as an answer. Please accept in order to make the topic look solved.
@Alexander Shishkov, @StevenPuttemans I have also the same problem still with version 2.4.6.1 in Windows7. Actually the camera seems detected but as soon as it tries to turn on dies. Do you have any idea in this case?
Please create a new topic with all your system details, camera specifics, operating system, ... we will help you there. Don't hijack threads, because we want to stick to one problem in one topic only.