-
Notifications
You must be signed in to change notification settings - Fork 31
Expanded support for Libcamera Controls (ControlInfoMap and ControlInfo) #46
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
46ac292
Add support for iterating and getting information from ControlInfoMap
SoZ0 eff5ee9
cargo fmt
SoZ0 8e5825c
added method to get name and id from ControlId and PropertyId enums d…
SoZ0 ad95922
Forgot values method for ControlInfo, now added
SoZ0 c052b1d
fixed issue with ControlInfo.values() not properly decoding into Rust…
SoZ0 9295c96
Improved error handling
SoZ0 200d8bf
rust fmt
SoZ0 1a26183
yes
SoZ0 46188bb
fixes for merging into main
SoZ0 7cf3573
Merge remote-tracking branch 'upstream/main'
SoZ0 a08bd85
Corrected lifetimes
SoZ0 ec4916d
Missing control values implamented
SoZ0 e9b6c2b
cargo format and clippy - ran a short test and should be ready to merge
SoZ0 cedb267
updated examples and new examples. impl debug for ControlInfoMap and …
SoZ0 c5830dd
regnerate and example fix
SoZ0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,20 @@ | ||
| use libcamera::{camera_manager::CameraManager, logging::LoggingLevel, stream::StreamRole}; | ||
|
|
||
| fn main() { | ||
| let mgr = CameraManager::new().unwrap(); | ||
|
|
||
| mgr.log_set_level("Camera", LoggingLevel::Error); | ||
|
|
||
| let cameras = mgr.cameras(); | ||
|
|
||
| for cam in cameras.iter() { | ||
| println!("ID: {}", cam.id()); | ||
|
|
||
| println!("Properties: {:#?}", cam.properties()); | ||
| println!("Controls: {:#?}", cam.controls()); | ||
|
|
||
| let config = cam.generate_configuration(&[StreamRole::ViewFinder]).unwrap(); | ||
| let view_finder_cfg = config.get(0).unwrap(); | ||
| println!("Available formats: {:#?}", view_finder_cfg.formats()); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,38 @@ | ||
| use libcamera::{camera_manager::CameraManager, controls::ControlId, logging::LoggingLevel}; | ||
|
|
||
| fn main() { | ||
| let mgr = CameraManager::new().unwrap(); | ||
|
|
||
| mgr.log_set_level("Camera", LoggingLevel::Error); | ||
|
|
||
| let cameras = mgr.cameras(); | ||
|
|
||
| //Grab the first camera, if one exists | ||
| for cam in cameras.iter().take(1) { | ||
| println!("ID: {}", cam.id()); | ||
|
|
||
| //Read the first ControlInfo | ||
| for (id, control_info) in cam.controls().into_iter().take(1) { | ||
fishrockz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| //Attempt to get ControlID | ||
| match ControlId::try_from(id) { | ||
| Ok(id) => println!("Control Id {:?} - {:?}", id as u32, id), | ||
| Err(_) => println!("Control Id {:?} - UNKOWN", id), | ||
| } | ||
|
|
||
| println!("Control Max: {:?}", control_info.max()); | ||
| println!("Control Min: {:?}", control_info.min()); | ||
| println!("Control Defualt: {:?}", control_info.def()); | ||
|
|
||
| let values = control_info.values(); | ||
|
|
||
| //Some controls only support specific values within their ranges. | ||
| //this will display those possible values if they exist | ||
| if values.len() > 0 { | ||
| println!("Supported Values:"); | ||
| for value in values { | ||
| println!("{:?}", value); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this changing the public api of libcamera-sys ? I worry this might need a version bump if it is.
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.
Im not 100% sure I understand what you are referring to.
There should be no changes that remove or change functionality for the libcamera-sys only add new methods from structs that were missing
many of the changes in here and this section highlighted in specific is adding the missing functions and or giving a more verbose function signature as some of the methods else would share a very similar name or even have the exact name.
I cant recall exactly which functions it was but a few function names were simply too broad not allowing exposing the other libcamera functions with a convenient naming scheme.
If adding in the new functions and or changing the underlying naming of functions is enough to constitute the public api being changed then yes it has changed and will need a version bump. To be honest with the scale and broad impact of changes being made to me it only makes sense.
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.
So the api for
libcamera_control_nameseems to change.changes to
Which if this makes its way to our rust api/abi will be a braking change for
senverrules.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.
yer so i had a little play and
And this function makes its way into the public api via the bindings
./target/debug/build/libcamera-sys-*/out/bindings.rs:
to
and it can be accessed by
I would suggest that we re ajust the cpp file so the changes are purely additive
Or we need to bump the version in this MR.
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.
I could refactor it to have them all use:
enum libcamera_control_id_enumand have the c++ api internally call:
const libcamera_control_id_t *libcamera_control_from_id(enum libcamera_control_id_enum id)to acces the needed methods. I'm just not sure if this is the right way to go about this.
The current way its laid out in the PR follows how the other structs are handled where it uses the direct reference instead of getting a new one each time.
OR
We could approach it like this to all the effected methods:
it just seems weird and a bit redundant to have it like this to me, using the struct pointer seems like the way the api should move towards when working with the controls.
I personally feel like a version bump should be the way to go, but I am willing to refactor the code if a version bump would rather be avoided