//! Integration tests for the documented pipeline examples (see the crate-level docs). //! //! These assert that the runnable parts of the examples behave as documented and //! that the scaffolded steps report `Error::Unimplemented` rather than panicking. use std::path::Path; use colmap::math::{Vec2, Vec3}; use colmap::scene::Camera; use colmap::types::CameraModelId; use colmap::Error; /// Example 1 — basic building blocks: a pinhole camera projects an on-axis point /// onto its principal point. #[test] fn basic_building_blocks_example() { let camera = Camera::new_with_model(1, CameraModelId::Pinhole, 800.0, 640, 480); assert_eq!(camera.model_name(), "PINHOLE"); assert_eq!((camera.width, camera.height), (640, 480)); let uv = camera.img_from_cam(&Vec3::new(0.0, 0.0, 1.0)).unwrap(); assert_eq!(uv, Vec2::new(320.0, 240.0)); // Option structs construct with sane defaults. let features = colmap::feature::FeatureExtractionOptions::default(); assert!(features.sift.max_num_features > 0); } /// Example 2 — the workflow's option structs compose as documented. #[test] fn workflow_options_compose() { let sfm = colmap::sfm::IncrementalPipelineOptions::default(); assert!(sfm.min_num_matches >= 1); let mvs = colmap::mvs::PatchMatchOptions::default(); assert!(mvs.window_radius >= 1); } /// Example 3 — error handling: a scaffolded step returns `Error::Unimplemented`. #[test] fn scaffolded_step_reports_unimplemented() { use colmap::mvs::{patch_match_stereo, PatchMatchOptions}; let result = patch_match_stereo(Path::new("/tmp/workspace"), &PatchMatchOptions::default()); match result { Err(Error::Unimplemented(what)) => assert_eq!(what, "dense patch-match stereo"), other => panic!("expected Unimplemented, got {other:?}"), } }