tags:

views:

21

answers:

2

Hi, 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

A: 

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);    
}
karlphillip
A: 

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

More info here: http://www.aishack.in/2010/03/capturing-images-with-directx/

Utkarsh Sinha