View Source Evision.VideoCapture (Evision v0.2.9)

Summary

Types

t()

Type that represents an Evision.VideoCapture struct.

Functions

Returns the specified VideoCapture property

Returns used backend API name

getExceptionMode

Grabs the next frame from video file or capturing device.

Returns true if video capturing has been initialized already.

Variant 1:

Opens a camera for video capturing

Variant 1:

Opens a camera for video capturing

Variant 1:

Opens a camera for video capturing with API Preference and parameters

Grabs, decodes and returns the next video frame.

Grabs, decodes and returns the next video frame.

Closes video file or capturing device.

Decodes and returns the grabbed video frame.

Decodes and returns the grabbed video frame.

Sets a property in the VideoCapture.

Default constructor

Variant 1:

Opens a camera for video capturing

Variant 1:

Opens a camera for video capturing

Variant 1:

Opens a camera for video capturing with API Preference and parameters

Wait for ready frames from VideoCapture.

Wait for ready frames from VideoCapture.

Types

@type t() :: %Evision.VideoCapture{
  fps: number(),
  frame_count: number(),
  frame_height: number(),
  frame_width: number(),
  isOpened: boolean(),
  ref: reference()
}

Type that represents an Evision.VideoCapture struct.

  • fps. double.

    Frames per second.

  • frame_count. double.

    Total number of frames.

  • frame_width. double.

    Width of each frame.

  • frame_height. double.

    Height of each frame.

  • isOpened. boolean.

    Is successfully opened the video source.

  • ref. reference.

    The underlying erlang resource variable.

Functions

@spec get(Keyword.t()) :: any() | {:error, String.t()}
@spec get(t(), integer()) :: number() | {:error, String.t()}

Returns the specified VideoCapture property

Positional Arguments
  • self: Evision.VideoCapture.t()

  • propId: integer().

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

Return
  • retval: double

@return 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. Note: Reading / writing properties involves many layers. Some unexpected result might happens along this chain.

VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware

The returned value might be different from what really used by the device or it could be encoded using device dependent rules (eg. steps or percentage). Effective behaviour depends from device driver and API Backend

Python prototype (for reference only):

get(propId) -> retval
Link to this function

getBackendName(named_args)

View Source
@spec getBackendName(Keyword.t()) :: any() | {:error, String.t()}
@spec getBackendName(t()) :: binary() | {:error, String.t()}

Returns used backend API name

Positional Arguments
  • self: Evision.VideoCapture.t()
Return

Note: Stream should be opened.

Python prototype (for reference only):

getBackendName() -> retval
Link to this function

getExceptionMode(named_args)

View Source
@spec getExceptionMode(Keyword.t()) :: any() | {:error, String.t()}
@spec getExceptionMode(t()) :: boolean() | {:error, String.t()}

getExceptionMode

Positional Arguments
  • self: Evision.VideoCapture.t()
Return
  • retval: bool

Python prototype (for reference only):

getExceptionMode() -> retval
@spec grab(Keyword.t()) :: any() | {:error, String.t()}
@spec grab(t()) :: boolean() | {:error, String.t()}

Grabs the next frame from video file or capturing device.

Positional Arguments
  • self: Evision.VideoCapture.t()
Return
  • retval: bool

@return true (non-zero) in the case of success. 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. @ref tutorial_kinect_openni

Python prototype (for reference only):

grab() -> retval
@spec isOpened(Keyword.t()) :: any() | {:error, String.t()}
@spec isOpened(t()) :: boolean() | {:error, String.t()}

Returns true if video capturing has been initialized already.

Positional Arguments
  • self: Evision.VideoCapture.t()
Return
  • retval: bool

If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns true.

Python prototype (for reference only):

isOpened() -> retval
@spec open(Keyword.t()) :: any() | {:error, String.t()}
@spec open(t(), integer()) :: boolean() | {:error, String.t()}
@spec open(t(), binary()) :: boolean() | {:error, String.t()}

Variant 1:

Opens a camera for video capturing

Positional Arguments
  • self: Evision.VideoCapture.t()
  • index: integer()
Keyword Arguments
  • apiPreference: integer().
Return
  • retval: bool

Has overloading in C++

Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY) @return true if the camera has been successfully opened. The method first calls VideoCapture::release to close the already opened file or camera.

Python prototype (for reference only):

open(index[, apiPreference]) -> retval

Variant 2:

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

Positional Arguments
  • self: Evision.VideoCapture.t()
  • filename: String
Keyword Arguments
  • apiPreference: integer().
Return
  • retval: bool

Has overloading in C++

Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) @return true if the file has been successfully opened The method first calls VideoCapture::release to close the already opened file or camera.

Python prototype (for reference only):

open(filename[, apiPreference]) -> retval
@spec open(t(), integer(), [{:apiPreference, term()}] | nil) ::
  boolean() | {:error, String.t()}
@spec open(t(), binary(), [{:apiPreference, term()}] | nil) ::
  boolean() | {:error, String.t()}

Variant 1:

Opens a camera for video capturing

Positional Arguments
  • self: Evision.VideoCapture.t()
  • index: integer()
Keyword Arguments
  • apiPreference: integer().
Return
  • retval: bool

Has overloading in C++

Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY) @return true if the camera has been successfully opened. The method first calls VideoCapture::release to close the already opened file or camera.

Python prototype (for reference only):

open(index[, apiPreference]) -> retval

Variant 2:

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

Positional Arguments
  • self: Evision.VideoCapture.t()
  • filename: String
Keyword Arguments
  • apiPreference: integer().
Return
  • retval: bool

Has overloading in C++

Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) @return true if the file has been successfully opened The method first calls VideoCapture::release to close the already opened file or camera.

Python prototype (for reference only):

open(filename[, apiPreference]) -> retval
Link to this function

open(self, index, apiPreference, params)

View Source
@spec open(t(), integer(), integer(), [integer()]) :: boolean() | {:error, String.t()}
@spec open(t(), binary(), integer(), [integer()]) :: boolean() | {:error, String.t()}

Variant 1:

Opens a camera for video capturing with API Preference and parameters

Positional Arguments
  • self: Evision.VideoCapture.t()
  • index: integer()
  • apiPreference: integer()
  • params: [integer()]
Return
  • retval: bool

Has overloading in C++

The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties @return true if the camera has been successfully opened. The method first calls VideoCapture::release to close the already opened file or camera.

Python prototype (for reference only):

open(index, apiPreference, params) -> retval

Variant 2:

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

Positional Arguments
  • self: Evision.VideoCapture.t()
  • filename: String
  • apiPreference: integer()
  • params: [integer()]
Return
  • retval: bool

Has overloading in C++

The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties @return true if the file has been successfully opened The method first calls VideoCapture::release to close the already opened file or camera.

Python prototype (for reference only):

open(filename, apiPreference, params) -> retval
@spec read(Keyword.t()) :: any() | {:error, String.t()}
@spec read(t()) :: Evision.Mat.t() | false | {:error, String.t()}

Grabs, decodes and returns the next video frame.

Positional Arguments
  • self: Evision.VideoCapture.t()
Return
  • retval: bool
  • image: Evision.Mat.t().

@return false if no frames has been grabbed 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()). Note: In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video capturing structure. It is not allowed to modify or release the image! You can copy the frame using cvCloneImage and then do whatever you want with the copy.

Python prototype (for reference only):

read([, image]) -> retval, image
@spec read(t(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | false | {:error, String.t()}

Grabs, decodes and returns the next video frame.

Positional Arguments
  • self: Evision.VideoCapture.t()
Return
  • retval: bool
  • image: Evision.Mat.t().

@return false if no frames has been grabbed 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()). Note: In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video capturing structure. It is not allowed to modify or release the image! You can copy the frame using cvCloneImage and then do whatever you want with the copy.

Python prototype (for reference only):

read([, image]) -> retval, image
@spec release(Keyword.t()) :: any() | {:error, String.t()}
@spec release(t()) :: t() | {:error, String.t()}

Closes video file or capturing device.

Positional Arguments
  • self: Evision.VideoCapture.t()

The method is automatically called by subsequent VideoCapture::open and by VideoCapture destructor. The C function also deallocates memory and clears *capture pointer.

Python prototype (for reference only):

release() -> None
@spec retrieve(Keyword.t()) :: any() | {:error, String.t()}
@spec retrieve(t()) :: Evision.Mat.t() | false | {:error, String.t()}

Decodes and returns the grabbed video frame.

Positional Arguments
  • self: Evision.VideoCapture.t()
Keyword Arguments
  • flag: integer().

    it could be a frame index or a driver specific flag

Return
  • retval: bool
  • image: Evision.Mat.t().

@return false if no frames has been grabbed 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()). @sa read() Note: In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video capturing structure. It is not allowed to modify or release the image! You can copy the frame using cvCloneImage and then do whatever you want with the copy.

Python prototype (for reference only):

retrieve([, image[, flag]]) -> retval, image
@spec retrieve(t(), [{:flag, term()}] | nil) ::
  Evision.Mat.t() | false | {:error, String.t()}

Decodes and returns the grabbed video frame.

Positional Arguments
  • self: Evision.VideoCapture.t()
Keyword Arguments
  • flag: integer().

    it could be a frame index or a driver specific flag

Return
  • retval: bool
  • image: Evision.Mat.t().

@return false if no frames has been grabbed 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()). @sa read() Note: In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video capturing structure. It is not allowed to modify or release the image! You can copy the frame using cvCloneImage and then do whatever you want with the copy.

Python prototype (for reference only):

retrieve([, image[, flag]]) -> retval, image
@spec set(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

set(self, propId, value)

View Source
@spec set(t(), integer(), number()) :: boolean() | {:error, String.t()}

Sets a property in the VideoCapture.

Positional Arguments
  • self: Evision.VideoCapture.t()

  • propId: integer().

    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.

Return
  • retval: bool

@return true if the property is supported by backend used by the VideoCapture instance. Note: Even if it returns true this doesn't ensure that the property value has been accepted by the capture device. See note in VideoCapture::get()

Python prototype (for reference only):

set(propId, value) -> retval
Link to this function

setExceptionMode(named_args)

View Source
@spec setExceptionMode(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setExceptionMode(self, enable)

View Source
@spec setExceptionMode(t(), boolean()) :: t() | {:error, String.t()}

setExceptionMode

Positional Arguments
  • self: Evision.VideoCapture.t()
  • enable: bool

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

Python prototype (for reference only):

setExceptionMode(enable) -> None
@spec videoCapture() :: t() | {:error, String.t()}

Default constructor

Return
  • self: Evision.VideoCapture.t()

Note: In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with cvReleaseCapture(), or use Ptr\<CvCapture> that calls cvReleaseCapture() automatically in the destructor.

Python prototype (for reference only):

VideoCapture() -> <VideoCapture object>
Link to this function

videoCapture(named_args)

View Source
@spec videoCapture(Keyword.t()) :: any() | {:error, String.t()}
@spec videoCapture(integer()) :: t() | {:error, String.t()}
@spec videoCapture(binary()) :: t() | {:error, String.t()}

Variant 1:

Opens a camera for video capturing

Positional Arguments
  • index: integer().

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

Keyword Arguments
  • apiPreference: integer().

    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.

Return
  • self: Evision.VideoCapture.t()

Has overloading in C++

@sa cv::VideoCaptureAPIs

Python prototype (for reference only):

VideoCapture(index[, apiPreference]) -> <VideoCapture object>

Variant 2:

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

Positional Arguments
  • 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)
    • or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend 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.
Keyword Arguments
  • apiPreference: integer().

    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.

Return
  • self: Evision.VideoCapture.t()

Has overloading in C++

@sa cv::VideoCaptureAPIs

Python prototype (for reference only):

VideoCapture(filename[, apiPreference]) -> <VideoCapture object>
Link to this function

videoCapture(index, opts)

View Source
@spec videoCapture(integer(), [{:apiPreference, term()}] | nil) ::
  t() | {:error, String.t()}
@spec videoCapture(binary(), [{:apiPreference, term()}] | nil) ::
  t() | {:error, String.t()}

Variant 1:

Opens a camera for video capturing

Positional Arguments
  • index: integer().

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

Keyword Arguments
  • apiPreference: integer().

    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.

Return
  • self: Evision.VideoCapture.t()

Has overloading in C++

@sa cv::VideoCaptureAPIs

Python prototype (for reference only):

VideoCapture(index[, apiPreference]) -> <VideoCapture object>

Variant 2:

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

Positional Arguments
  • 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)
    • or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend 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.
Keyword Arguments
  • apiPreference: integer().

    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.

Return
  • self: Evision.VideoCapture.t()

Has overloading in C++

@sa cv::VideoCaptureAPIs

Python prototype (for reference only):

VideoCapture(filename[, apiPreference]) -> <VideoCapture object>
Link to this function

videoCapture(index, apiPreference, params)

View Source
@spec videoCapture(integer(), integer(), [integer()]) :: t() | {:error, String.t()}
@spec videoCapture(binary(), integer(), [integer()]) :: t() | {:error, String.t()}

Variant 1:

Opens a camera for video capturing with API Preference and parameters

Positional Arguments
  • index: integer()
  • apiPreference: integer()
  • params: [integer()]
Return
  • self: Evision.VideoCapture.t()

Has overloading in C++

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

Python prototype (for reference only):

VideoCapture(index, apiPreference, params) -> <VideoCapture object>

Variant 2:

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

Positional Arguments
  • filename: String
  • apiPreference: integer()
  • params: [integer()]
Return
  • self: Evision.VideoCapture.t()

Has overloading in C++

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

Python prototype (for reference only):

VideoCapture(filename, apiPreference, params) -> <VideoCapture object>
@spec waitAny([t()]) :: [integer()] | false | {:error, String.t()}

Wait for ready frames from VideoCapture.

Positional Arguments
  • streams: [Evision.VideoCapture].

    input video streams

Keyword Arguments
  • timeoutNs: int64.

    number of nanoseconds (0 - infinite)

Return
  • retval: bool

  • readyIndex: [int].

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

@return true if streamReady is not empty @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported 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.

Python prototype (for reference only):

waitAny(streams[, timeoutNs]) -> retval, readyIndex
@spec waitAny([t()], [{:timeoutNs, term()}] | nil) ::
  [integer()] | false | {:error, String.t()}

Wait for ready frames from VideoCapture.

Positional Arguments
  • streams: [Evision.VideoCapture].

    input video streams

Keyword Arguments
  • timeoutNs: int64.

    number of nanoseconds (0 - infinite)

Return
  • retval: bool

  • readyIndex: [int].

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

@return true if streamReady is not empty @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported 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.

Python prototype (for reference only):

waitAny(streams[, timeoutNs]) -> retval, readyIndex