P2DingoCV.Camera.VideoCamera

Classes

VideoCamera([source])

Camera subclass that reads frames from a webcam, camera device, or video file.

class P2DingoCV.Camera.VideoCamera.VideoCamera(source=0)[source]

Bases: P2DingoCV.Camera.Camera.Camera

Camera subclass that reads frames from a webcam, camera device, or video file.

Parameters:

source (int | str)

cap

OpenCV video capture object.

Type:

cv.VideoCapture

frame

Last frame read from the camera.

Type:

np.ndarray | None

source

Device index or video file path.

Type:

int | str

Camera subclass that reads frames from a webcam, camera device, or video file.

__init__(source=0)[source]

Initialize the VideoCamera with a device index or video file path.

Parameters:

source (int | str) – Camera device index or path to a video file.

Raises:

ValueError – If the video source cannot be opened.

Return type:

None

read()[source]

Read the next frame from the video source.

Returns:

The next frame, or None if the video has ended.

Return type:

np.ndarray | None

release()[source]

Release video capture resources.

Return type:

None

testRead()[source]

Read frames in a loop for testing. Loops back to the start if the video ends.

Returns:

The next frame, or None if no frame is available.

Return type:

np.ndarray | None