Skip to main content
Camera parts capture image data from various camera hardware including Raspberry Pi cameras, webcams, CSI cameras, and mock cameras for testing.

Base Classes

BaseCamera

Base class for all camera implementations. Methods:
() -> np.ndarray
Returns the most recently captured frame

Camera Implementations

PiCamera

Raspberry Pi camera using the Picamera2 library (Bullseye and later). Constructor:
int
default:"160"
Image width in pixels
int
default:"120"
Image height in pixels
int
default:"3"
Image depth/channels (3 for RGB, 1 for grayscale)
bool
default:"false"
Flip image vertically
bool
default:"false"
Flip image horizontally
Methods:
() -> np.ndarray
Captures and returns a new frame from the camera buffer
() -> None
Continuously captures frames in a threaded loop
() -> None
Stops the camera and releases resources
Usage Example:

Webcam

USB webcam using pygame camera interface. Constructor:
int
default:"160"
Image width in pixels
int
default:"120"
Image height in pixels
int
default:"3"
Image depth/channels (3 for RGB, 1 for grayscale)
int
default:"20"
Target framerate in Hz
int
default:"0"
Index of the camera device to use
Installation:
Methods:
() -> np.ndarray
Captures and returns a new frame
() -> None
Continuously captures frames at the specified framerate
() -> None
Stops the camera and releases resources

CSICamera

Jetson Nano CSI camera using GStreamer. Constructor:
int
default:"160"
Output image width in pixels
int
default:"120"
Output image height in pixels
int
default:"3"
Image depth/channels
int
default:"3280"
Sensor capture width
int
default:"2464"
Sensor capture height
int
default:"60"
Camera framerate
int
default:"0"
Flip method: 0=none, 1=rotate CCW 90°, 2=flip vertical, 3=rotate CW 90°
Methods:
() -> np.ndarray
Captures and returns a new frame
() -> None
Continuously captures frames in a threaded loop
() -> None
Stops the camera and releases resources

V4LCamera

Video4Linux camera using v4l2capture library. Constructor:
int
default:"160"
Image width in pixels
int
default:"120"
Image height in pixels
str
default:"/dev/video0"
Video device path
str
default:"MJPG"
Video format FourCC code
Installation:

Mock/Testing Cameras

MockCamera

Returns a static image for testing. Constructor:
np.ndarray
default:"None"
Optional image array to use. If None, creates a blank image.

ImageListCamera

Returns images from a directory in sequence. Constructor:
str
Glob pattern for image files
Methods:
() -> np.ndarray
Returns the next image in the sequence

Configuration

Cameras are typically configured in myconfig.py:

Integration Example

From templates like complete.py: