golib  0.5
goVideoCapture Class Reference

Video capture class. More...

#include <govideocapture.h>

Public Types

enum  ColourMode { RGB24, YUV422P, YUV420P, GREY }
 

Public Member Functions

 goVideoCapture (const char *devname, goSize_t width, goSize_t height)
 
bool setDevice (const char *name)
 Set device file name. More...
 
void setFileDescriptor (int fd)
 Set file discriptor of an already open device. More...
 
int getFileDescriptor () const
 Get file descriptor for open device. More...
 
bool setCaptureSize (goSize_t width, goSize_t height)
 Set capture frame size. More...
 
goSize_t getCaptureWidth () const
 Capture frame width. More...
 
goSize_t getCaptureHeight () const
 Capture frame height. More...
 
void setColourMode (enum ColourMode vm)
 Sets the colour mode. More...
 
enum ColourMode getColourMode () const
 Get the colour mode this object is currently set to. More...
 
bool open ()
 Open the device. More...
 
void close ()
 Close the open device.
 
bool grab (goSignal3DBase< void > &signal, const int *rgb_channels)
 Grab a frame from the open device. More...
 
bool grab (goSignal3D< void > &signal, const int *rgb_channels)
 Convenience method. More...
 
bool grab (void *buffer, goSize_t size)
 Grab a frame from the open device. More...
 
bool checkCapture () const
 Check if video capture is available by the open device. More...
 
bool setSettings ()
 Store settings from this object to the open device. More...
 
void getSettings ()
 Get settings from device and store them internally. It is a good idea to call this after opening a device. It is also called by setFileDescriptor(). This method calls getCapabilities() and getCaptureWindow().
 
void getValidRanges ()
 Get valid ranges for brightnes etc. More...
 
void setBrightness (double b)
 
double getBrightness () const
 
void setHue (double b)
 
double getHue () const
 
void setColour (double b)
 
double getColour () const
 
void setContrast (double b)
 
double getContrast () const
 
void setWhiteness (double b)
 
double getWhiteness () const
 
void printImageProperties (goString &ret)
 
- Public Member Functions inherited from goObjectBase
 goObjectBase ()
 Constructor.
 
virtual ~goObjectBase ()
 Destructor. More...
 
const char * getClassName () const
 Returns the class name. More...
 
int getClassID () const
 
virtual goSize_t memoryUsage () const
 Returns the size of this object or some measure of its memory consumption. More...
 
void setObjectName (const char *name)
 Set name string for an object. More...
 
void setObjectName (const goString &name)
 Set name string for an object. More...
 
const goStringgetObjectName () const
 Get the object name. More...
 
virtual bool writeObjectFile (FILE *) const
 Write object to a file. More...
 
virtual bool readObjectFile (FILE *)
 Read object from a file. More...
 
void connectObject (goObjectBase *object)
 Connects an object to this object. More...
 
void disconnectObject (const goObjectBase *object)
 Disconnects an object from this object.
 
virtual bool callObjectMethod (int methodID, goObjectMethodParameters *param=NULL)
 Call an object method by identifier. More...
 
virtual bool queueObjectMethod (int methodID, goObjectMethodParameters *param=NULL, bool blocking=false)
 Enqueue a method call to an internal list of methods. More...
 
bool callQueuedMethods ()
 Call all queued methods. More...
 

Protected Member Functions

void getCapabilities ()
 Gets device capabilities and stores them internally. Called, amongst others, by getSettings().
 
void getCaptureWindow ()
 Get the size of the capture frame from the device and store it internally. It can be retrieved with getCapture[Width|Height]().
 
- Protected Member Functions inherited from goObjectBase
void setClassID (int id)
 Sets the class name.
 
void printClassMessage (const char *msg)
 Sets the class name. More...
 
void printClassMessage (goString &msg)
 Prints an informational message to the calling console. More...
 
void sendObjectMessage (int messageID, void *data=NULL)
 Sends a message to all connected objects.
 
void sendObjectMessage (goObjectBase *object, int messageID, void *data=NULL)
 Sends a message to a specific object.
 
virtual void receiveObjectMessage (const goObjectMessage &message)
 Receive a message. More...
 

Detailed Description

Video capture class.

This class allows video capture, currently only from video4linux (version 1) devices. Version 2 will follow when the drivers for our cameras support it and there is need.

Note
Please report when a camera/driver works witht this class, it's fairly new and my first time using v4l.
Currently only supports video4linux devices under Linux. No Windows support.
Author
Christian Gosch
Examples
videocapture/videocapture.cpp.

Member Function Documentation

◆ checkCapture()

bool goVideoCapture::checkCapture ( ) const

Check if video capture is available by the open device.

Returns
True if capture is available, false otherwise.

◆ getCaptureHeight()

goSize_t goVideoCapture::getCaptureHeight ( ) const

Capture frame height.

Returns
Frame height in pixels.

◆ getCaptureWidth()

goSize_t goVideoCapture::getCaptureWidth ( ) const

Capture frame width.

Returns
Frame width in pixels.

◆ getColourMode()

enum goVideoCapture::ColourMode goVideoCapture::getColourMode ( ) const

Get the colour mode this object is currently set to.

Returns
The colour mode enumerator.

◆ getFileDescriptor()

int goVideoCapture::getFileDescriptor ( ) const

Get file descriptor for open device.

Returns
File descriptor. Negative means no device is open.

◆ getValidRanges()

void goVideoCapture::getValidRanges ( )

Get valid ranges for brightnes etc.

Todo:
Does not work yet. a) doesn't find the real maximum value the way it works now, b) gets invalid argument all the time.

◆ grab() [1/3]

bool goVideoCapture::grab ( goSignal3D< void > &  target,
const int *  rgb_channels 
)

Convenience method.

Calls grab (goSignal3DBase<void>&), changing type and size of target if necessary.

Parameters
targetTarget containing the image if return value is true.
rgb_channelsContains 3 integers, each denoting the channel number in target for r, g, and b respectively.
Returns
True if successful, false otherwise.

◆ grab() [2/3]

bool goVideoCapture::grab ( goSignal3DBase< void > &  target,
const int *  rgb_channels 
)

Grab a frame from the open device.

Parameters
targetTarget. Must currently be linear in memory (block size == signal size), of type GO_UINT8 and must have 3 channels if the colour mode is RGB24.
rgb_channelsContains 3 integers, each denoting the channel number in target for r, g, and b respectively.
Returns
True if successful, false otherwise.
Examples
videocapture/videocapture.cpp.

◆ grab() [3/3]

bool goVideoCapture::grab ( void *  target,
goSize_t  sz 
)

Grab a frame from the open device.

Note
No data conversion is done. The data is as-is from the video device.
Parameters
targetTarget pointer to memory of size sz bytes.
szMaximum of sz bytes is read from the open device.
Returns
True if successful, false otherwise.

◆ open()

bool goVideoCapture::open ( )

Open the device.

See also
setDevice()
Returns
True if successful, false otherwise.
Examples
videocapture/videocapture.cpp.

◆ setCaptureSize()

bool goVideoCapture::setCaptureSize ( goSize_t  width,
goSize_t  height 
)

Set capture frame size.

Parameters
widthWidth in pixels.
heightHeight in pixels.
Returns
True if successful, false otherwise.
Examples
videocapture/videocapture.cpp.

◆ setColourMode()

void goVideoCapture::setColourMode ( enum ColourMode  vm)

Sets the colour mode.

Note
Care should be taken when forcing a colour mode and setting it with setSettings(). Apparently some devices don't support most colour modes or I'm not using the v4l interface right. Either way, it didn't work with my cameras. So just use the format provided by the camera for now.
Parameters
mColour mode enumerator.

◆ setDevice()

bool goVideoCapture::setDevice ( const char *  name)

Set device file name.

Parameters
nameDevice file name, e.g. "/dev/video0"
Returns
True if successful, false otherwise.
Examples
videocapture/videocapture.cpp.

◆ setFileDescriptor()

void goVideoCapture::setFileDescriptor ( int  fd)

Set file discriptor of an already open device.

Sets the descriptor and automatically reads settings from the device to update the settings stored in the goVideoCapture object.

Parameters
fdFile descriptor.

◆ setSettings()

bool goVideoCapture::setSettings ( )

Store settings from this object to the open device.

Returns
True if successful, false otherwise. Also check the logfile.
Examples
videocapture/videocapture.cpp.

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