Ask Your Question
0

I cant access my webcam Opencv 2.4.3

asked 2012-12-14 10:09:36 -0600

Kakashi gravatar image

updated 2013-01-09 03:00:54 -0600

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.

edit retag flag offensive close merge delete

Comments

run lsusb and ls /dev/video*

Victor1234 gravatar imageVictor1234 ( 2012-12-14 13:25:28 -0600 )edit

use <pre> tag to format you question

Victor1234 gravatar imageVictor1234 ( 2012-12-14 13:35:18 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-01-09 02:33:25 -0600

Geppertm gravatar image

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

edit flag offensive delete link more
0

answered 2013-01-09 02:21:41 -0600

Mahdi gravatar image

Hi

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

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-12-14 10:09:36 -0600

Seen: 643 times

Last updated: Jan 09 '13