简体   繁体   中英

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

this might be 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM