CVVidCapture Class Reference#include <CVVidCapture.h>
Inheritance diagram for CVVidCapture:
List of all members.
Detailed Description
CVVidCapture provides the pure interface for derived video capture classses, and also provides some basic functionality for all video capture classes.
You *must* derive a class from it, and cannot simply instantiate it.
To use any CVVidCapture object, instantiated the desired derived type. The ideal way to do this is to go through CVPlatform, like this:
CVVidCapture* vidCap = CVPlatform::GetPlatform()->AcquireVideoCapture();
Call Init() to to initialize the capture library as needed.
Successful initialization, you can call EnumDevices() to enumerate the available video capture devices.
Once you've decided which capture device to use, call Connect() with the desired device name to connect to it. Now you can read and modify any of the camera properties and video modes.
When you're ready to receive images, either call Grab() for a single- shot grab, or setup a callback and call StartImageCap().
If you are using Grab(), be sure to call CVImage::ReleaseImage() on the grabbed image when done.
If you are doing a continuous capture, then the images are automatically released after the callback returns. However, if you want to keep the image around (for example, to place it on a queue for later processing outside of the callback), you may call CVImage::AddRef() on the image and it will not be deleted. Just make sure to call CVImage::ReleaseImage() later when done with that image.
Always check the incoming status code in the callbacks prior to attempting to access the data. If the status code is a failed result, the data is not present!
Call Stop() to end a continuous capture. Do NOT call Stop() from within a callback or it will deadlock. You still need to call Stop() when you're done to clean up even if you've aborted by returning false from the callback.
To clean up, call Disconnect() to disconnect from the device, then Uninit().
Make sure to delete the CVVidCapture object when done. If you used CVPlatform to create it, just call CVPlatform::Release() on the CVVidCapture*, like this:
CVPlatform::GetPlatform()->Release(vidCap);
- RCSfile
- CVVidCapture.h,v
- Date
- 2004/03/01 18:31:06
- Revision
- 1.7
- Author
- mikeellison
Definition at line 111 of file CVVidCapture.h. Public Types
- typedef bool(* CVVIDCAP_CALLBACK )(CVRES status, CVImage *imagePtr, void *userParam)
- enum CAMERA_PROPERTY {
CAMERAPROP_BRIGHT = 0,
CAMERAPROP_CONTRAST,
CAMERAPROP_HUE,
CAMERAPROP_SAT,
CAMERAPROP_SHARP,
CAMERAPROP_GAMMA,
CAMERAPROP_COLOR,
CAMERAPROP_WHITEBALANCE,
CAMERAPROP_BACKLIGHT,
CAMERAPROP_GAIN,
CAMERAPROP_NUMPROPS
}
Public Member Functions
- CVVidCapture ()
- virtual ~CVVidCapture ()
- virtual CVRES Init ()=0
- virtual void ClearDeviceList ()
- virtual CVRES RefreshDeviceList ()=0
- virtual CVRES GetNumDevices (int &numDevices)
- virtual CVRES GetDeviceInfo (int index, VIDCAP_DEVICE &deviceInfo)
- virtual CVRES Connect (int devIndex)=0
- virtual CVRES StartImageCap (CVImage::CVIMAGE_TYPE imageType, CVVIDCAP_CALLBACK callback, void *userParam)=0
- virtual CVRES Grab (CVImage::CVIMAGE_TYPE imageType, CVImage *&imagePtr)=0
- virtual CVRES Uninit ()
- virtual CVRES Disconnect ()
- virtual CVRES Stop ()
- virtual CVRES GetPropertyInfo (CAMERA_PROPERTY property, long *curVal=0, long *defVal=0, long *minVal=0, long *maxVal=0, long *step=0)
- virtual CVRES SetProperty (CAMERA_PROPERTY property, long value)
- virtual CVRES GetPropertyName (CAMERA_PROPERTY property, char *nameBuffer, int maxLength)
- virtual CVRES GetNumSupportedModes (int &numModes)
- virtual CVRES GetModeInfo (int index, VIDCAP_MODE &modeInfo)
- virtual CVRES SetMode (int index)
- virtual CVRES GetCurrentMode (VIDCAP_MODE &curMode)
- const char * GetFormatModeName (VIDCAP_FORMAT format)
- virtual CVRES AddMode (VIDCAP_MODE &addMode)
- virtual CVRES SetMode (VIDCAP_MODE &newMode)
- CVRES GetDeviceName (char *nameBuffer, int &maxLength)
- bool IsInitialized ()
- bool IsConnected ()
- bool IsStarted ()
Protected Types
Protected Member Functions
Protected Attributes
Member Typedef Documentation
|
|
CVVIDCAP_CALLBACK is the callback definition for continuous captures using the image class.
First, check the status code - if it's a successful status code, (e.g. if CVSUCCESS(status) returns true), then the imagePtr is valid. Otherwise, some sort of error has occurred - most likely, the camera has been disconnected.
imagePtr will be the captured image in the format type requested when the capture was started. It will be released by CVVidCapture when the callback returns - however, you may call AddRef() to add a reference to the image and keep it around outside of the callback if you want - just make sure to free it when done and be aware of memory limitations vs. number of frames captured.
Returning true continues the capture, returning false aborts it. You'll still have to call CVVidCapture::Stop() from another thread (e.g. outside the callback), but no more callbacks will be received after an abort and the processing will halt.
Do NOT call Stop() from within a callback or it will cause a deadlock. Instead, return false from the callback to cause an abort, then call Stop() from your main thread.
- Parameters:
-
| status | - Status of the capture (CVRES_VIDCAP_OK, CVRES_VIDCAP_CAPTURE_ERROR) |
| imagePtr | - ptr to image containing current frame of status is CVRES_VIDCAP_OK |
| userParam | - user defined value (suggested: this*) |
- Returns:
- bool - true continues capture, false halts it.
- See also:
- StartImageCap()
Definition at line 149 of file CVVidCapture.h. |
Member Enumeration Documentation
|
|
VIDCAP_STATES enumerates the states the video capture may be in or was previously in before being stopped.
Right now this is used to know when we need to reconfigure the capture driver for buffering. - Enumeration values:
-
| VIDCAP_UNCONNECTED |
|
| VIDCAP_SINGLE_SHOT_MODE |
|
| VIDCAP_CONTINUOUS_MODE |
|
Definition at line 230 of file CVVidCapture.h. |
Constructor & Destructor Documentation
| CVVidCapture::CVVidCapture |
( |
|
) |
|
|
Member Function Documentation
| void CVVidCapture::ClearDeviceList |
( |
|
) |
[virtual] |
|
| void CVVidCapture::ClearModes |
( |
|
) |
[protected, virtual] |
|
| virtual CVRES CVVidCapture::Connect |
( |
int |
devIndex |
) |
[pure virtual] |
|
| CVRES CVVidCapture::Disconnect |
( |
|
) |
[virtual] |
|
|
|
Disconnect from a previously connected capture device. Should only be called if a previous CVVidCapture::Connect() was successful.
Must set fConnected to false on success. Must also set fLastState to VIDCAP_UNCONNECTED
- Returns:
- CVRES result code.
- See also:
- Connect(), CVRes.h, CVResVidCap.h
Reimplemented in CVVidCaptureDSWin32.
Definition at line 319 of file CVVidCapture.cpp.
References CVRES, CVRES_SUCCESS, CVRES_VIDCAP_NOT_CONNECTED, fConnected, fLastState, and VIDCAP_UNCONNECTED.
Referenced by CVDevDisconnect(), CVidCapGuiTestDlg::OnDestroy(), CVidCapGuiTestDlg::OnSelchangeDevicelist(), TestIt(), and ~CVVidCapture(). |
|
|
GetDeviceInfo() retrieves the video capture device info for a specified index from the enumeration.
You must have called Init() previously. If it has been some time since calling init, refresh the device list with RefreshDeviceList() prior to getting the number of devices and device info.
- Parameters:
-
| index | - index into device list to retrieve information on. |
| deviceInfo | - video capture device information. Set on return. |
- Returns:
- CVRES result code
- See also:
- VIDCAP_DEVICE, GetNumDevices(), RefreshDeviceList(), Connect()
CVRes.h, CVResVidCap.h
Definition at line 264 of file CVVidCapture.cpp.
References CVRES, CVRES_SUCCESS, CVRES_VIDCAP_INVALID_DEVICE_INDEX, CVRES_VIDCAP_NO_DEVICES, CVRES_VIDCAP_NOT_INITIALIZED, fDeviceList, fInitialized, fNumDevices, and CVVidCapture::VIDCAP_DEVICE::NextDevice.
Referenced by CVGetDeviceName(), CVidCapGuiTestDlg::RefreshDevices(), and TestIt(). |
| CVRES CVVidCapture::GetDeviceName |
( |
char * |
nameBuffer, |
|
|
int & |
maxLength |
|
) |
|
|
| const char * CVVidCapture::GetFormatModeName |
( |
VIDCAP_FORMAT |
format |
) |
|
|
|
|
GetModeInfo() retrieves the video capture mode for a specified index from the enumeration. You must have called Connect() already to enumerate the available modes for the connected device before calling this function.
- Parameters:
-
| index | - index into mode list to retrieve information on. |
| modeInfo | - video mode information. Set on return. |
- Returns:
- CVRES result code
- See also:
- VIDCAP_MODE, GetNumSupportedModes(), SetMode(), GetCurrentMode()
CVRes.h, CVResVidCap.h
Definition at line 428 of file CVVidCapture.cpp.
References CVRES, CVRES_SUCCESS, CVRES_VIDCAP_MODE_NOT_SUPPORTED, CVRES_VIDCAP_NOT_CONNECTED, fConnected, fModeList, and CVVidCapture::VIDCAP_MODE::NextMode.
Referenced by CVDevGetModeInfo(), CVidCapGuiTestDlg::RefreshModeList(), and TestIt(). |
| CVRES CVVidCapture::GetNumDevices |
( |
int & |
numDevices |
) |
[virtual] |
|
| CVRES CVVidCapture::GetNumSupportedModes |
( |
int & |
numModes |
) |
[virtual] |
|
|
|
GetNumSupportedModes() retrieves the number of modes available on the currently connected image capture device.
You must have called Connect() already to enumerate the available modes for the connected device before calling this function.
- Parameters:
-
| numModes | - set to total number of available modes on return |
- Returns:
- CVRES result code
- See also:
- VIDCAP_MODE, GetModeInfo(), SetMode(), GetCurrentMode()
CVRes.h, CVResVidCap.h
Definition at line 403 of file CVVidCapture.cpp.
References CVRES, CVRES_SUCCESS, CVRES_VIDCAP_NOT_CONNECTED, fConnected, fModeList, and CVVidCapture::VIDCAP_MODE::NextMode.
Referenced by CVDevGetNumModes(), CVidCapGuiTestDlg::RefreshModeList(), and TestIt(). |
| CVRES CVVidCapture::GetPropertyInfo |
( |
CAMERA_PROPERTY |
property, |
|
|
long * |
curVal = 0, |
|
|
long * |
defVal = 0, |
|
|
long * |
minVal = 0, |
|
|
long * |
maxVal = 0, |
|
|
long * |
step = 0 |
|
) |
[virtual] |
|
| CVRES CVVidCapture::GetPropertyName |
( |
CAMERA_PROPERTY |
property, |
|
|
char * |
nameBuffer, |
|
|
int |
maxLength |
|
) |
[virtual] |
|
| virtual CVRES CVVidCapture::Init |
( |
|
) |
[pure virtual] |
|
| bool CVVidCapture::IsConnected |
( |
|
) |
|
|
| bool CVVidCapture::IsInitialized |
( |
|
) |
|
|
| bool CVVidCapture::IsStarted |
( |
|
) |
|
|
| virtual CVRES CVVidCapture::RefreshDeviceList |
( |
|
) |
[pure virtual] |
|
| CVRES CVVidCapture::SetMode |
( |
int |
index |
) |
[virtual] |
|
|
|
SetMode() sets the current capture mode to the one in the mode list that matches the specified index. You must have called Connect() already to enumerate the available modes for the connected device before calling this function.
- Parameters:
-
| index | - index into mode list |
- Returns:
- CVRES result code
- See also:
- GetNumSupportedModes(), GetModeInfo(), GetCurrentMode()
VIDCAP_MODE, CVRes.h, CVResVidCap.h
Definition at line 458 of file CVVidCapture.cpp.
References CVRES, CVRES_VIDCAP_MODE_NOT_SUPPORTED, CVRES_VIDCAP_NOT_CONNECTED, fConnected, fModeList, and CVVidCapture::VIDCAP_MODE::NextMode.
Referenced by CVDevGrabImage(), CVidCapGuiTestDlg::OnSelchangeModelist(), and TestIt(). |
| CVRES CVVidCapture::Stop |
( |
|
) |
[virtual] |
|
|
|
Stop() stops an active image capture started with StartImageCap(). (In derived classes, must stop other forms of continuous capture as well such as CVVidCaptureDSWin32::StartRawCap()).
Do NOT call Stop() from within a callback or it will cause a deadlock. Instead, return false from the callback to cause an abort, then call Stop() from your main thread.
Must set fStarted to false on success.
- Returns:
- CVRES result code.
- See also:
- StartImageCapture(), CVVIDCAP_CALLBACK, CVRes.h, CVResVidCap.h
Reimplemented in CVVidCaptureDSWin32.
Definition at line 304 of file CVVidCapture.cpp.
References CVRES, CVRES_SUCCESS, CVRES_VIDCAP_ALREADY_STOPPED, and fStarted.
Referenced by CVDevStopCap(), CVidCapGuiTestDlg::OnDestroy(), CVidCapGuiTestDlg::OnSelchangeDevicelist(), CVidCapGuiTestDlg::OnSelchangeModelist(), TestIt(), and ~CVVidCapture(). |
| CVRES CVVidCapture::Uninit |
( |
|
) |
[virtual] |
|
Member Data Documentation
|
|
Definition at line 631 of file CVVidCapture.h.
Referenced by CVVidCaptureDSWin32::Connect(), CVVidCaptureDSWin32::ConnectGraph(), CVVidCapture(), CVVidCaptureDSWin32::Disconnect(), Disconnect(), CVVidCaptureDSWin32::DisconnectGraph(), GetCurrentMode(), GetModeInfo(), GetNumSupportedModes(), CVVidCaptureDSWin32::Grab(), IsConnected(), SetMode(), CVVidCaptureDSWin32::StartImageCap(), CVVidCaptureDSWin32::StartRawCap(), CVVidCaptureDSWin32::Stop(), CVVidCaptureDSWin32::Uninit(), and ~CVVidCapture(). |
|
|
Definition at line 628 of file CVVidCapture.h.
Referenced by CVVidCaptureDSWin32::Connect(), CVVidCapture(), CVVidCaptureDSWin32::Disconnect(), GetDeviceInfo(), GetNumDevices(), CVVidCaptureDSWin32::Grab(), CVVidCaptureDSWin32::Init(), IsInitialized(), CVVidCaptureDSWin32::RefreshDeviceList(), CVVidCaptureDSWin32::StartImageCap(), CVVidCaptureDSWin32::StartRawCap(), CVVidCaptureDSWin32::Stop(), CVVidCaptureDSWin32::Uninit(), Uninit(), and ~CVVidCapture(). |
The documentation for this class was generated from the following files:
|