Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.