Table of Contents

Class VideoCapture

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Video capturing class

public class VideoCapture : CvObject, IDisposable
Inheritance
VideoCapture
Implements
Inherited Members

Constructors

VideoCapture()

Initializes empty capture. To use this, you should call Open.

VideoCapture(IStreamReader, VideoCaptureAPIs, VideoCapturePara)

Opens a video using a custom data stream.

VideoCapture(IStreamReader, VideoCaptureAPIs, int[])

Opens a video using a custom data stream.

VideoCapture(Stream, VideoCaptureAPIs, VideoCapturePara)

Opens a video using an in-memory or otherwise custom Stream (e.g. a MemoryStream or network stream). The caller remains responsible for disposing the stream; VideoCapture does not take ownership of it.

VideoCapture(Stream, VideoCaptureAPIs, int[])

Opens a video using an in-memory or otherwise custom Stream (e.g. a MemoryStream or network stream). The caller remains responsible for disposing the stream; VideoCapture does not take ownership of it.

VideoCapture(int, VideoCaptureAPIs)

Opens a camera for video capturing

VideoCapture(int, VideoCaptureAPIs, VideoCapturePara)

Opens a camera for video capturing with API Preference and parameters

VideoCapture(int, VideoCaptureAPIs, int[])

Opens a camera for video capturing with API Preference and parameters

VideoCapture(nint)

Initializes from native pointer

VideoCapture(string, VideoCaptureAPIs)

Opens a video file or a capturing device or an IP video stream for video capturing with API Preference

VideoCapture(string, VideoCaptureAPIs, VideoCapturePara)

Opens a video file or a capturing device or an IP video stream for video capturing with API Preference

VideoCapture(string, VideoCaptureAPIs, int[])

Opens a video file or a capturing device or an IP video stream for video capturing with API Preference

Properties

AutoExposure

exposure control done by camera, user can adjust refernce level using this feature [CV_CAP_PROP_AUTO_EXPOSURE]

AutoFocus
BackLight
Brightness

Gets or sets brightness of image (only for cameras)

BufferSize
CaptureType

Gets the capture type (File or Camera)

Contrast

Gets or sets contrast of image (only for cameras)

ConvertRgb

Boolean flags indicating whether images should be converted to RGB

Exposure

Exposure (only for cameras)

Focus
Format

The format of the Mat objects returned by retrieve()

FourCC

Gets or sets 4-character code of codec

Fps

Gets or sets frame rate

FrameCount

Gets number of frames in video file

FrameHeight

Gets or sets height of frames in the video stream

FrameWidth

Gets or sets width of frames in the video stream

GStreamerQueueLength

default is 1 [CV_CAP_GSTREAMER_QUEUE_LENGTH]

Gain

Gain of the image (only for cameras)

Gamma
Guid
Hue

Gets or sets hue of image (only for cameras)

Iris
IsoSpeed
Mode

A backend-specific value indicating the current capture mode

Monocrome
OpenNI_Baseline

in mm [CV_CAP_PROP_OPENNI_BASELINE]

OpenNI_DepthGeneratorBaseline

[CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE]

OpenNI_DepthGeneratorFocalLength

[CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH]

OpenNI_DepthGeneratorRegistrationON

[CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON]

OpenNI_FocalLength

in pixels [CV_CAP_PROP_OPENNI_FOCAL_LENGTH]

OpenNI_FrameMaxDepth

in mm [CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH]

OpenNI_ImageGeneratorOutputMode

[CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE]

OpenNI_OutputMode

[CV_CAP_PROP_OPENNI_OUTPUT_MODE]

OpenNI_Registration

flag that synchronizes the remapping depth map to image map by changing depth generator's view point (if the flag is "on") or sets this view point to its normal one (if the flag is "off"). [CV_CAP_PROP_OPENNI_REGISTRATION]

Pan
PosAviRatio

Gets or sets relative position of video file

PosFrames

Gets or sets 0-based index of the frame to be decoded/captured next

PosMsec

Gets or sets film current position in milliseconds or video capture timestamp

PvAPIMulticastIP

ip for anable multicast master mode. 0 for disable multicast [CV_CAP_PROP_PVAPI_MULTICASTIP]

Rectification

TOWRITE (note: only supported by DC1394 v 2.x backend currently)

Roll
Saturation

Gets or sets saturation of image (only for cameras)

Settings
Sharpness
Temperature

[CV_CAP_PROP_TEMPERATURE]

Tilt
Trigger
TriggerDelay
WhiteBalanceBlueU
WhiteBalanceRedV
XI_AEAG

Automatic exposure/gain [CV_CAP_PROP_XI_AEAG]

XI_AEAGLevel

default is 1 [CV_CAP_PROP_XI_AEAG_LEVEL]

XI_AEMaxLimit

Maximum limit of exposure in AEAG procedure [CV_CAP_PROP_XI_AE_MAX_LIMIT]

XI_AGMaxLimit

Maximum limit of gain in AEAG procedure [CV_CAP_PROP_XI_AG_MAX_LIMIT]

XI_AutoWB

Automatic white balance [CV_CAP_PROP_XI_AUTO_WB]

XI_DataFormat

Output data format. [CV_CAP_PROP_XI_DATA_FORMAT]

XI_Downsampling

Change image resolution by binning or skipping.
[CV_CAP_PROP_XI_DOWNSAMPLING]

XI_ExpPriority

Exposure priority (0.5 - exposure 50%, gain 50%). [CV_CAP_PROP_XI_EXP_PRIORITY]

XI_GpiLevel

Get general purpose level [CV_CAP_PROP_XI_GPI_LEVEL]

XI_GpiMode

Set general purpose input mode [CV_CAP_PROP_XI_GPI_MODE]

XI_GpiSelector

Selects general purpose input [CV_CAP_PROP_XI_GPI_SELECTOR]

XI_GpoMode

Set general purpose output mode [CV_CAP_PROP_XI_GPO_MODE]

XI_GpoSelector

Selects general purpose output [CV_CAP_PROP_XI_GPO_SELECTOR]

XI_LedMode

Define camera signalling LED functionality [CV_CAP_PROP_XI_LED_MODE]

XI_LedSelector

Selects camera signalling LED [CV_CAP_PROP_XI_LED_SELECTOR]

XI_ManualWB

Calculates White Balance(must be called during acquisition) [CV_CAP_PROP_XI_MANUAL_WB]

XI_OffsetX

Horizontal offset from the origin to the area of interest (in pixels). [CV_CAP_PROP_XI_OFFSET_X]

XI_OffsetY

Vertical offset from the origin to the area of interest (in pixels). [CV_CAP_PROP_XI_OFFSET_Y]

XI_Timeout

default is 1 [CV_CAP_PROP_XI_TIMEOUT]

XI_TrgSoftware

Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. [CV_CAP_PROP_XI_TRG_SOFTWARE]

XI_TrgSource

Defines source of trigger. [CV_CAP_PROP_XI_TRG_SOURCE]

Zoom

Methods

FromCamera(int, VideoCaptureAPIs)

Opens a camera for video capturing

FromFile(string, VideoCaptureAPIs)

Opens a video file or a capturing device or an IP video stream for video capturing with API Preference

Get(VideoCaptureProperties)

Returns the specified VideoCapture property

Get(int)

Returns the specified VideoCapture property

GetBackendName()

Returns used backend API name. Note that stream should be opened.

GetExceptionMode()

query if exception mode is active

Grab()

Grabs the next frame from video file or capturing device.

The method/function grabs the next frame from video file or camera and returns true (non-zero) in the case of success.

The primary use of the function is in multi-camera environments, especially when the cameras do not have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames from different cameras will be closer in time.

Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the correct way of retrieving data from it is to call VideoCapture::grab() first and then call VideoCapture::retrieve() one or more times with different values of the channel parameter.

IsOpened()

Returns true if video capturing has been initialized already.

Open(IStreamReader, VideoCaptureAPIs, VideoCapturePara)

Opens a video using a custom data stream.

Open(IStreamReader, VideoCaptureAPIs, int[])

Opens a video using a custom data stream.

Open(Stream, VideoCaptureAPIs, VideoCapturePara)

Opens a video using an in-memory or otherwise custom Stream (e.g. a MemoryStream or network stream). The caller remains responsible for disposing the stream; VideoCapture does not take ownership of it.

Open(Stream, VideoCaptureAPIs, int[])

Opens a video using an in-memory or otherwise custom Stream (e.g. a MemoryStream or network stream). The caller remains responsible for disposing the stream; VideoCapture does not take ownership of it.

Open(int, VideoCaptureAPIs)

Opens a camera for video capturing

Open(string, VideoCaptureAPIs)

Opens a video file or a capturing device or an IP video stream for video capturing.

Open(string, VideoCaptureAPIs, VideoCapturePara)

Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters

Open(string, VideoCaptureAPIs, int[])

Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters

Read(Mat)

Grabs, decodes and returns the next video frame.

The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the most convenient method for reading video files or capturing data from decode and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).

Read(OutputArray)

Grabs, decodes and returns the next video frame.

The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the most convenient method for reading video files or capturing data from decode and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).

Release()

Closes video file or capturing device.

Retrieve(Mat, CameraChannels)

Decodes and returns the grabbed video frame.

The method decodes and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).

Retrieve(Mat, int)

Decodes and returns the grabbed video frame.

The method decodes and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).

Retrieve(OutputArray, CameraChannels)

Decodes and returns the grabbed video frame.

The method decodes and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).

Retrieve(OutputArray, int)

Decodes and returns the grabbed video frame.

The method decodes and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).

RetrieveMat()

Decodes and returns the grabbed video frame.

The method decodes and returns the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the method returns false and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).

Set(VideoCaptureProperties, double)

Sets a property in the VideoCapture.

Set(int, double)

Sets a property in the VideoCapture.

SetExceptionMode(bool)

Switches exceptions mode. methods raise exceptions if not successful instead of returning an error code

WaitAny(IEnumerable<VideoCapture>, out int[], long)

Wait for ready frames from VideoCapture.

The primary use of the function is in multi-camera environments. The method fills the ready state vector, grabs video frame, if camera is ready.

After this call use VideoCapture::retrieve() to decode and fetch frame data.