Camera
Description
Represents a camera tool for the Jubilee machine, based on the Raspberry Pi Camera module. Enables frame capture, video streaming, and well imaging tasks. Extends the base Tool class and inherits all standard tool behaviors (activation check, offset, etc.).
Camera operations require the tool to be active (@requires_active_tool enforced).
Constructor
python
Camera(index: int, name: str)Initializes a Camera tool.
| Parameter | Type | Description |
|---|---|---|
index | int | Tool number assigned to the camera. |
name | str | Human-readable name of the camera. |
Key Properties
| Property | Type | Description |
|---|---|---|
_camera_matrix | ndarray or None | Loaded camera intrinsic calibration matrix. |
_dist_matrix | ndarray or None | Lens distortion coefficients. |
Important Methods
| Method | Returns | Description |
|---|---|---|
load_coefficients(path) | list | Loads camera calibration coefficients from YAML. |
get_camera_indices() | list | Lists all available camera device indices (for OpenCV capture). |
get_frame(resolution=[1200,1200], uvc=False) | ndarray | Captures a single still frame (requires PiCamera). |
show_frame(frame, grid=False, save=False, save_path="fig.png") | None | Displays a frame using matplotlib. |
get_show_frame() | None | Captures and displays a frame. |
video_stream(camera_index=0) | None | Starts a live video stream from a selected camera. |
image_wells(resolution, uvc, wells) | None | Moves to multiple wells and shows captured images. |
get_well_image(resolution, uvc, well) | ndarray | Moves to a single well and captures a frame. |
Helper Functions
| Method | Returns | Description |
|---|---|---|
_get_xyz(well, location) | tuple | Gets (x,y,z) coordinates from either a Well or direct location. |
_get_top_bottom(well) | tuple | Gets the z-heights for the top and bottom of a well. |
Usage Flow Example
python
from science_jubilee.tools import Camera
from science_jubilee.machine import Machine
# Connect to machine
m = Machine(address="192.168.1.2")
# Load camera tool
camera = Camera(index=5, name="CameraTool")
m.load_tool(camera)
m.pickup_tool(camera)
# Capture a frame
frame = camera.get_frame()
camera.show_frame(frame)Important Notes
- Requires Raspberry Pi Camera support (Linux systems only).
- Always ensure the Camera tool is active (
@requires_active_tool) before attempting any camera operations. - By default, lens distortion correction is commented out — call
load_coefficients(path)if calibration is desired. - Move to safe Z heights (
m.safe_z_movement()) before adjusting X/Y for imaging wells. - For imaging wells, focus height (
z=30) is hard-coded — consider adjusting per system setup.