From 552ff9185a8b97ee74637ee8cb6f58c36f374ddb Mon Sep 17 00:00:00 2001 From: Andrew Straw Date: Mon, 13 Jan 2025 10:59:52 +0100 Subject: [PATCH] braid-april-cal: do not require opencv by default --- braid-april-cal/Cargo.toml | 2 -- .../braid-april-cal-webapp/Cargo.toml | 2 +- .../flytrax-apriltags-calibration/Cargo.toml | 2 +- braid-april-cal/src/lib.rs | 23 +++++++++++-------- braid-april-cal/tests/integration-test.rs | 3 +++ 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/braid-april-cal/Cargo.toml b/braid-april-cal/Cargo.toml index 2f821f0de..6e7f8bf5b 100644 --- a/braid-april-cal/Cargo.toml +++ b/braid-april-cal/Cargo.toml @@ -28,6 +28,4 @@ anyhow.workspace = true ads-webasm = { workspace = true, features = ["csv-widget"] } [features] -default = ["solve-pnp"] - solve-pnp = ["opencv-calibrate"] diff --git a/braid-april-cal/braid-april-cal-webapp/Cargo.toml b/braid-april-cal/braid-april-cal-webapp/Cargo.toml index c6c3e9b02..4f0dad2a5 100644 --- a/braid-april-cal/braid-april-cal-webapp/Cargo.toml +++ b/braid-april-cal/braid-april-cal-webapp/Cargo.toml @@ -26,6 +26,6 @@ wasm-logger.workspace = true chrono.workspace = true ads-webasm = { workspace = true, features = ["csv-widget"] } -braid-april-cal = { path = "..", default-features = false } +braid-april-cal.workspace = true [features] diff --git a/braid-april-cal/flytrax-apriltags-calibration/Cargo.toml b/braid-april-cal/flytrax-apriltags-calibration/Cargo.toml index f5b6a620a..c248427dc 100644 --- a/braid-april-cal/flytrax-apriltags-calibration/Cargo.toml +++ b/braid-april-cal/flytrax-apriltags-calibration/Cargo.toml @@ -20,7 +20,7 @@ tracing.workspace = true ads-webasm = { workspace = true, features = ["csv-widget"] } ads-apriltag.workspace = true -braid-april-cal.workspace = true +braid-april-cal = { workspace = true, features = ["solve-pnp"] } convert-image.workspace = true flydra-types.workspace = true flytrax-io.workspace = true diff --git a/braid-april-cal/src/lib.rs b/braid-april-cal/src/lib.rs index 390acfad4..788fca5a0 100644 --- a/braid-april-cal/src/lib.rs +++ b/braid-april-cal/src/lib.rs @@ -292,11 +292,11 @@ fn dlt( Ok(linear_cam) } +#[cfg(feature = "solve-pnp")] fn solve_extrinsics( points: Vec>, intrinsics: &NamedIntrinsicParameters, ) -> Result { - #[cfg(feature = "solve-pnp")] { let cv_points: Vec = points .iter() @@ -361,13 +361,6 @@ fn solve_extrinsics( Ok(CamSolution { final_cam, points }) } - #[cfg(not(feature = "solve-pnp"))] - { - let _ = (intrinsics, points); - Err(MyError { - msg: "'solve-pnp' feature must be enabled to solve extrinsics".into(), - }) - } } fn dlt_then_distortion( @@ -440,8 +433,18 @@ pub fn do_calibrate_system(src_data: &CalData) -> Result CalibrationResult { @@ -107,6 +109,7 @@ fn test_calibration_pymvg() { } #[test] +#[cfg(feature = "solve-pnp")] fn solve_pnp_with_prior_intrinsics() -> anyhow::Result<()> { let fiducial_3d_coords_buf = include_bytes!("data-single-cam/apriltags_coordinates.csv"); let fiducial_3d_coords = parse_csv::(