开发者

How to extract a function from highgui module(opencv)and place in the code file

this might b开发者_开发知识库e a silly question, but I need to know if for the code below, if i can extract the cvCaptureFromCAM() function from the highgui.lib and paste it in my code so that I can rename it to camcapture() and then call that within my program without just including the highgui library file at the beginning of the code file:

CvCapture * pCapture = 0;


//Initialize video capture
pCapture = cvCaptureFromCAM( CV_CAP_ANY );

Many Thanks


It is possible! However, after a couple of days you will eventually realize OpenCV relies on other libraries to do its job, meaning you would also need to dig into those libraries in order to get everything to make cvCaptureFromCAM() work on your application without linking it with OpenCV.

Now, think about this for a second, even if you succeeded, how would you retrieve/save/display images from the camera without using other OpenCV functions like cvShowImage(), cvGrabFrame(), etc. Consider all the hard work you would also have for stripping this functions from the library. Is it worth it?

In case you're just trying to make your code cleaner, you could make a simple wrapper around cvCaptureFromCAM(), and simply call camcapture() from inside your main() function.

/* Global variables */
CvCapture* capture = NULL;

void camcapture()
{
   capture = cvCaptureFromCAM(CV_CAP_ANY);    
}


Another thing you could do is use the videoInput library. It uses DirectX to get access to the webcam.

More info here: http://aishack.in/tutorials/capturing-images-with-directx/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜