WebCam#

class WebCam(url: str, **kwargs: Any)[source]#

Iterate images from an internet web camera

Parameters:
  • url (str) – URL of the camera

  • kwargs – options applied to image frames, see convert

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

Example:

from machinevisiontoolbox import WebCam
webcam = WebCam('https://webcam.dartmouth.edu/webcam/image.jpg')
for image in webcam:  # iterate over frames
  # process image

alternatively:

img = next(webcam)  # get next frame

or using a context manager to ensure the connection is released:

with WebCam('https://webcam.dartmouth.edu/webcam/image.jpg') as webcam:
    for image in webcam:
        # process image

Note

Manu webcameras accept a query string in the URL to specify image resolution, image format, codec and other parameters. There is no common standard for this, see the manufacturer’s datasheet for details.

References:
Seealso:

convert cv2.VideoCapture

Methods

disp

Display images from the source interactively.

grab

Grab frame from web camera

tensor

Convert all images from this source into a single 4D PyTorch tensor.

Attributes