VideoCamera

class machinevisiontoolbox.Sources.VideoCamera(id=0, rgb=True, **kwargs)[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:
  • Robotics, Vision & Control for Python, Section 11.1.3, P. Corke, Springer 2023.

Seealso:

convert cv2.VideoCapture,

__init__(id=0, rgb=True, **kwargs)[source]

Methods

__init__

get

Get camera property

grab

Grab single frame from camera

release

Release the camera

set

Set camera property

Attributes

framerate

Camera frame rate

height

Height of video frame

properties

shape

Shape of video frame

width

Width of video frame