Ask Your Question
0

I cant access my webcam Opencv 2.4.3

asked Dec 14 '12

Kakashi gravatar image

updated Jan 9 '13

Here is my code

#include <highgui.h>
#include <cv.h>
int main(int argc,char** argv)
{
    IplImage* frame;
    CvCapture* capture = cvCreateCameraCapture(-1);
    cvNamedWindow("Example 2",CV_WINDOW_AUTOSIZE);
    while(1)
    {
        frame = cvQueryFrame(capture);
        if(!frame)
        {
            printf("Error");
            break;
        }
        cvShowImage("Example 2",frame);
        char c = cvWaitKey(33);
        if(c==27)
            break;
    }
    cvReleaseCapture(&capture);
    cvDestroyWindow("Example 2");
}

It shows the message "error". I am using opencv2.4.3 in Ubuntu 12.10 and my ide is Eclipse.

Preview: (hide)

Comments

run lsusb and ls /dev/video*

Victor1234 gravatar imageVictor1234 (Dec 14 '12)edit

use <pre> tag to format you question

Victor1234 gravatar imageVictor1234 (Dec 14 '12)edit

2 answers

Sort by » oldest newest most voted
0

answered Jan 9 '13

Geppertm gravatar image

Try cvCreateCameraCapture(0). Maybe you should use Mat instead of IplImage.

Preview: (hide)
0

answered Jan 9 '13

Mahdi gravatar image

Hi

I have run your code and I think you should use IplImage* rather than IplImage!

Preview: (hide)

Question Tools

Stats

Asked: Dec 14 '12

Seen: 657 times

Last updated: Jan 09 '13