📄 videoio.h
字号:
/**Get video output devices that correspond to the specified driver name.
If driverName is an empty string or the value "*" then this will return
a list of unique device names across all of the available drivers. If
two drivers have identical names for devices, then the string returned
will be of the form driver+'\t'+device.
*/
static PStringList GetDriversDeviceNames(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create the video output device that corresponds to the specified driver name.
*/
static PVideoOutputDevice * CreateDevice(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/* Create the matching video output device that corresponds to the device name.
This is typically used with the return values from GetDriversDeviceNames().
*/
static PVideoOutputDevice *CreateDeviceByName(
const PString & deviceName, ///< Name of device
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create an opened video output device that corresponds to the specified names.
If the driverName parameter is an empty string or "*" then CreateDeviceByName
is used with the deviceName parameter which is assumed to be a value returned
from GetDriversDeviceNames().
*/
static PVideoOutputDevice *CreateOpenedDevice(
const PString & driverName, ///< Name of driver
const PString & deviceName, ///< Name of device
BOOL startImmediate = TRUE, ///< Immediately start display
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Close the device.
*/
virtual BOOL Close() { return TRUE; }
/**Start the video device I/O display.
*/
virtual BOOL Start() { return TRUE; }
/**Stop the video device I/O display.
*/
virtual BOOL Stop() { return TRUE; }
/** Is the device a camera, and obtain video
*/
virtual BOOL CanCaptureVideo() const;
/**Set a section of the output frame buffer.
*/
virtual BOOL SetFrameData(
unsigned x,
unsigned y,
unsigned width,
unsigned height,
const BYTE * data,
BOOL endFrame = TRUE
) = 0;
};
/**This class defines a video output device for RGB in a frame store.
*/
class PVideoOutputDeviceRGB : public PVideoOutputDevice
{
PCLASSINFO(PVideoOutputDeviceRGB, PVideoOutputDevice);
public:
/** Create a new video output device.
*/
PVideoOutputDeviceRGB();
/**Set the colour format to be used.
Note that this function does not do any conversion. If it returns TRUE
then the video device does the colour format in native mode.
To utilise an internal converter use the SetColourFormatConverter()
function.
Default behaviour sets the value of the colourFormat variable and then
returns TRUE.
*/
virtual BOOL SetColourFormat(
const PString & colourFormat // New colour format for device.
);
/**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.
*/
virtual BOOL SetFrameSize(
unsigned width, ///< New width of frame
unsigned height ///< New height of frame
);
/**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.
*/
virtual PINDEX GetMaxFrameBytes();
/**Set a section of the output frame buffer.
*/
virtual BOOL SetFrameData(
unsigned x,
unsigned y,
unsigned width,
unsigned height,
const BYTE * data,
BOOL endFrame = TRUE
);
/**Indicate frame may be displayed.
*/
virtual BOOL FrameComplete() = 0;
protected:
PMutex mutex;
PBYTEArray frameStore;
PINDEX bytesPerPixel;
PINDEX scanLineWidth;
bool swappedRedAndBlue;
};
#ifdef SHOULD_BE_MOVED_TO_PLUGIN
/**This class defines a video output device which outputs to a series of PPM files.
*/
class PVideoOutputDevicePPM : public PVideoOutputDeviceRGB
{
PCLASSINFO(PVideoOutputDevicePPM, PVideoOutputDeviceRGB);
public:
/** Create a new video output device.
*/
PVideoOutputDevicePPM();
/**Open the device given the device name.
*/
virtual BOOL Open(
const PString & deviceName, ///< Device name (filename base) to open
BOOL startImmediate = TRUE ///< Immediately start device
);
/**Determine if the device is currently open.
*/
virtual BOOL IsOpen();
/**Close the device.
*/
virtual BOOL Close();
/**Get a list of all of the drivers available.
*/
virtual PStringList GetDeviceNames() const;
/**Indicate frame may be displayed.
*/
virtual BOOL EndFrame();
protected:
unsigned frameNumber;
};
#endif // SHOULD_BE_MOVED_TO_PLUGIN
/**This class defines a video input device.
*/
class PVideoInputDevice : public PVideoDevice
{
PCLASSINFO(PVideoInputDevice, PVideoDevice);
public:
/** Create a new video input device.
*/
//PVideoInputDevice();
/**Close the video input device on destruction.
*/
~PVideoInputDevice() { Close(); }
/**Get the list of available video input drivers (plug-ins)
*/
static PStringList GetDriverNames(
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Get video input devices that correspond to the specified driver name.
If driverName is an empty string or the value "*" then this will return
a list of unique device names across all of the available drivers. If
two drivers have identical names for devices, then the string returned
will be of the form driver+'\t'+device.
*/
static PStringList GetDriversDeviceNames(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create the video input device that corresponds to the specified driver name.
*/
static PVideoInputDevice *CreateDevice(
const PString & driverName, ///< Name of driver
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/* Create the matching video input device that corresponds to the device name.
So, for "fake" return a device that will generate fake video.
For "Phillips 680 webcam" (eg) will return appropriate grabber.
Note that Phillips will return the appropriate grabber also.
This is typically used with the return values from GetDriversDeviceNames().
*/
static PVideoInputDevice *CreateDeviceByName(
const PString & deviceName, ///< Name of device
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Create an opened video input device that corresponds to the specified names.
If the driverName parameter is an empty string or "*" then CreateDeviceByName
is used with the deviceName parameter which is assumed to be a value returned
from GetDriversDeviceNames().
*/
static PVideoInputDevice *CreateOpenedDevice(
const PString & driverName, ///< Name of driver
const PString & deviceName, ///< Name of device
BOOL startImmediate = TRUE, ///< Immediately start grabbing
PPluginManager * pluginMgr = NULL ///< Plug in manager, use default if NULL
);
/**Open the device given the device name.
*/
virtual BOOL Open(
const PString & deviceName, ///< Device name to open
BOOL startImmediate = TRUE ///< Immediately start device
) = 0;
virtual BOOL Close(
) { return TRUE; }
/** Is the device a camera, and obtain video
*/
virtual BOOL CanCaptureVideo() const;
/**Determine if the video device I/O capture is in progress.
*/
virtual BOOL IsCapturing() = 0;
/**Grab a frame.
*/
virtual BOOL GetFrame(
PBYTEArray & frame
);
/**Grab a frame, after a delay as specified by the frame rate.
*/
virtual BOOL GetFrameData(
BYTE * buffer, ///< Buffer to receive frame
PINDEX * bytesReturned = NULL ///< OPtional bytes returned.
) = 0;
/**Grab a frame. Do not delay according to the current frame rate parameter.
*/
virtual BOOL GetFrameDataNoDelay(
BYTE * buffer, ///< Buffer to receive frame
PINDEX * bytesReturned = NULL ///< OPtional bytes returned.
) = 0;
/**Try all known video formats & see which ones are accepted by the video driver
*/
virtual BOOL TestAllFormats() = 0;
};
////////////////////////////////////////////////////////
//
// declare macros and structures needed for video input plugins
//
template <class className> class PVideoInputPluginServiceDescriptor : public PDevicePluginServiceDescriptor
{
public:
virtual PObject * CreateInstance(int /*userData*/) const { return new className; }
virtual PStringList GetDeviceNames(int /*userData*/) const { return className::GetInputDeviceNames(); }
};
#define PCREATE_VIDINPUT_PLUGIN(name) \
static PVideoInputPluginServiceDescriptor<PVideoInputDevice_##name> PVideoInputDevice_##name##_descriptor; \
PCREATE_PLUGIN(name, PVideoInputDevice, &PVideoInputDevice_##name##_descriptor)
////////////////////////////////////////////////////////
//
// declare macros and structures needed for video output plugins
//
template <class className> class PVideoOutputPluginServiceDescriptor : public PDevicePluginServiceDescriptor
{
public:
virtual PObject * CreateInstance(int /*userData*/) const { return new className; }
virtual PStringList GetDeviceNames(int /*userData*/) const { return className::GetOutputDeviceNames(); }
};
#define PCREATE_VIDOUTPUT_PLUGIN(name) \
static PVideoOutputPluginServiceDescriptor<PVideoOutputDevice_##name> PVideoOutputDevice_##name##_descriptor; \
PCREATE_PLUGIN(name, PVideoOutputDevice, &PVideoOutputDevice_##name##_descriptor)
#endif // _PVIDEOIO
// End Of File ///////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -