VideoCamera#

class VideoCamera(id: int = 0, rgb: bool = True, **kwargs: Any)[source]#

Iterate images from a local video camera

Parameters:
  • id (int) – Identity of local camera

  • kwargs – options applied to image frames, see convert

Connect to a local video camera. For some cameras this will cause the recording light to come on.

The resulting object is an iterator over the frames from the video camera. The iterator returns Image objects.

Example:

>>> from machinevisiontoolbox import VideoCamera
>>> video = VideoCamera(0)
>>> for im in video:
>>>   # process image

alternatively:

>>> img = video.grab()

Note

The value of id is system specific but generally 0 is the first attached video camera.

References:
Seealso:

convert cv2.VideoCapture,

Methods

get

Get camera property

grab

Grab single frame from camera

release

Release the camera

set

Set camera property

torch

Convert the entire collection into a single 4D PyTorch tensor.

Attributes

args

cap

framerate

Camera frame rate

height

Height of video frame

i

id

properties

rgb

shape

Shape of video frame

width

Width of video frame