Ask Your Question

Revision history [back]

need help c920

Hi all ! I have a problem with my Logitech c920. Under windows 7 32 (My VS c++ application and commercial) after some minutes the camera turn off, under ubuntu 64 the same (in VLC, cheese, my opencv programs, gtk uvc, skype ...), but after install windows 8 the camera work fine long time and no problem. I try the same code, other webcam and all right on 7,8 and ubuntu 14.10, but no the c920. forgotten windows 7 im trying to get working the c920 under ubuntu, I use Gtk uvc viewer and video4linux to disable auto focus and other uvc driver option but the problem persist, after some minutes, the camera auto turn off freezing the image and showing "VIDIOC_DQBUF: no such device"

My code is:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <time.h>
#include <stdio.h>
using namespace cv;
using namespace std;

int main() {
VideoCapture cap(1);

time_t start, end;
double fps;
int counter = 0;
double sec;
time(&start);
if(!cap.isOpened())
return -1;

Mat frame;
cap >> frame;
namedWindow("cam");

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FPS, 20);

while (true)
{
    cap >> frame;
    imshow("cam", frame);

    time(&end);
    ++counter;
    sec = difftime (end, start);
    fps = counter / sec;
    printf("FPS = %.2f\n", fps);

    if (waitKey(30) >= 0)
    break;
}
cap.release();
cvDestroyWindow( "cam" );
return 0;
}

Thanks :)