![]() |
Capture Example | |
|
|
WHAT DOES THIS EXAMPLE DO? | |
| In this short example, VideoOCX is used to capture one frame from a VfW video source and display it in the application's dialog. Capturing means to transfer the image data to your applications memory. This gives you the possibility to "work" with the images (e.g. image processing algrithms etc.). VideoOCX provides functions to support you in doing so, but these functions are not part of this example. | ||
|
|
HOW DOES IT WORK? | |
| First, a couple of necessary initializations are done in part (1) of the example. In Part (2), one frame is captured and displayed afterwards. Last but not least, the video connection is closed and the used memory freed in Part (3). | ||
|
|
VISUAL BASIC (see below for C++) | |
| 1 | '
Image Handle Dim image as Long ' Select first VfW device (can be 0-9) VideoOcx.Driver = 0 ' // Open video driver connection VideoOcx.Init ' allocate image memory image = VideoOcx.GetColorImageHandle ' Start internal capture process VideoOcx.Start |
|
| 2 |
' get a picture, if possible if (VideoOcx.Capture(image)) then ' show in control VideoOcx.Show image end if |
|
| 3 |
' Stop internal capture process VideoOcx.Stop ' free memory VideoOcx.ReleaseImageHandle image ' close video connection VideoOcx.Close |
|
|
|
C++ | |
| 1 |
// Image Handle long image; // Select first VfW device (can be 0-9) m_VideoOcx.SetDriver(0); // Open video driver connection m_VideoOcx.Init(); // allocate image memory image = m_VideoOcx.GetColorImageHandle(); // Start internal capture process m_VideoOcx.Start(); |
|
| 2 |
// get a picture, if possible if (m_VideoOcx.Capture(image)) // show in control m_VideoOcx.Show(image); |
|
| 3 |
// Stop internal capture process m_VideoOcx.Stop(); // free memory m_VideoOcx.ReleaseImageHandle(image); // close video connection m_VideoOcx.Close(); |
|
|
|
WHAT ELSE DO I NEED? | |
| You will need no more commands than the ones used in this example to implement it. But, of course, it makes little sense to capture and display just one image. We did this only to keep the example short and easy to understand. In order to capture and display continiously in your own application, you will need to implement Part (2) of this example in some kind of a loop. | ||