PDA

View Full Version : opencv2.2 webcam



afro_cv
7th August 2011, 14:45
Good day, I'm desperate.
Initially intended to do a QT application that uses a webcam, then after a google search I found the opencv.

But the opencv only has given me problems. Already missed 5 days this
3 days only, to integrate in QTCREATOR, i.e. I started with the opencv 2.3 but as not managed to integrate there found a site explaining how to integrate the opencv 2.2 in qtcreator
I used this site:

http://www.barbato.us/2011/03/18/using-opencv2-within-qtcreator-in-windows-2/

Exceeded the pace of integration. I investigated using the webcam and found the following code:


QMessageBox msgBox;
CvCapture* capture = NULL;
if ((capture = cvCreateCameraCapture( -1 )) == NULL)
{
msgBox.setText( "Cannot open initialize webcam!\n" );
msgBox.exec();

return ;
}

cvNamedWindow("mywindow", CV_WINDOW_AUTOSIZE);

cvQueryFrame(capture); // Sometimes needed to get correct data

while (1)
{
IplImage* frame = cvQueryFrame(capture); // check return
{
msgBox.setText( "ERROR: cvQueryFrame failed\n");
msgBox.exec();

break;
}

cvShowImage("mywindow", frame); // Do not release the frame!

int key = cvWaitKey(10);
if (key == 0x1b)
break;
}

cvReleaseCapture(&capture);
cvDestroyWindow("mywindow");



The problem with the above code is that it appears only a gray screen, and has exprimentei almost everything I found on the internet. AND
still made a guest appearance a gray screen, and the more serious is that the gray screen appears only once, that is, when I run the program for the second time gives me "cannot open initialize webcam". And the first time that work appears "ERROR: cvQueryFrame failed"


My webcam is working well, as I experienced with SKYPE and MSN. And already tried -1. .2 in cvCreateCameraCapture (or cvCaptureFromCAM) and nothing.


I don't know if installed correctly the opencv 2.2 in qtcreator but I think Yes, but the opencv does not work go to DIRECTSHOW .... I chose the opencv for the program can function
on any Windows operating system regardless if it is xp, vista, 7

I use Qt Creator 2.2.1
Qt 4.7.4
Opencv2.2.0
Windows 7, but i want to work in XP AND VISTA

afro_cv
7th August 2011, 21:41
Someone can tell me how can I configure qtcreator with DirectShow?
I need to create a class that captures webcam and places it in a QLABEL, does anyone know how can I do this?

Dong Back Kim
7th August 2011, 23:20
Someone can tell me how can I configure qtcreator with DirectShow?
I need to create a class that captures webcam and places it in a QLABEL, does anyone know how can I do this?

http://doc.trolltech.com/4.7/widgets-imageviewer.html
The above shows how to make a QLabel as an image but it seems this is not the first think you need to implement. I guess as long as you can convert your image captured from webcam into some sort of Qt compatible format then you can do anything you want really. The following one was quite helpful for me. That's showing how to convert cv::Mat to OpenCV.

http://opencv-users.1802565.n2.nabble.com/QImage-to-OpenCV-td5121181.html

It may also be helpful if you try to ask on OpenCV user group.

Regards,

stampede
8th August 2011, 08:49
I need to create a class that captures webcam and places it in a QLABEL, does anyone know how can I do this?
http://www.qtcentre.org/threads/43056-Qt-OpenCV-simple-example