-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera Factory Pattern Adoption #64
Conversation
bantuerfei0
commented
Nov 14, 2024
- Removed the ability for cameras to save images, instead they just return data and it is up to the caller to save the data
- Added implementations for the opencv and picamera2 (UNTESTED) camera
- Added CameraOption enum (CAM_OPENCV, CAM_PICAM2) to camera_factory.py
- Added create_camera(CameraOption, width, height) function to camera_factory.py
- Both untested, however the opencv implementation should be identical to the previous iteration
Note: include import checks inside create_camera() function, not the implementations themselves...? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed.
modules/camera/base_camera.py
Outdated
class BaseCameraDevice(ABC): | ||
""" | ||
Abstract class for camera device implementations. | ||
TODO: could leverage the abc library's tags more (required properties/methods/etc.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do this now in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, just read up on it and the abstractproperty decorator is deprecated since python 3.3
We can just use the @Property decorator. However, I believe camera is supposed to be "private"
The picamera2 library seems to throw RuntimeError if anything goes wrong, so wrapping the camera creation in a try-except block. Picamera2 fails capture_array() the same way opencv would for read() Changed the configuration for the picamera2 camera to use a still configuration. TL;DR most configurations are similar in parameters, except for buffer size. See manual/source for more
Integration tests are failing, going to go to work session today to fix |
Tested OpenCV integration test Tested QR Code integration test Pending Picamera2 integration test Renamed get_camera_data function inside cameras to "run" Fixed type hinting error in picamera2 implementation Other small changes
5275686
to
51fa66c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one little thing
camera = picamera2.Picamera2() | ||
|
||
config = camera.create_still_configuration( | ||
{"size": (width, height), "format": "RGB888"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add parameters for "ExposureTime" and "AnalogueGain"? We will need to set these for the IR camera detection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved