# PVideoDevice Class Reference

This class defines a video device. More...

`#include <videoio.h>`

Inheritance diagram for PVideoDevice:

List of all members.

## Public Types

| PAL
| NTSC
| SECAM
| Auto
| NumVideoFormats
enum | VideoFormat { PAL, NTSC, SECAM, Auto, NumVideoFormats }

## Public Member Functions

virtual | ~PVideoDevice ()
| Delete structures created by PVideoDevice();.
const PString & | GetDeviceName () const
| Get the device name of the open device.
virtual PStringArray | GetDeviceNames () const =0
| Get a list of all of the drivers available.
virtual PBoolean | OpenFull (const OpenArgs &args, PBoolean startImmediate=true)
| Open the device given the device name.
virtual PBoolean | Open (const PString &deviceName, PBoolean startImmediate=true)=0
| Open the device given the device name.
virtual PBoolean | IsOpen ()=0
| Determine if the device is currently open.
virtual PBoolean | Close ()=0
| Close the device.
virtual PBoolean | Start ()=0
| Start the video device I/O capture.
virtual PBoolean | Stop ()=0
| Stop the video device I/O capture.
virtual PBoolean | SetVideoFormat (VideoFormat videoFormat)
| Set the video format to be used.
virtual VideoFormat | GetVideoFormat () const
| Get the video format being used.
virtual int | GetNumChannels ()
| Get the number of video channels available on the device.
virtual PBoolean | SetChannel (int channelNumber)
| Set the video channel to be used on the device.
virtual int | GetChannel () const
| Get the video channel to be used on the device.
virtual PBoolean | SetColourFormatConverter (const PString &colourFormat)
| Set the colour format to be used, trying converters if available.
virtual PBoolean | GetVFlipState ()
| Get the video conversion vertical flip state.
virtual PBoolean | SetVFlipState (PBoolean newVFlipState)
| Set the video conversion vertical flip state.
virtual PBoolean | GetFrameSizeLimits (unsigned &minWidth, unsigned &minHeight, unsigned &maxWidth, unsigned &maxHeight)
| Get the minimum & maximum size of a frame on the device.
virtual PBoolean | SetFrameSizeConverter (unsigned width, unsigned height, ResizeMode resizeMode=eMaxResizeMode)
| Set the frame size to be used, trying converters if available.
virtual PBoolean | SetFrameSizeConverter (unsigned width, unsigned height, PBoolean)
| Set the frame size to be used, trying converters if available.
virtual PBoolean | SetNearestFrameSize (unsigned width, unsigned height)
| Set the nearest available frame size to be used.
virtual PBoolean | SetFrameSize (unsigned width, unsigned height)
| Set the frame size to be used.
virtual PBoolean | GetFrameSize (unsigned &width, unsigned &height) const
| Get the frame size being used.
virtual PINDEX | GetMaxFrameBytes ()=0
| Get the maximum frame size in bytes.
int | GetLastError () const
| Get the last error code.
virtual PBoolean | CanCaptureVideo () const =0
| Is the device a camera, and obtain video.
virtual int | GetBrightness ()
| Get the brightness of the image.
virtual PBoolean | SetBrightness (unsigned newBrightness)
| Set brightness of the image.
virtual int | GetWhiteness ()
| Get the whiteness of the image.
virtual PBoolean | SetWhiteness (unsigned newWhiteness)
| Set whiteness of the image.
virtual int | GetColour ()
| Get the colour of the image.
virtual PBoolean | SetColour (unsigned newColour)
| Set colour of the image.
virtual int | GetContrast ()
| Get the contrast of the image.
virtual PBoolean | SetContrast (unsigned newContrast)
| Set contrast of the image.
virtual int | GetHue ()
| Get the hue of the image.
virtual PBoolean | SetHue (unsigned newHue)
| Set hue of the image.
virtual PBoolean | GetParameters (int *whiteness, int *brightness, int *colour, int *contrast, int *hue)
| Return whiteness, brightness, colour, contrast and hue in one call.
virtual PBoolean | SetVideoChannelFormat (int channelNumber, VideoFormat videoFormat)
| Set VideoFormat and VideoChannel in one ioctl.
void | SetPreferredColourFormat (const PString &colourFmt)
| Set preferred native colour format from video capture device.
const PString & | GetPreferredColourFormat ()
| Get preferred native colour format from video capture device.

## Protected Member Functions

| PVideoDevice ()
| Create a new video device (input or output).
PINDEX | GetMaxFrameBytesConverted (PINDEX rawFrameBytes) const

## 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

## Classes

struct | OpenArgs

## 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

enum PVideoDevice::VideoFormat

Enumerator:

  PAL |
  NTSC |
  SECAM |
  Auto |
  NumVideoFormats |

## Constructor & Destructor Documentation

PVideoDevice::PVideoDevice | ( |  | ) | `[protected]`

Create a new video device (input or output).

virtual PVideoDevice::~PVideoDevice | ( |  | ) | `[virtual]`

Delete structures created by PVideoDevice();.

## Member Function Documentation

virtual PBoolean PVideoDevice::CanCaptureVideo | ( |  | ) | const`[pure virtual]`

Is the device a camera, and obtain video.

Implemented in PVideoOutputDevice, and PVideoInputDevice.

virtual PBoolean PVideoDevice::Close | ( |  | ) | `[pure virtual]`

Close the device.

Implemented in PVideoOutputDevice, PVideoInputDevice, and PVideoInput1394DcDevice.

virtual int PVideoDevice::GetBrightness | ( |  | ) | `[virtual]`

Get the brightness of the image.

0xffff-Very bright. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

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.

virtual int PVideoDevice::GetColour | ( |  | ) | `[virtual]`

Get the colour of the image.

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

Reimplemented in PVideoInput1394DcDevice.

virtual int PVideoDevice::GetContrast | ( |  | ) | `[virtual]`

Get the contrast of the image.

0xffff-High contrast. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

const PString& PVideoDevice::GetDeviceName | ( |  | ) | const`[inline]`

Get the device name of the open device.

virtual PStringArray PVideoDevice::GetDeviceNames | ( |  | ) | const`[pure virtual]`

Get a list of all of the drivers available.

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.

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.

virtual int PVideoDevice::GetHue | ( |  | ) | `[virtual]`

Get the hue of the image.

0xffff-High hue. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

int PVideoDevice::GetLastError | ( |  | ) | const`[inline]`

Get the last error code.

This is a platform dependent number.

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.

PINDEX PVideoDevice::GetMaxFrameBytesConverted | ( | PINDEX | rawFrameBytes | ) | const`[protected]`

virtual int PVideoDevice::GetNumChannels | ( |  | ) | `[virtual]`

Get the number of video channels available on the device.

Default behaviour returns 1.

Reimplemented in PVideoInput1394DcDevice.

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.

const PString& PVideoDevice::GetPreferredColourFormat | ( |  | ) | `[inline]`

Get preferred native colour format from video capture device.

Returns empty == no preference

virtual PBoolean PVideoDevice::GetVFlipState | ( |  | ) | `[virtual]`

Get the video conversion vertical flip state.

Default action is to return false.

virtual VideoFormat PVideoDevice::GetVideoFormat | ( |  | ) | const`[virtual]`

Get the video format being used.

Default behaviour returns the value of the videoFormat variable.

virtual int PVideoDevice::GetWhiteness | ( |  | ) | `[virtual]`

Get the whiteness of the image.

0xffff-Very white. -1 is unknown.

Reimplemented in PVideoInput1394DcDevice.

virtual PBoolean PVideoDevice::IsOpen | ( |  | ) | `[pure virtual]`

Determine if the device is currently open.

Implemented in PVideoInput1394DcDevice.

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.

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

virtual PBoolean PVideoDevice::SetBrightness | ( | unsigned | newBrightness | ) | `[virtual]`

Set brightness of the image.

0xffff-Very bright.

Reimplemented in PVideoInput1394DcDevice.

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.

virtual PBoolean PVideoDevice::SetColour | ( | unsigned | newColour | ) | `[virtual]`

Set colour of the image.

0xffff-lots of colour.

Reimplemented in PVideoInput1394DcDevice.

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.

virtual PBoolean PVideoDevice::SetContrast | ( | unsigned | newContrast | ) | `[virtual]`

Set contrast of the image.

0xffff-High contrast.

Reimplemented in PVideoInput1394DcDevice.

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.

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.

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.

virtual PBoolean PVideoDevice::SetHue | ( | unsigned | newHue | ) | `[virtual]`

Set hue of the image.

0xffff-High hue.

Reimplemented in PVideoInput1394DcDevice.

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.

void PVideoDevice::SetPreferredColourFormat | ( | const PString & | colourFmt | ) | `[inline]`

Set preferred native colour format from video capture device.

Note empty == no preference.

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

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

Set VideoFormat and VideoChannel in one ioctl.

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

virtual PBoolean PVideoDevice::SetWhiteness | ( | unsigned | newWhiteness | ) | `[virtual]`

Set whiteness of the image.

0xffff-Very white.

Reimplemented in PVideoInput1394DcDevice.

virtual PBoolean PVideoDevice::Start | ( |  | ) | `[pure virtual]`

Start the video device I/O capture.

Implemented in PVideoOutputDevice, and PVideoInput1394DcDevice.

virtual PBoolean PVideoDevice::Stop | ( |  | ) | `[pure virtual]`

Stop the video device I/O capture.

Implemented in PVideoOutputDevice, and PVideoInput1394DcDevice.

## Member Data Documentation

int PVideoDevice::channelNumber `[protected]`

PColourConverter* PVideoDevice::converter `[protected]`

PString PVideoDevice::deviceName `[protected]`

int PVideoDevice::frameBrightness `[protected]`

int PVideoDevice::frameColour `[protected]`

int PVideoDevice::frameContrast `[protected]`

int PVideoDevice::frameHue `[protected]`

PBYTEArray PVideoDevice::frameStore `[protected]`

int PVideoDevice::frameWhiteness `[protected]`

int PVideoDevice::lastError `[protected]`

PBoolean PVideoDevice::nativeVerticalFlip `[protected]`

PString PVideoDevice::preferredColourFormat `[protected]`

VideoFormat PVideoDevice::videoFormat `[protected]`

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

- videoio.h