Table of Contents

Class VideoCapture

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Video capturing class

public class VideoCapture : DisposableCvObject, IDisposable, ICvPtrHolder
Inheritance
VideoCapture
Implements
Inherited Members

Constructors

VideoCapture()

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

public VideoCapture()

VideoCapture(int, VideoCaptureAPIs)

Opens a camera for video capturing

public VideoCapture(int index, VideoCaptureAPIs apiPreference = VideoCaptureAPIs.ANY)

Parameters

index int

id of the video capturing device to open. To open default camera using default backend just pass 0. (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)

apiPreference VideoCaptureAPIs

preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.

VideoCapture(int, VideoCaptureAPIs, VideoCapturePara)

Opens a camera for video capturing with API Preference and parameters

public VideoCapture(int index, VideoCaptureAPIs apiPreference, VideoCapturePara prms)

Parameters

index int

id of the video capturing device to open. To open default camera using default backend just pass 0. (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)

apiPreference VideoCaptureAPIs

preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.

prms VideoCapturePara

Parameters of VideoCapture for hardware acceleration

VideoCapture(int, VideoCaptureAPIs, int[])

Opens a camera for video capturing with API Preference and parameters

public VideoCapture(int index, VideoCaptureAPIs apiPreference, int[] prms)

Parameters

index int

id of the video capturing device to open. To open default camera using default backend just pass 0. (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)

apiPreference VideoCaptureAPIs

preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.

prms int[]

The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties

VideoCapture(nint)

Initializes from native pointer

protected VideoCapture(nint ptr)

Parameters

ptr nint

CvCapture*

VideoCapture(string, VideoCaptureAPIs)

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

public VideoCapture(string fileName, VideoCaptureAPIs apiPreference = VideoCaptureAPIs.ANY)

Parameters

fileName string

it can be: - name of video file (e.g. video.avi) - or image sequence (e.g. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) - or URL of video stream (e.g. protocol://host:port/script_name?script_params|auth). Note that each video stream or IP camera feed has its own URL scheme. Please refer to the documentation of source stream to know the right URL.

apiPreference VideoCaptureAPIs

apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.

VideoCapture(string, VideoCaptureAPIs, VideoCapturePara)

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

public VideoCapture(string fileName, VideoCaptureAPIs apiPreference, VideoCapturePara prms)

Parameters

fileName string

it can be: - name of video file (e.g. video.avi) - or image sequence (e.g. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) - or URL of video stream (e.g. protocol://host:port/script_name?script_params|auth). Note that each video stream or IP camera feed has its own URL scheme. Please refer to the documentation of source stream to know the right URL.

apiPreference VideoCaptureAPIs

apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.

prms VideoCapturePara

Parameters of VideoCature for hardware acceleration

VideoCapture(string, VideoCaptureAPIs, int[])

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

public VideoCapture(string fileName, VideoCaptureAPIs apiPreference, int[] prms)

Parameters

fileName string

it can be: - name of video file (eg. video.avi) - or image sequence (eg. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) - or URL of video stream (eg. protocol://host:port/script_name?script_params|auth). Note that each video stream or IP camera feed has its own URL scheme. Please refer to the documentation of source stream to know the right URL.

apiPreference VideoCaptureAPIs

apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.

prms int[]

The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties

Properties

AutoExposure

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

public double AutoExposure { get; set; }

Property Value

double

AutoFocus

public bool AutoFocus { get; set; }

Property Value

bool

BackLight

public double BackLight { get; set; }

Property Value

double

Brightness

Gets or sets brightness of image (only for cameras)

public double Brightness { get; set; }

Property Value

double

BufferSize

public double BufferSize { get; set; }

Property Value

double

CaptureType

Gets the capture type (File or Camera)

public CaptureType CaptureType { get; }

Property Value

CaptureType

Contrast

Gets or sets contrast of image (only for cameras)

public double Contrast { get; set; }

Property Value

double

ConvertRgb

Boolean flags indicating whether images should be converted to RGB

public bool ConvertRgb { get; set; }

Property Value

bool

Exposure

Exposure (only for cameras)

public double Exposure { get; set; }

Property Value

double

Focus

public double Focus { get; set; }

Property Value

double

Format

The format of the Mat objects returned by retrieve()

public int Format { get; set; }

Property Value

int

FourCC

Gets or sets 4-character code of codec

public string FourCC { get; set; }

Property Value

string

Fps

Gets or sets frame rate

public double Fps { get; set; }

Property Value

double

FrameCount

Gets number of frames in video file

public int FrameCount { get; }

Property Value

int

FrameHeight

Gets or sets height of frames in the video stream

public int FrameHeight { get; set; }

Property Value

int

FrameWidth

Gets or sets width of frames in the video stream

public int FrameWidth { get; set; }

Property Value

int

GStreamerQueueLength

default is 1 [CV_CAP_GSTREAMER_QUEUE_LENGTH]

public double GStreamerQueueLength { get; set; }

Property Value

double

Gain

Gain of the image (only for cameras)

public double Gain { get; set; }

Property Value

double

Gamma

public double Gamma { get; set; }

Property Value

double

Guid

public double Guid { get; set; }

Property Value

double

Hue

Gets or sets hue of image (only for cameras)

public double Hue { get; set; }

Property Value

double

Iris

public double Iris { get; set; }

Property Value

double

IsoSpeed

public double IsoSpeed { get; set; }

Property Value

double

Mode

A backend-specific value indicating the current capture mode

public int Mode { get; set; }

Property Value

int

Monocrome

public double Monocrome { get; set; }

Property Value

double

OpenNI_Baseline

in mm [CV_CAP_PROP_OPENNI_BASELINE]

public double OpenNI_Baseline { get; set; }

Property Value

double

OpenNI_DepthGeneratorBaseline

[CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE]

public double OpenNI_DepthGeneratorBaseline { get; set; }

Property Value

double

OpenNI_DepthGeneratorFocalLength

[CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH]

public double OpenNI_DepthGeneratorFocalLength { get; set; }

Property Value

double

OpenNI_DepthGeneratorRegistrationON

[CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON]

public double OpenNI_DepthGeneratorRegistrationON { get; set; }

Property Value

double

OpenNI_FocalLength

in pixels [CV_CAP_PROP_OPENNI_FOCAL_LENGTH]

public double OpenNI_FocalLength { get; set; }

Property Value

double

OpenNI_FrameMaxDepth

in mm [CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH]

public double OpenNI_FrameMaxDepth { get; set; }

Property Value

double

OpenNI_ImageGeneratorOutputMode

[CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE]

public double OpenNI_ImageGeneratorOutputMode { get; set; }

Property Value

double

OpenNI_OutputMode

[CV_CAP_PROP_OPENNI_OUTPUT_MODE]

public double OpenNI_OutputMode { get; set; }

Property Value

double

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]

public double OpenNI_Registration { get; set; }

Property Value

double

Pan

public double Pan { get; set; }

Property Value

double

PosAviRatio

Gets or sets relative position of video file

public CapturePosAviRatio PosAviRatio { get; set; }

Property Value

CapturePosAviRatio

PosFrames

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

public int PosFrames { get; set; }

Property Value

int

PosMsec

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

public int PosMsec { get; set; }

Property Value

int

PvAPIMulticastIP

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

public double PvAPIMulticastIP { get; set; }

Property Value

double

Rectification

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

public double Rectification { get; set; }

Property Value

double

Roll

public double Roll { get; set; }

Property Value

double

Saturation

Gets or sets saturation of image (only for cameras)

public double Saturation { get; set; }

Property Value

double

Settings

public double Settings { get; set; }

Property Value

double

Sharpness

public double Sharpness { get; set; }

Property Value

double

Temperature

[CV_CAP_PROP_TEMPERATURE]

public double Temperature { get; set; }

Property Value

double

Tilt

public double Tilt { get; set; }

Property Value

double

Trigger

public double Trigger { get; set; }

Property Value

double

TriggerDelay

public double TriggerDelay { get; set; }

Property Value

double

WhiteBalanceBlueU

public double WhiteBalanceBlueU { get; set; }

Property Value

double

WhiteBalanceRedV

public double WhiteBalanceRedV { get; set; }

Property Value

double

XI_AEAG

Automatic exposure/gain [CV_CAP_PROP_XI_AEAG]

public double XI_AEAG { get; set; }

Property Value

double

XI_AEAGLevel

default is 1 [CV_CAP_PROP_XI_AEAG_LEVEL]

public double XI_AEAGLevel { get; set; }

Property Value

double

XI_AEMaxLimit

Maximum limit of exposure in AEAG procedure [CV_CAP_PROP_XI_AE_MAX_LIMIT]

public double XI_AEMaxLimit { get; set; }

Property Value

double

XI_AGMaxLimit

Maximum limit of gain in AEAG procedure [CV_CAP_PROP_XI_AG_MAX_LIMIT]

public double XI_AGMaxLimit { get; set; }

Property Value

double

XI_AutoWB

Automatic white balance [CV_CAP_PROP_XI_AUTO_WB]

public double XI_AutoWB { get; set; }

Property Value

double

XI_DataFormat

Output data format. [CV_CAP_PROP_XI_DATA_FORMAT]

public double XI_DataFormat { get; }

Property Value

double

XI_Downsampling

Change image resolution by binning or skipping.
[CV_CAP_PROP_XI_DOWNSAMPLING]

public double XI_Downsampling { get; set; }

Property Value

double

XI_ExpPriority

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

public double XI_ExpPriority { get; set; }

Property Value

double

XI_GpiLevel

Get general purpose level [CV_CAP_PROP_XI_GPI_LEVEL]

public double XI_GpiLevel { get; set; }

Property Value

double

XI_GpiMode

Set general purpose input mode [CV_CAP_PROP_XI_GPI_MODE]

public double XI_GpiMode { get; set; }

Property Value

double

XI_GpiSelector

Selects general purpose input [CV_CAP_PROP_XI_GPI_SELECTOR]

public double XI_GpiSelector { get; set; }

Property Value

double

XI_GpoMode

Set general purpose output mode [CV_CAP_PROP_XI_GPO_MODE]

public double XI_GpoMode { get; set; }

Property Value

double

XI_GpoSelector

Selects general purpose output [CV_CAP_PROP_XI_GPO_SELECTOR]

public double XI_GpoSelector { get; set; }

Property Value

double

XI_LedMode

Define camera signalling LED functionality [CV_CAP_PROP_XI_LED_MODE]

public double XI_LedMode { get; set; }

Property Value

double

XI_LedSelector

Selects camera signalling LED [CV_CAP_PROP_XI_LED_SELECTOR]

public double XI_LedSelector { get; set; }

Property Value

double

XI_ManualWB

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

public double XI_ManualWB { get; set; }

Property Value

double

XI_OffsetX

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

public double XI_OffsetX { get; set; }

Property Value

double

XI_OffsetY

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

public double XI_OffsetY { get; set; }

Property Value

double

XI_Timeout

default is 1 [CV_CAP_PROP_XI_TIMEOUT]

public double XI_Timeout { get; set; }

Property Value

double

XI_TrgSoftware

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

public double XI_TrgSoftware { get; set; }

Property Value

double

XI_TrgSource

Defines source of trigger. [CV_CAP_PROP_XI_TRG_SOURCE]

public double XI_TrgSource { get; set; }

Property Value

double

Zoom

public double Zoom { get; set; }

Property Value

double

Methods

DisposeUnmanaged()

Releases unmanaged resources

protected override void DisposeUnmanaged()

FromCamera(int, VideoCaptureAPIs)

Opens a camera for video capturing

public static VideoCapture FromCamera(int index, VideoCaptureAPIs apiPreference = VideoCaptureAPIs.ANY)

Parameters

index int

id of the video capturing device to open. To open default camera using default backend just pass 0. (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)

apiPreference VideoCaptureAPIs

preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.

Returns

VideoCapture

FromFile(string, VideoCaptureAPIs)

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

public static VideoCapture FromFile(string fileName, VideoCaptureAPIs apiPreference = VideoCaptureAPIs.ANY)

Parameters

fileName string

it can be: - name of video file (e.g. video.avi) - or image sequence (e.g. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) - or URL of video stream (e.g. protocol://host:port/script_name?script_params|auth). Note that each video stream or IP camera feed has its own URL scheme. Please refer to the documentation of source stream to know the right URL.

apiPreference VideoCaptureAPIs

apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.

Returns

VideoCapture

Get(VideoCaptureProperties)

Returns the specified VideoCapture property

public double Get(VideoCaptureProperties propertyId)

Parameters

propertyId VideoCaptureProperties

Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) or one from @ref videoio_flags_others

Returns

double

Value for the specified property. Value 0 is returned when querying a property that is not supported by the backend used by the VideoCapture instance.

Get(int)

Returns the specified VideoCapture property

public double Get(int propertyId)

Parameters

propertyId int

Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) or one from @ref videoio_flags_others

Returns

double

Value for the specified property. Value 0 is returned when querying a property that is not supported by the backend used by the VideoCapture instance.

GetBackendName()

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

public string GetBackendName()

Returns

string

GetExceptionMode()

query if exception mode is active

public bool GetExceptionMode()

Returns

bool

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.

public bool Grab()

Returns

bool

true (non-zero) in the case of success.

IsOpened()

Returns true if video capturing has been initialized already.

public bool IsOpened()

Returns

bool

Open(int, VideoCaptureAPIs)

Opens a camera for video capturing

public bool Open(int index, VideoCaptureAPIs apiPreference = VideoCaptureAPIs.ANY)

Parameters

index int

id of the video capturing device to open. To open default camera using default backend just pass 0. (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)

apiPreference VideoCaptureAPIs

preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.

Returns

bool

true if the file has been successfully opened

Open(string, VideoCaptureAPIs)

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

public bool Open(string fileName, VideoCaptureAPIs apiPreference = VideoCaptureAPIs.ANY)

Parameters

fileName string

it can be: - name of video file (eg. video.avi) - or image sequence (eg. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) - or URL of video stream (eg. protocol://host:port/script_name?script_params|auth). Note that each video stream or IP camera feed has its own URL scheme. Please refer to the documentation of source stream to know the right URL.

apiPreference VideoCaptureAPIs

apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.

Returns

bool

true if the file has been successfully opened

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()).

public bool Read(Mat image)

Parameters

image Mat

Returns

bool

false if no frames has been grabbed

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()).

public bool Read(OutputArray image)

Parameters

image OutputArray

Returns

bool

false if no frames has been grabbed

Release()

Closes video file or capturing device.

public void Release()

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()).

public bool Retrieve(Mat image, CameraChannels streamIdx)

Parameters

image Mat

the video frame is returned here. If no frames has been grabbed the image will be empty.

streamIdx CameraChannels

non-zero streamIdx is only valid for multi-head camera live streams

Returns

bool

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()).

public bool Retrieve(Mat image, int flag = 0)

Parameters

image Mat

the video frame is returned here. If no frames has been grabbed the image will be empty.

flag int

it could be a frame index or a driver specific flag

Returns

bool

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()).

public bool Retrieve(OutputArray image, CameraChannels streamIdx)

Parameters

image OutputArray

the video frame is returned here. If no frames has been grabbed the image will be empty.

streamIdx CameraChannels

non-zero streamIdx is only valid for multi-head camera live streams

Returns

bool

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()).

public bool Retrieve(OutputArray image, int flag = 0)

Parameters

image OutputArray

the video frame is returned here. If no frames has been grabbed the image will be empty.

flag int

it could be a frame index or a driver specific flag

Returns

bool

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()).

public Mat RetrieveMat()

Returns

Mat

the video frame is returned here. If no frames has been grabbed the image will be empty.

Set(VideoCaptureProperties, double)

Sets a property in the VideoCapture.

public bool Set(VideoCaptureProperties propertyId, double value)

Parameters

propertyId VideoCaptureProperties

Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) or one from @ref videoio_flags_others

value double

Value of the property.

Returns

bool

true if the property is supported by backend used by the VideoCapture instance.

Set(int, double)

Sets a property in the VideoCapture.

public bool Set(int propertyId, double value)

Parameters

propertyId int

Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) or one from @ref videoio_flags_others

value double

Value of the property.

Returns

bool

true if the property is supported by backend used by the VideoCapture instance.

SetExceptionMode(bool)

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

public void SetExceptionMode(bool enable)

Parameters

enable bool

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.

public static bool WaitAny(IEnumerable<VideoCapture> streams, out int[] readyIndex, long timeoutNs = 0)

Parameters

streams IEnumerable<VideoCapture>

input video streams

readyIndex int[]

stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame)

timeoutNs long

number of nanoseconds (0 - infinite)

Returns

bool

`true if streamReady is not empty

Exceptions

OpenCVException

Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported