Skip to content

Update camera module with encoding, configuration, and state handling#6

Merged
jlegrand62 merged 6 commits intodevelopfrom
feature/camera-options
Mar 11, 2026
Merged

Update camera module with encoding, configuration, and state handling#6
jlegrand62 merged 6 commits intodevelopfrom
feature/camera-options

Conversation

@ArthurLuciani2
Copy link
Collaborator

### Summary

This pull request updates the camera module with the following changes:
- Adds encoding configuration support (`jpeg` and `png`) and related signals.
- Introduces new `WAITING` state and asynchronous response handling for enhanced camera interaction.
- Includes camera lag simulation via environment variable (`PI3_CAMERASERVER_LAG`) with corresponding UI updates for warning states.
- Extends configuration capabilities with additional RPC properties (`encoding` and `config`) and improved signal handling.

### Details

**Key updates include:**
1. **Encoding Configuration:**
   - Support for `jpeg` and `png` image formats via new `encoding` property.
   - Signals (`encodingChanged` and `configChanged`) added to notify about updates.

2. **State Handling:**
   - Implements a `WAITING` state for delayed or asynchronous operations.
   - Enhances signal integration for consistent state management.

3. **Lag Simulation:**
   - Introduces lag simulation via `PI3_CAMERASERVER_LAG` with warning-level updates in UI elements.

4. **Camera Configuration:**
   - Support for configuring encoding and other camera parameters dynamically using RPC properties.
   - Updated test cases and examples to reflect new functionalities.

- Introduced `encoding` property with support for `jpeg` and `png` formats in `RPCCamera.py` and `cameraserver.py`.
- Added `_encoding` and `_config` attributes to store encoding preference and camera parameters.
- Implemented `config` property to set camera parameters from Picamera2 Appendix B, with updates applied via `set_controls`.
- Modified image capture logic to support `png` encoding using Pillow for conversion and compression.
- Extended RPC signals `encodingChanged` and `configChanged` to notify about encoding and configuration changes.
- Updated abstract methods in `cameradevice.py` to define `encoding` and `config` management.
- Adjusted example code in `cameraserver.py` to include new functionality for encoding and camera configuration.
- Added `encodingChanged` and `configChanged` signals in `PiCameraComm.py` to notify about encoding and configuration updates.
- Introduced `encoding` and `config` properties in `PiCameraComm.py` with corresponding setters to update camera settings asynchronously.
- Enhanced `_configure_cameras` method in `scanner.py` to set `encoding` and `config` for individual cameras using provided configurations.
- Ensured new properties integrate seamlessly with the camera initialization and configuration flow.
…era modules

- Introduced a new `WAITING` state in `CameraBridge.py` and `PiCameraComm.py` to represent when the camera is waiting for a response.
- Updated `STATE_TO_CLASS` mapping to include the `WAITING` state.
- Added `waitingForResponseChanged` signal in `PiCameraComm.py` to notify changes in the waiting state.
- Implemented `waiting_for_response` property in `PiCameraComm.py` to manage asynchronous operations and trigger the signal when the waiting state changes.
- Modified camera property getters and setters to handle the `WAITING` state during asynchronous operations.
- Refactored `CameraBridge` initialization to connect to the `waitingForResponseChanged` signal and update its status accordingly.
- Simplified `nextDisplayMode` method in `CameraBridge.py` by removing redundant `return` statements.
- Introduced `PI3_CAMERASERVER_LAG` environment variable to simulate camera processing lag; added handling in `cameraserver.py`.
- Added `warningColor` property in `Style.qml` for consistent styling of warning states.
- Enhanced `CameraDelegate.qml` to support `waiting` status with appropriate icons and colors.
- Updated integration test `test_scan_integration.py` to include lag simulation setup for testing.
- Added delay logic to image generation in `cameraserver.py` based on configured lag.
- Updated comments and references in `RPCCamera.py` and `cameraserver.py` to align with Appendix C of the Picamera2 documentation.
- Added `encoding` setting and related comments in `config_scan.toml` for `jpeg` and `png` formats.
- Introduced `picamera.config` and `picamera2.config` sections in `config_scan.toml` to reflect configurable properties from Appendix C of the Picamera2 doc.
@ArthurLuciani2 ArthurLuciani2 self-assigned this Mar 10, 2026
@jlegrand62 jlegrand62 merged commit 0d0f3b6 into develop Mar 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants