WebCam#
- class WebCam(url: str, **kwargs: Any)[source][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
Imageobjects.Example:
from machinevisiontoolbox import WebCam webcam = WebCam('https://webcam.dartmouth.edu/webcam/image.jpg') for image in webcam: # iterate over frames pass
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: pass
Note
Many 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.
Note
The
urlis passed tocv2.VideoCapture, so it can be anything that OpenCV can open, for example a still-image URL, a live HTTP (MJPEG) stream or an RTSP stream. A phone can be used as a networked camera in this way: many IP-camera apps for iOS and Android publish a live stream at a URL. Which stream types and URL formats are supported depends on the app and on how your OpenCV was built. On a Mac with an iPhone, Continuity Camera makes the phone appear as a local camera instead, seeVideoCamera.- References:
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 11.1.5.
- Seealso:
Base constructor for image sources.
- Parameters:
kwargs (Any) – source-specific keyword arguments