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
() -> 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
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
() -> 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°
() -> 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
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
() -> np.ndarray
Returns the next image in the sequence
Configuration
Cameras are typically configured inmyconfig.py:
Integration Example
From templates likecomplete.py:
