-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* camera config classes * camera config classes updated * updated camera_comfig * updated camera config * updated config * updated camera config * styling errors fix * styling fixes * fixed errors * styling issues * fixed styling * fixed styling: * fixed styling
- Loading branch information
Showing
8 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
Camera configuration | ||
""" | ||
|
||
try: | ||
from libcamera import controls # This is a pre-installed library on the Rpi5 | ||
except ImportError: | ||
pass | ||
|
||
|
||
class PiCameraConfig: | ||
""" | ||
Configuration for the PiCamera. | ||
This class allows specifying parameters such as exposure time, gain, and contrast. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
exposure_time: int = 250, | ||
analogue_gain: float = 64.0, | ||
contrast: float = 1.0, | ||
lens_position: float = None, | ||
) -> None: | ||
""" | ||
Args: | ||
exposure_time (int) | ||
analogue_gain (float) | ||
contrast (float) | ||
lens_position (float) | ||
""" | ||
self.exposure_time = exposure_time | ||
self.analogue_gain = analogue_gain | ||
self.contrast = contrast | ||
self.lens_position = lens_position | ||
|
||
def to_dict(self) -> dict[str, int | float | None]: | ||
""" | ||
Dictionary containing camera controls. | ||
""" | ||
camera_controls: dict[str, int | float] = {} | ||
if self.exposure_time is not None: | ||
camera_controls["ExposureTime"] = self.exposure_time | ||
if self.analogue_gain is not None: | ||
camera_controls["AnalogueGain"] = self.analogue_gain | ||
if self.contrast is not None: | ||
camera_controls["Contrast"] = self.contrast | ||
if self.lens_position is not None: | ||
camera_controls["LensPosition"] = self.lens_position | ||
camera_controls["AfMode"] = controls.AfModeEnum.Manual | ||
else: | ||
camera_controls["LensPosition"] = 0.0 | ||
camera_controls["AfMode"] = controls.AfModeEnum.Auto | ||
|
||
return camera_controls | ||
|
||
|
||
class OpenCVCameraConfig: | ||
""" | ||
Placeholder | ||
""" | ||
|
||
pass # pylint: disable=unnecessary-pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters