basic_bot.commons.camera_picamera
Camera Objects
This class implements the BaseCamera interface using Picamera2.
To use the Picamera2, you need to be running on a Raspberry Pi Bullseye or Bookworm with a ribbon cable camera module installed.
To use with the vision service, you need to set the environment
variable BB_CAMERA_MODULE=basic_bot.commons.camera_picamera
before the vision service is started. You can al
- name: "vision"
run: "python -m basic_bot.services.vision"
production_env:
BB_CAMERA_MODULE: "basic_bot.commons.camera_picamera"
By default the vision service uses opencv camera capture which ATM works on Bullseye and Bookworm with USB camera, but not for ribbon cable cameras. See also the Installation Guide for Bookworm.
Direct Usage:
from basic_bot.commons.camera_picamera import Camera
camera = Camera()
# get_frame() is from BaseCamera and returns a single frame
frame = camera.get_frame()
# you can then used the image frame for example:
jpeg = cv2.imencode(".jpg", frame)[1].tobytes()
See vision service for another example usage.
frames
Generator function that yields frames from the camera. Required by BaseCamera