4

I am trying to use a webcam for my project. I use Opencv2.4.11 and the Logicool webcam C270. I wrote a very simple code shown on below.

#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include <stdio.h>

using namespace std;
using namespace cv;

int main()
{
  Mat frame;
  VideoCapture capture(0); // open the default camera
  if (!capture.isOpened())  // check if we succeeded
    return -1;

  namedWindow("CVtest",1);

  while (true) {
    capture >> frame;
    imshow("CVtest", frame);
    waitKey(20);
  }
  return 0;
}

but this code is not work for me. I get this error messages.

jiehunt@ubuntu:~/work/test$ ./test.out 
init done 
opengl support available 
select timeout
select timeout

I found this page Select Timeout error in Ubuntu - Opencv , and I followed the step

sudo rmmod uvcvideo
sudo modprobe uvcvideo nodrop=1 timeout=6000 quirks=0x80

It doesn't work for me. When I turned on the trace of uvcvideo, I got this error message.

[13087.385542] uvcvideo: Marking buffer as bad (error bit set).
[13087.385545] uvcvideo: Frame complete (EOF found).

And now, I don't know what I should do.

My camera formats are shown bellow.

jiehunt@ubuntu:~/work/test$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
  Index       : 0
  Type        : Video Capture
  Pixel Format: 'YUYV'
  Name        : YUV 4:2:2 (YUYV)

  Index       : 1
  Type        : Video Capture
  Pixel Format: 'MJPG' (compressed)
  Name        : MJPEG
vwvw
  • 372
  • 4
  • 16
Jiehunt
  • 41
  • 3

0 Answers0