PVideoDevice Class Referenceabstract

This class defines a video device. More...

`#include <videoio.h>`

Inheritance diagram for PVideoDevice:

## Classes

struct | OpenArgs

## Public Types

enum | VideoFormat { PAL, NTSC, SECAM, Auto, NumVideoFormats }
Public Types inherited from PVideoFrameInfo
enum | ResizeMode { eScale, eCropCentre, eCropTopLeft, eMaxResizeMode }

enum

StandardSizes {
SQCIFWidth = 128, SQCIFHeight = 96, QCIFWidth = 176, QCIFHeight = 144,
CIFWidth = 352, CIFHeight = 288, CIF4Width = 704, CIF4Height = 576,
CIF16Width = 1408, CIF16Height = 1152, HD480Width = 704, HD480Height = 480,
i480Width = 704, i480Height = 480, HD720Width = 1280, HD720Height = 720,
p720Width = 1280, p720Height = 720, HD1080Width = 1920, HD1080Height = 1080,
i1080Width = 1920, i1080Height = 1080, HDTVWidth = 1920, HDTVHeight = 1080,
MaxWidth = 1920, MaxHeight = 1200
}

Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...

## Public Member Functions

virtual | ~PVideoDevice ()
| Delete structures created by PVideoDevice();. More...
const PString & | GetDeviceName () const
| Get the device name of the open device. More...
virtual PStringArray | GetDeviceNames () const =0
| Get a list of all of the drivers available. More...
virtual PBoolean | OpenFull (const OpenArgs &args, PBoolean startImmediate=true)
| Open the device given the device name. More...
virtual PBoolean | Open (const PString &deviceName, PBoolean startImmediate=true)=0
| Open the device given the device name. More...
virtual PBoolean | IsOpen ()=0
| Determine if the device is currently open. More...
virtual PBoolean | Close ()=0
| Close the device. More...
virtual PBoolean | Start ()=0
| Start the video device I/O capture. More...
virtual PBoolean | Stop ()=0
| Stop the video device I/O capture. More...
virtual PBoolean | SetVideoFormat (VideoFormat videoFormat)
| Set the video format to be used. More...
virtual VideoFormat | GetVideoFormat () const
| Get the video format being used. More...
virtual int | GetNumChannels ()
| Get the number of video channels available on the device. More...
virtual PBoolean | SetChannel (int channelNumber)
| Set the video channel to be used on the device. More...
virtual int | GetChannel () const
| Get the video channel to be used on the device. More...
virtual PBoolean | SetColourFormatConverter (const PString &colourFormat)
| Set the colour format to be used, trying converters if available. More...
virtual PBoolean | GetVFlipState ()
| Get the video conversion vertical flip state. More...
virtual PBoolean | SetVFlipState (PBoolean newVFlipState)
| Set the video conversion vertical flip state. More...
virtual PBoolean | GetFrameSizeLimits (unsigned &minWidth, unsigned &minHeight, unsigned &maxWidth, unsigned &maxHeight)
| Get the minimum & maximum size of a frame on the device. More...
virtual PBoolean | SetFrameSizeConverter (unsigned width, unsigned height, ResizeMode resizeMode=eMaxResizeMode)
| Set the frame size to be used, trying converters if available. More...
virtual PBoolean | SetFrameSizeConverter (unsigned width, unsigned height, PBoolean)
| Set the frame size to be used, trying converters if available. More...
virtual PBoolean | SetNearestFrameSize (unsigned width, unsigned height)
| Set the nearest available frame size to be used. More...
virtual PBoolean | SetFrameSize (unsigned width, unsigned height)
| Set the frame size to be used. More...
virtual PBoolean | GetFrameSize (unsigned &width, unsigned &height) const
| Get the frame size being used. More...
virtual PINDEX | GetMaxFrameBytes ()=0
| Get the maximum frame size in bytes. More...
int | GetLastError () const
| Get the last error code. More...
virtual PBoolean | CanCaptureVideo () const =0
| Is the device a camera, and obtain video. More...
virtual int | GetBrightness ()
| Get the brightness of the image. More...
virtual PBoolean | SetBrightness (unsigned newBrightness)
| Set brightness of the image. More...
virtual int | GetWhiteness ()
| Get the whiteness of the image. More...
virtual PBoolean | SetWhiteness (unsigned newWhiteness)
| Set whiteness of the image. More...
virtual int | GetColour ()
| Get the colour of the image. More...
virtual PBoolean | SetColour (unsigned newColour)
| Set colour of the image. More...
virtual int | GetContrast ()
| Get the contrast of the image. More...
virtual PBoolean | SetContrast (unsigned newContrast)
| Set contrast of the image. More...
virtual int | GetHue ()
| Get the hue of the image. More...
virtual PBoolean | SetHue (unsigned newHue)
| Set hue of the image. More...
virtual PBoolean | GetParameters (int *whiteness, int *brightness, int *colour, int *contrast, int *hue)
| Return whiteness, brightness, colour, contrast and hue in one call. More...
virtual PBoolean | SetVideoChannelFormat (int channelNumber, VideoFormat videoFormat)
| Set VideoFormat and VideoChannel in one ioctl. More...
void | SetPreferredColourFormat (const PString &colourFmt)
| Set preferred native colour format from video capture device. More...
const PString & | GetPreferredColourFormat ()
| Get preferred native colour format from video capture device. More...
Public Member Functions inherited from PVideoFrameInfo
| PVideoFrameInfo ()
| Construct video frame information. More...
| PVideoFrameInfo (unsigned frameWidth, unsigned frameHeight, const PString &colourFormat="YUV420P", unsigned frameRate=15, ResizeMode resizeMode=eScale)
virtual Comparison | Compare (const PObject &obj) const
| Compare the two PVideoFrameInfo and return their relative rank. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual unsigned | GetFrameWidth () const
| Get the width of the frame being used. More...
virtual unsigned | GetFrameHeight () const
| Get the height of the frame being used. More...
virtual PBoolean | SetFrameSar (unsigned width, unsigned height)
| Set the sar size to be used. More...
virtual PBoolean | GetSarSize (unsigned &width, unsigned &height) const
| Get the sar size being used. More...
virtual unsigned | GetSarWidth () const
| Get the width of the sar being used. More...
virtual unsigned | GetSarHeight () const
| Get the height of the sar being used. More...
virtual PBoolean | SetFrameRate (unsigned rate)
| Set the video frame rate to be used on the device. More...
virtual unsigned | GetFrameRate () const
| Get the video frame rate used on the device. More...
virtual PBoolean | SetColourFormat (const PString &colourFormat)
| Set the colour format to be used. More...
virtual const PString & | GetColourFormat () const
| Get the colour format to be used. More...
void | SetResizeMode (ResizeMode mode)
| Set the resize mode to be used. More...
ResizeMode | GetResizeMode () const
| Get the resize mode to be used. More...
PINDEX | CalculateFrameBytes () const
| Get the number of bytes of an image, given a particular width, height and colour format. More...
bool | Parse (const PString &str)
| Parse a descriptor string for the video format. More...
Public Member Functions inherited from PObject
virtual | ~PObject ()
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Protected Member Functions

| PVideoDevice ()
| Create a new video device (input or output). More...
PINDEX | GetMaxFrameBytesConverted (PINDEX rawFrameBytes) const
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Protected Attributes

PString | deviceName
int | lastError
VideoFormat | videoFormat
int | channelNumber
PString | preferredColourFormat
PBoolean | nativeVerticalFlip
PColourConverter * | converter
PBYTEArray | frameStore
int | frameBrightness
int | frameWhiteness
int | frameContrast
int | frameColour
int | frameHue
Protected Attributes inherited from PVideoFrameInfo
unsigned | frameWidth
unsigned | frameHeight
unsigned | sarWidth
unsigned | sarHeight
unsigned | frameRate
PString | colourFormat
ResizeMode | resizeMode

## Additional Inherited Members

Static Public Member Functions inherited from PVideoFrameInfo
static PINDEX | CalculateFrameBytes (unsigned width, unsigned height, const PString &colourFormat)
static bool | ParseSize (const PString &str, unsigned &width, unsigned &height)
| Parse the standard size string names. More...
static PString | AsString (unsigned width, unsigned height)
| Get a width/height as a standard size string name. More...
static PStringArray | GetSizeNames ()
| Get all "known" image size names. More...
Static Public Member Functions inherited from PObject
static const char * | Class ()
| Get the name of the class as a C string. More...
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...

## Detailed Description

This class defines a video device.

This class is used to abstract the few parameters that are common to both\ input and output devices.

Example colour formats are:

"Grey" Simple 8 bit linear grey scale "Gray" Synonym for Grey "RGB32" 32 bit RGB "RGB24" 24 bit RGB "RGB565" 16 bit RGB (6 bit green) "RGB555" 15 bit RGB "YUV422" YUV 4:2:2 packed "YUV422P" YUV 4:2:2 planar "YUV411" YUV 4:1:1 packed "YUV411P" YUV 4:1:1 planar "YUV420" YUV 4:2:0 packed "YUV420P" YUV 4:2:0 planar "YUV410" YUV 4:1:0 packed "YUV410P" YUV 4:1:0 planar "MJPEG" Motion JPEG "UYVY422" YUV 4:2:2 packed as U Y V Y U Y V Y ... "UYV444" YUV 4:4:4 packed as U Y V U Y V ... They are used in IEEE 1394 digital cameras. The specification is found at http://www.1394ta.org/Download/Technology/Specifications/2000/IIDC_Spec_v1_30.pdf

## Member Enumeration Documentation

## VideoFormat

enum PVideoDevice::VideoFormat

Enumerator
PAL |
NTSC |
SECAM |
Auto |
NumVideoFormats |

## Constructor & Destructor Documentation

## PVideoDevice()

PVideoDevice::PVideoDevice | ( |  | ) |

protected

Create a new video device (input or output).

## ~PVideoDevice()

virtual PVideoDevice::~PVideoDevice | ( |  | ) |

virtual

Delete structures created by PVideoDevice();.

## Member Function Documentation

## CanCaptureVideo()

virtual PBoolean PVideoDevice::CanCaptureVideo | ( |  | ) | const

pure virtual

Is the device a camera, and obtain video.

Implemented in PVideoInputDevice, and PVideoOutputDevice.

## Close()

virtual PBoolean PVideoDevice::Close | ( |  | ) |

pure virtual

Close the device.

Implemented in PVideoInputDevice, PVideoOutputDevice, and PVideoInput1394DcDevice.

## GetBrightness()

virtual int PVideoDevice::GetBrightness | ( |  | ) |

virtual

Get the brightness of the image.

0xffff-Very bright. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

## GetChannel()

virtual int PVideoDevice::GetChannel | ( |  | ) | const

virtual

Get the video channel to be used on the device.

Default behaviour returns the value of the channelNumber variable.

## GetColour()

virtual int PVideoDevice::GetColour | ( |  | ) |

virtual

Get the colour of the image.

0xffff-lots of colour. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

## GetContrast()

virtual int PVideoDevice::GetContrast | ( |  | ) |

virtual

Get the contrast of the image.

0xffff-High contrast. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

## GetDeviceName()

const PString& PVideoDevice::GetDeviceName | ( |  | ) | const

inline

Get the device name of the open device.

## GetDeviceNames()

virtual PStringArray PVideoDevice::GetDeviceNames | ( |  | ) | const

pure virtual

Get a list of all of the drivers available.

## GetFrameSize()

virtual PBoolean PVideoDevice::GetFrameSize | ( | unsigned & | width,
|  | unsigned & | height
| ) |  | const

virtual

Get the frame size being used.

Default behaviour returns the value of the frameWidth and frameHeight variable and returns true.

Reimplemented from PVideoFrameInfo.

## GetFrameSizeLimits()

virtual PBoolean PVideoDevice::GetFrameSizeLimits | ( | unsigned & | minWidth,
|  | unsigned & | minHeight,
|  | unsigned & | maxWidth,
|  | unsigned & | maxHeight
| ) |  |

virtual

Get the minimum & maximum size of a frame on the device.

Default behaviour returns the value 1 to UINT_MAX for both and returns false.

Parameters

  minWidth | Variable to receive minimum width
  minHeight | Variable to receive minimum height
  maxWidth | Variable to receive maximum width
  maxHeight | Variable to receive maximum height

Reimplemented in PVideoInput1394DcDevice.

## GetHue()

virtual int PVideoDevice::GetHue | ( |  | ) |

virtual

Get the hue of the image.

0xffff-High hue. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

## GetLastError()

int PVideoDevice::GetLastError | ( |  | ) | const

inline

Get the last error code.

This is a platform dependent number.

## GetMaxFrameBytes()

virtual PINDEX PVideoDevice::GetMaxFrameBytes | ( |  | ) |

pure virtual

Get the maximum frame size in bytes.

Note a particular device may be able to provide variable length frames (eg motion JPEG) so will be the maximum size of all frames.

Implemented in PVideoOutputDeviceRGB, and PVideoInput1394DcDevice.

## GetMaxFrameBytesConverted()

PINDEX PVideoDevice::GetMaxFrameBytesConverted | ( | PINDEX | rawFrameBytes | ) | const

protected

## GetNumChannels()

virtual int PVideoDevice::GetNumChannels | ( |  | ) |

virtual

Get the number of video channels available on the device.

Default behaviour returns 1.

Reimplemented in PVideoInput1394DcDevice.

## GetParameters()

virtual PBoolean PVideoDevice::GetParameters | ( | int * | whiteness,
|  | int * | brightness,
|  | int * | colour,
|  | int * | contrast,
|  | int * | hue
| ) |  |

virtual

Return whiteness, brightness, colour, contrast and hue in one call.

Reimplemented in PVideoInput1394DcDevice.

## GetPreferredColourFormat()

const PString& PVideoDevice::GetPreferredColourFormat | ( |  | ) |

inline

Get preferred native colour format from video capture device.

Returns empty == no preference

## GetVFlipState()

virtual PBoolean PVideoDevice::GetVFlipState | ( |  | ) |

virtual

Get the video conversion vertical flip state.

Default action is to return false.

## GetVideoFormat()

virtual VideoFormat PVideoDevice::GetVideoFormat | ( |  | ) | const

virtual

Get the video format being used.

Default behaviour returns the value of the videoFormat variable.

## GetWhiteness()

virtual int PVideoDevice::GetWhiteness | ( |  | ) |

virtual

Get the whiteness of the image.

0xffff-Very white. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

## IsOpen()

virtual PBoolean PVideoDevice::IsOpen | ( |  | ) |

pure virtual

Determine if the device is currently open.

Implemented in PVideoInput1394DcDevice.

## Open()

virtual PBoolean PVideoDevice::Open | ( | const PString & | deviceName,
|  | PBoolean | startImmediate = `true`
| ) |  |

pure virtual

Open the device given the device name.

Parameters

  deviceName | Device name to open
  startImmediate | Immediately start device

Implemented in PVideoInputDevice, and PVideoInput1394DcDevice.

## OpenFull()

virtual PBoolean PVideoDevice::OpenFull | ( | const OpenArgs & | args,
|  | PBoolean | startImmediate = `true`
| ) |  |

virtual

Open the device given the device name.

Parameters

  args | Parameters to set on opened device
  startImmediate | Immediately start device

## SetBrightness()

virtual PBoolean PVideoDevice::SetBrightness | ( | unsigned | newBrightness | ) |

virtual

Set brightness of the image.

0xffff-Very bright.

Reimplemented in PVideoInput1394DcDevice.

## SetChannel()

virtual PBoolean PVideoDevice::SetChannel | ( | int | channelNumber | ) |

virtual

Set the video channel to be used on the device.

The channel number is an integer from 0 to GetNumChannels()-1. The special value of -1 will find the first working channel number.

Default behaviour sets the value of the channelNumber variable and then returns true.

Parameters

  channelNumber | New channel number for device.

Reimplemented in PVideoInput1394DcDevice.

## SetColour()

virtual PBoolean PVideoDevice::SetColour | ( | unsigned | newColour | ) |

virtual

Set colour of the image.

0xffff-lots of colour.

Reimplemented in PVideoInput1394DcDevice.

## SetColourFormatConverter()

virtual PBoolean PVideoDevice::SetColourFormatConverter | ( | const PString & | colourFormat | ) |

virtual

Set the colour format to be used, trying converters if available.

This function will set the colour format on the device to one that is compatible with a registered converter, and install that converter so that the correct format is used.

Reimplemented in PVideoInput1394DcDevice.

## SetContrast()

virtual PBoolean PVideoDevice::SetContrast | ( | unsigned | newContrast | ) |

virtual

Set contrast of the image.

0xffff-High contrast.

Reimplemented in PVideoInput1394DcDevice.

## SetFrameSize()

virtual PBoolean PVideoDevice::SetFrameSize | ( | unsigned | width,
|  | unsigned | height
| ) |  |

virtual

Set the frame size to be used.

Note that devices may not be able to produce the requested size, and this function will fail. See SetFrameSizeConverter().

Default behaviour sets the frameWidth and frameHeight variables and returns true.

Parameters

  width | New width of frame
  height | New height of frame

Reimplemented from PVideoFrameInfo.

Reimplemented in PVideoOutputDeviceRGB, and PVideoInput1394DcDevice.

## SetFrameSizeConverter() [1/2]

virtual PBoolean PVideoDevice::SetFrameSizeConverter | ( | unsigned | width,
|  | unsigned | height,
|  | ResizeMode | resizeMode = `eMaxResizeMode`
| ) |  |

virtual

Set the frame size to be used, trying converters if available.

If the device does not support the size, a set of alternate resolutions are attempted. A converter is setup if possible.

Parameters

  width | New width of frame
  height | New height of frame
  resizeMode | Mode to use if resizing is required.

## SetFrameSizeConverter() [2/2]

virtual PBoolean PVideoDevice::SetFrameSizeConverter | ( | unsigned | width,
|  | unsigned | height,
|  | PBoolean |
| ) |  |

inline virtual

Set the frame size to be used, trying converters if available.

Function used for Backward compatibility only. If the device does not support the size, a set of alternate resolutions are attempted. A converter is setup if possible.

Parameters

  width | New width of frame
  height | New height of frame

Reimplemented in PVideoInput1394DcDevice.

References PVideoFrameInfo::eScale, PVideoFrameInfo::GetFrameSize(), and PVideoFrameInfo::SetFrameSize().

## SetHue()

virtual PBoolean PVideoDevice::SetHue | ( | unsigned | newHue | ) |

virtual

Set hue of the image.

0xffff-High hue.

Reimplemented in PVideoInput1394DcDevice.

## SetNearestFrameSize()

virtual PBoolean PVideoDevice::SetNearestFrameSize | ( | unsigned | width,
|  | unsigned | height
| ) |  |

virtual

Set the nearest available frame size to be used.

Note that devices may not be able to produce the requested size, so this function picks the nearest available size.

Default behaviour simply calls SetFrameSize().

Parameters

  width | New width of frame
  height | New height of frame

Reimplemented in PVideoInputDevice.

## SetPreferredColourFormat()

void PVideoDevice::SetPreferredColourFormat | ( | const PString & | colourFmt | ) |

inline

Set preferred native colour format from video capture device.

Note empty == no preference.

## SetVFlipState()

virtual PBoolean PVideoDevice::SetVFlipState | ( | PBoolean | newVFlipState | ) |

virtual

Set the video conversion vertical flip state.

Default action is to return false.

Parameters

  newVFlipState | New vertical flip state

## SetVideoChannelFormat()

virtual PBoolean PVideoDevice::SetVideoChannelFormat | ( | int | channelNumber,
|  | VideoFormat | videoFormat
| ) |  |

virtual

Set VideoFormat and VideoChannel in one ioctl.

## SetVideoFormat()

virtual PBoolean PVideoDevice::SetVideoFormat | ( | VideoFormat | videoFormat | ) |

virtual

Set the video format to be used.

Default behaviour sets the value of the videoFormat variable and then returns true.

Parameters

  videoFormat | New video format

Reimplemented in PVideoInput1394DcDevice.

## SetWhiteness()

virtual PBoolean PVideoDevice::SetWhiteness | ( | unsigned | newWhiteness | ) |

virtual

Set whiteness of the image.

0xffff-Very white.

Reimplemented in PVideoInput1394DcDevice.

## Start()

virtual PBoolean PVideoDevice::Start | ( |  | ) |

pure virtual

Start the video device I/O capture.

Implemented in PVideoOutputDevice, and PVideoInput1394DcDevice.

## Stop()

virtual PBoolean PVideoDevice::Stop | ( |  | ) |

pure virtual

Stop the video device I/O capture.

Implemented in PVideoOutputDevice, and PVideoInput1394DcDevice.

## Member Data Documentation

## channelNumber

int PVideoDevice::channelNumber

protected

## converter

PColourConverter* PVideoDevice::converter

protected

## deviceName

PString PVideoDevice::deviceName

protected

## frameBrightness

int PVideoDevice::frameBrightness

protected

## frameColour

int PVideoDevice::frameColour

protected

## frameContrast

int PVideoDevice::frameContrast

protected

## frameHue

int PVideoDevice::frameHue

protected

## frameStore

PBYTEArray PVideoDevice::frameStore

protected

## frameWhiteness

int PVideoDevice::frameWhiteness

protected

## lastError

int PVideoDevice::lastError

protected

## nativeVerticalFlip

PBoolean PVideoDevice::nativeVerticalFlip

protected

## preferredColourFormat

PString PVideoDevice::preferredColourFormat

protected

## videoFormat

VideoFormat PVideoDevice::videoFormat

protected

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

- videoio.h