GCGlib  0.04.228
GCG Graphics Engine
gcgVIDEOCAPTURE Class Reference

Class for capturing video from camera devices. More...

#include <gcg.h>

Inheritance diagram for gcgVIDEOCAPTURE:
gcgVIDEO gcgCLASS

Public Member Functions

 gcgVIDEOCAPTURE ()
 Constructs a valid video capture object. The capture actually starts with calls to setCallBackFunction() and openCamera(). More...
 
virtual ~gcgVIDEOCAPTURE ()
 Releases all video capture resources by calling destroyVideo(). More...
 
virtual bool destroyVideo ()
 Releases all resources of this video capture object. More...
 
virtual int getNumberOfCameras ()
 Returns the number of valid cameras installed in the system. More...
 
virtual bool getCameraName (unsigned int id, char *pCameraName, unsigned int maxName)
 Gets the human readable name of the capture device given its integer identification. More...
 
virtual bool openCamera (unsigned int id, unsigned int width, unsigned int height, unsigned char bpp, float fps)
 Opens the capture device and makes it ready to start image retrieval. More...
 
virtual bool start ()
 Starts synchronous capturing. If successful, the capture starts from the device indicated by the previous call to openCamera() and the frames are delivered to the callback set by setCallBackFunction(). More...
 
virtual bool stop ()
 Stops synchronous capturing. If successful, the capture stops. It generally releases some video resources. For a faster restart, use pause() instead. More...
 
virtual bool resume ()
 Resumes synchronous capturing. If successful, the capture restarts. More...
 
virtual bool pause ()
 Pauses the synchronous capturing. More...
 
virtual bool isCapturing ()
 Returns true if the object is currently capturing, i.e., not stoped. More...
 
virtual bool setCallBackFunction (void(*callback)(gcgVIDEOCAPTURE *))
 Sets the callback function for the current object. It should be called before start(). Changing the internal function during the capture might give undesirable results. The callback function receives a pointer of the gcgVIDEOCAPTURE object that is delivering the new frame. The callback must return as fast as possible otherwise the video capture stream will be delayed. This might result in frame losses or instability depending on the system. More...
 
virtual double copyFrameTo (gcgIMAGE *dstimg)
 Copies the last delivered frame into a gcgIMAGE object. It is generally used during a call to the callback function defined by setCallBackFunction() in order to get a copy of the new frame. More...
 
- Public Member Functions inherited from gcgVIDEO
 gcgVIDEO ()
 Constructs a valid but empty image. The image can be used as destiny image in any gcgIMAGE method or GCGlib function. More...
 
virtual ~gcgVIDEO ()
 Releases all video resources by deleting the video handler. More...
 
- Public Member Functions inherited from gcgCLASS
void * operator new (size_t size)
 Defines a new operator to be used by instatiations of GCGlib classes instead the global one. More...
 
void * operator new (size_t size, const std::nothrow_t &) throw ()
 Defines a new operator to be used by instantiations of GCGlib classes instead the global one. Returns a NULL pointer instead of throwing an exception if an error occurs. More...
 
void * operator new[] (size_t size)
 Defines a new operator to be used by GCGlib array allocations instead the global one. More...
 
void * operator new[] (size_t size, const std::nothrow_t &) throw ()
 Defines a new operator to be used by vector allocations instead the global one. More...
 
void operator delete (void *p)
 Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
 
void operator delete (void *p, const std::nothrow_t &) throw ()
 Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
 
void operator delete[] (void *p)
 Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
 
void operator delete[] (void *p, const std::nothrow_t &) throw ()
 Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
 

Detailed Description

Class for capturing video from camera devices.

The gcgVIDEOCAPTURE class is the main interface of GCGlib with camera devices. It uses platform specific objects and APIs. The camera is identified by its sequencial integer number. The capture mechanism is synchronous using a callback funtion. The video frames are provided by gcgIMAGE objects. Do not change any attributes unless you are absolutely sure about you are doing.

Since
0.01.6

Constructor & Destructor Documentation

◆ gcgVIDEOCAPTURE()

gcgVIDEOCAPTURE::gcgVIDEOCAPTURE ( )

Constructs a valid video capture object. The capture actually starts with calls to setCallBackFunction() and openCamera().

See also
openCamera()
setCallBackFunction()
~gcgVIDEOCAPTURE()

◆ ~gcgVIDEOCAPTURE()

virtual gcgVIDEOCAPTURE::~gcgVIDEOCAPTURE ( )
virtual

Releases all video capture resources by calling destroyVideo().

See also
destroyVideo()
gcgVIDEOCAPTURE()

Member Function Documentation

◆ copyFrameTo()

virtual double gcgVIDEOCAPTURE::copyFrameTo ( gcgIMAGE dstimg)
virtual

Copies the last delivered frame into a gcgIMAGE object. It is generally used during a call to the callback function defined by setCallBackFunction() in order to get a copy of the new frame.

Parameters
dstimgA pointer to the gcgIMAGE object to which the last frame received by this gcgVIDEOCAPTURE must be copied to. If NULL, a warning is just reported.
Returns
the frame time in seconds. If negative, an error has occurred. Check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
openCamera()
start()
setCallBackFunction()

◆ destroyVideo()

virtual bool gcgVIDEOCAPTURE::destroyVideo ( )
virtual

Releases all resources of this video capture object.

Returns
true if the resources were released. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
gcgVIDEOCAPTURE()
~gcgVIDEOCAPTURE()

◆ getCameraName()

virtual bool gcgVIDEOCAPTURE::getCameraName ( unsigned int  id,
char *  pCameraName,
unsigned int  maxName 
)
virtual

Gets the human readable name of the capture device given its integer identification.

Parameters
idThe device capture identifier.
pCameraNamePointer to the char buffer to receive the string. It must be non-null. The maximum number of chars supported by pCameraName must be indicated in maxName.
maxNameMaximum number of characters supported by the buffer pCameraName.
Returns
true if the name was retrieved. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
getNumberOfCameras()

◆ getNumberOfCameras()

virtual int gcgVIDEOCAPTURE::getNumberOfCameras ( )
virtual

Returns the number of valid cameras installed in the system.

Returns
the number of cameras. If negative or zero, no capture devices are available or an error occurred: check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
getCameraName()

◆ isCapturing()

virtual bool gcgVIDEOCAPTURE::isCapturing ( )
virtual

Returns true if the object is currently capturing, i.e., not stoped.

Returns
true if the capture is going on or paused.
See also
start()
stop()
openCamera()

◆ openCamera()

virtual bool gcgVIDEOCAPTURE::openCamera ( unsigned int  id,
unsigned int  width,
unsigned int  height,
unsigned char  bpp,
float  fps 
)
virtual

Opens the capture device and makes it ready to start image retrieval.

Parameters
idThe device capture identifier.
widthDesired frame width in pixels. It might not be supported by the device.
heightDesired frame height in pixels. It might not be supported by the device.
bppDesired number of bits per pixel of each pixel. It might not be supported by the device.
fpsDesired frames per second rate. It might not be supported by the device.
Returns
true if the camera was successfully opened. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem and make sure the parameters are valid for the given device.
See also
start()
stop()
resume()
pause()
setCallBackFunction()

◆ pause()

virtual bool gcgVIDEOCAPTURE::pause ( )
virtual

Pauses the synchronous capturing.

Returns
true if the capture was paused. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
start()
stop()
resume()
openCamera()

◆ resume()

virtual bool gcgVIDEOCAPTURE::resume ( )
virtual

Resumes synchronous capturing. If successful, the capture restarts.

Returns
true if the capture is resumed. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
start()
stop()
pause()
openCamera()

◆ setCallBackFunction()

virtual bool gcgVIDEOCAPTURE::setCallBackFunction ( void(*)(gcgVIDEOCAPTURE *)  callback)
virtual

Sets the callback function for the current object. It should be called before start(). Changing the internal function during the capture might give undesirable results. The callback function receives a pointer of the gcgVIDEOCAPTURE object that is delivering the new frame. The callback must return as fast as possible otherwise the video capture stream will be delayed. This might result in frame losses or instability depending on the system.

Parameters
callbackpointer to a function that receives one gcgVIDEOCAPTURE pointer and returns void. When called, the callback function receives the pointer of the object that delivers the new frame. If NULL, a warning is reported and all subsequent frames are discarded.
Returns
true if the callback was correctly set. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
openCamera()
start()
copyFrameTo()

◆ start()

virtual bool gcgVIDEOCAPTURE::start ( )
virtual

Starts synchronous capturing. If successful, the capture starts from the device indicated by the previous call to openCamera() and the frames are delivered to the callback set by setCallBackFunction().

Returns
true if the capture started. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
openCamera()
stop()
resume()
pause()

◆ stop()

virtual bool gcgVIDEOCAPTURE::stop ( )
virtual

Stops synchronous capturing. If successful, the capture stops. It generally releases some video resources. For a faster restart, use pause() instead.

Returns
true if the capture stoped. If it returns false, check GCG_REPORT_MESSAGE(gcgGetReport()) for knowing the problem.
See also
start()
openCamera()
resume()
pause()

The documentation for this class was generated from the following file: