-
Notifications
You must be signed in to change notification settings - Fork 7
Add larod-sys #182
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
apljungquist
merged 11 commits into
AxisCommunications:main
from
JsGjKJzi:feature/add-larod-sys
May 8, 2025
Merged
Add larod-sys #182
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4ba72da
add larod-sys
JsGjKJzi 021d2ee
use newtype enums
JsGjKJzi 1501fca
alphabetic order in Cargo.toml
JsGjKJzi 2cd4b37
move any custom code out of larod-sys crate
JsGjKJzi a63e9e4
copy bindings.rs
JsGjKJzi 6c6d751
f: remove thiserror
apljungquist 0819f67
s: Add simple example
apljungquist 9a4cb06
f: prepare to merge
apljungquist 4e46601
Merge remote-tracking branch 'upstream/main' into feature/add-larod-sys
apljungquist 1b1b3f6
f: checksums
apljungquist 57219a7
f: fmt
apljungquist 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
| [package] | ||
| name = "object_detection" | ||
| version = "0.0.0" | ||
| edition.workspace = true | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| anyhow = { workspace = true } | ||
| log = { workspace = true } | ||
|
|
||
| acap-logging = { workspace = true } | ||
| larod-sys = { workspace = true } |
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,11 @@ | ||
| { | ||
| "schemaVersion": "1.4.0", | ||
| "acapPackageConf": { | ||
| "setup": { | ||
| "appName": "object_detection", | ||
| "vendor": "Axis Communications", | ||
| "runMode": "never", | ||
| "version": "1.0.0" | ||
| } | ||
| } | ||
| } |
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,35 @@ | ||
| //! This application loads a larod model which takes an image as input and outputs values | ||
| //! corresponding to the class, score and location of detected objects in the image. | ||
| //! | ||
| //! # Arguments | ||
| //! | ||
| //! 1. `MODEL`: a string describing the path to the model. | ||
| //! 2. `WIDTH`: an integer for the input width. ß | ||
| //! 3. `HEIGHT`: an integer for the input height. | ||
| //! 4. `QUALITY`: an integer for the desired jpeg quality. | ||
| //! 5. `RAW_WIDTH`: an integer for camera width resolution. | ||
| //! 6. `RAW_HEIGHT`: an integer for camera height resolution. | ||
| //! 7. `THRESHOLD`: an integer ranging from 0 to 100 to select good detections. | ||
| //! 8. `LABELSFILE`: a string describing the path to the label txt. | ||
|
|
||
| use log::{error, info}; | ||
|
|
||
| fn main() { | ||
| acap_logging::init_logger(); | ||
| let mut conn: *mut larod_sys::larodConnection = std::ptr::null_mut(); | ||
| let mut error: *mut larod_sys::larodError = std::ptr::null_mut(); | ||
| if unsafe { !larod_sys::larodConnect(&mut conn, &mut error) } { | ||
| error!("Could not connect to larod"); | ||
| return; | ||
| } | ||
| assert!(error.is_null()); | ||
|
|
||
| let mut num_sessions = u64::MAX; | ||
| if unsafe { !larod_sys::larodGetNumSessions(conn, &mut num_sessions, &mut error) } { | ||
| error!("Could not get the number of sessions"); | ||
| return; | ||
| } | ||
|
|
||
| info!("Number of sessions: {num_sessions}"); | ||
| todo!("Implement the real example") | ||
| } |
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,10 @@ | ||
| [package] | ||
| build = "build.rs" | ||
| name = "larod-sys" | ||
| version = "0.0.0" | ||
| edition.workspace = true | ||
| license = "MIT" | ||
|
|
||
| [build-dependencies] | ||
| bindgen = { workspace = true } | ||
| pkg-config = { workspace = true } |
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,27 @@ | ||
| use std::{env, path}; | ||
|
|
||
| fn populated_bindings(dst: &path::PathBuf) { | ||
| let library = pkg_config::Config::new().probe("liblarod").unwrap(); | ||
| let mut bindings = bindgen::Builder::default() | ||
| .header("wrapper.h") | ||
| .allowlist_recursively(false) | ||
| .allowlist_function("^(larod.*)$") | ||
| .allowlist_type("^(_?larod.*)$") | ||
| .default_enum_style(bindgen::EnumVariation::NewType { | ||
| is_global: false, | ||
| is_bitfield: true, | ||
| }) | ||
| .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) | ||
| .layout_tests(false); | ||
| for path in library.include_paths { | ||
| bindings = bindings.clang_args(&["-F", path.to_str().unwrap()]); | ||
| } | ||
| bindings.generate().unwrap().write_to_file(dst).unwrap(); | ||
| } | ||
|
|
||
| fn main() { | ||
| let dst = path::PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs"); | ||
| if env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default() != "x86_64" { | ||
| populated_bindings(&dst); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.