malphite.camera
¶
Module Contents¶
Classes¶
Base configuration class for cameras. |
|
A camera class that uses OpenCV to capture images. |
|
Configuration for an OpenCV camera. |
|
A camera class that uses shared memory to capture images. |
|
API¶
- exception malphite.camera.CameraConfigurationError¶
Bases:
Exception
Raised when camera configuration parameters cannot be set.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class malphite.camera.Camera(camera_config: malphite.camera.CameraConfig)¶
Bases:
abc.ABC
- abstractmethod read_once() numpy.ndarray ¶
Reads a single frame from the camera.
- Returns:
The captured frame.
- Return type:
np.ndarray
- class malphite.camera.CameraConfig¶
Bases:
abc.ABC
Base configuration class for cameras.
- name: str | None = None¶
The name of the camera.
- width: int | None = None¶
The width of the camera image in pixels.
- height: int | None = None¶
The height of the camera image in pixels.
- fps: float | None = None¶
The frames per second (FPS) of the camera.
- type: str | None = None¶
- target_class: malphite.camera.CameraConfig.type = None¶
The target class to instantiate with. This should be a subclass of
Camera
.
- class malphite.camera.OpenCVCamera(camera_config: malphite.camera.OpenCVCameraConfig)¶
Bases:
malphite.camera.Camera
A camera class that uses OpenCV to capture images.
Initialization
Initialize the camera with the given configuration.
- Parameters:
camera_config (CameraConfig) – The configuration for the camera.
- read_once() numpy.ndarray ¶
Reads a single frame from the camera.
- class malphite.camera.OpenCVCameraConfig¶
Bases:
malphite.camera.CameraConfig
Configuration for an OpenCV camera.
- camera_path: str = None¶
The path to the camera device, e.g., ‘/dev/video0’.
- type: str = 'opencv'¶
- target_class: malphite.camera.OpenCVCameraConfig.type = None¶
Bases:
malphite.camera.Camera
A camera class that uses shared memory to capture images.
Initialization
Initialize the camera with the given configuration.
- Parameters:
camera_config (CameraConfig) – The configuration for the camera.
Reads a single frame from the shared memory.
Bases:
malphite.camera.CameraConfig
The name of the shared memory segment.
The size of the shared memory segment in bytes.
For example, if the camera resolution is width x height and the image is in 8-bit RGB format, the size can be calculated as:
shared_memory_size = int(width * height * 3 * np.uint8().itemsize)
- class malphite.camera.ManagedCamera(camera_config: malphite.camera.CameraConfig, shared_memory_name: str = None)¶
Bases:
malphite.camera.Camera
- _instance: malphite.camera.Camera = None¶
- read_once() numpy.ndarray ¶
Reads a single frame from the camera.
Exports the camera configuration as a
SharedCameraConfig
.