Ask Your Question
0

capturing camera ?

asked 2013-02-19 01:57:36 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

i'm using VS2010 conbined with OpenCV 2.2 ! i've tryied programming to capturing camera but the result as the picture below: image description i've configed property as follow:

*VC++ Directories:
 +Include Directories... add: 'C:\OpenCV2.1\include\opencv;'
 +Library Directories... add: 'C:\OpenCV2.1\lib;'
 +Source Directories... add folders in path "...\\include\\Opencv2"
*C/C++ =>General=>add “C:\OpenCV2.2\include”.
*Linker:
 +General=>Additional Library Directories => add “C:\OpenCV2.2\lib”.
*Input=>Additional Dependencies:
 opencv_imgproc220d.lib
 opencv_core220d.lib
 opencv_highgui220d.lib
 opencv_ml220d.lib
 opencv_video220d.lib
 opencv_features2d220d.lib
 opencv_calib3d220d.lib
 opencv_objdetect220d.lib
 opencv_contrib220d.lib
 opencv_legacy220d.lib
 opencv_flann220d.lib

And here is the code:

#include "stdafx.h"
#include "highgui.h"

int _tmain(int argc, _TCHAR* argv[])
{
CvCapture* capture = cvCaptureFromCAM(0);
IplImage* src = NULL;
cvNamedWindow("Webcam",0);
while(1)
{
    src = cvQueryFrame(capture);
    if(!src) break;
    char c = cvWaitKey(30);
    if(c == 27) break;
    cvShowImage("Webcam",src);
}
cvReleaseImage(&src);
cvDestroyWindow("Webcam");
return 0;
}

hope for help! ^~^ !

edit retag flag offensive close merge delete

Comments

well, you're supposed to click 'OK' there, so what's your 'real' question ? there's nothing obviously wrong with your code. ( well, apart from 2.2 being a bit old, and using IplImages instead of cv::Mat's )

berak gravatar imageberak ( 2013-02-19 03:43:37 -0600 )edit

Yes, i think the problem here is configuration for property! but i do not know which error i've got!

nqchanh gravatar imagenqchanh ( 2013-02-19 09:32:21 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2013-02-19 16:05:17 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

From the blurry picture it looks like Video Source selection dialog. Time honored way is to step thru the code - including the OpenCV, however MOST capAVI calls in OpenCV do not check the return values. And some of the OpenCV "wrappers" are notorous for that. cvCaptureFromCAM(0) is a prime example!

The code you have posted is a typical lazy way OpenCV (samples) are presented - for example CvCapture* capture = cvCaptureFromCAM(0); You should verify / assert / check if "capture" is set correctly. When dealing wiht hardware, functions returns are important. For all we know, you may be missing video driver for you camera.(But unlikely).

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-19 01:57:36 -0600

Seen: 636 times

Last updated: Feb 19 '13