pub struct ReconBuilder { /* private fields */ }Expand description
Plan recorder. Methods only record and do not run anything. Validate with ReconBuilder::build.
Implementations§
Source§impl ReconBuilder
impl ReconBuilder
Sourcepub fn input(self, src: impl AsRef<Path>) -> Self
pub fn input(self, src: impl AsRef<Path>) -> Self
Input folder: images <src>/images/<camera>/, GPS <src>/gps_ref.txt.
Sourcepub fn images(self, dir: impl Into<PathBuf>) -> Self
pub fn images(self, dir: impl Into<PathBuf>) -> Self
Only specify the image folder (parent of the camera folders).
Sourcepub fn cameras<S: Into<String>>(self, cams: impl IntoIterator<Item = S>) -> Self
pub fn cameras<S: Into<String>>(self, cams: impl IntoIterator<Item = S>) -> Self
List of camera folders (frame-bundle order).
Sourcepub fn preset(self, name: &str) -> Self
pub fn preset(self, name: &str) -> Self
Apply a preset (cameras, pairing strategy, stride). An unknown name is an error in build.
aerial-formation: camF/camR/camL, formation pairing rule, stride 3.
Sourcepub fn zones(self, span: usize, overlap: usize) -> Self
pub fn zones(self, span: usize, overlap: usize) -> Self
Zone size and overlap (number of positions).
Sourcepub fn no_gps(self) -> Self
pub fn no_gps(self) -> Self
No GPS file (to turn off alignment too, pass AlignFrame::None to ReconBuilder::align).
Sourcepub fn align(self, frame: AlignFrame) -> Self
pub fn align(self, frame: AlignFrame) -> Self
Alignment coordinate frame.
Sourcepub fn fixed_enu_origin(self, on: bool) -> Self
pub fn fixed_enu_origin(self, on: bool) -> Self
Fix the session ENU origin to the first GPS line.
Sourcepub fn match_backend(self, name: &str) -> Self
pub fn match_backend(self, name: &str) -> Self
Matching backend (cpu|cuda).
Sourcepub fn gpu(self) -> Self
pub fn gpu(self) -> Self
Set the SIFT, matching, sparse-stage, PatchMatch, undistortion and bundle adjustment backends all to cuda.
Sourcepub fn incremental_triangulation(self, on: bool) -> Self
pub fn incremental_triangulation(self, on: bool) -> Self
Triangulate only newly registered images.
Sourcepub fn stable_display(self, on: bool) -> Self
pub fn stable_display(self, on: bool) -> Self
Stable display (see SessionConfig::stable_display).
Sourcepub fn settle(self, tol: f64, max_zone: usize) -> Self
pub fn settle(self, tol: f64, max_zone: usize) -> Self
Stable display settling: intrinsics change tolerance and the last zone that may still settle
(see SessionConfig::settle_tol, SessionConfig::settle_max_zone).
Sourcepub fn lookahead(self, positions: usize) -> Self
pub fn lookahead(self, positions: usize) -> Self
Positions whose features are extracted ahead of the position loop (see SessionConfig::lookahead; 0 = off, the default).
Sourcepub fn preview(self, on: bool) -> Self
pub fn preview(self, on: bool) -> Self
Stable display: sparse preview of every zone when it closes (see SessionConfig::preview).
Sourcepub fn on<F>(self, kind: EventKind, f: F) -> Self
pub fn on<F>(self, kind: EventKind, f: F) -> Self
A hook for a specific kind (Pipeline::on).
Choosing EventKind::FrameDecoded turns frame decoding on.
Sourcepub fn on_frame<F>(self, f: F) -> Self
pub fn on_frame<F>(self, f: F) -> Self
Frame hook (Pipeline::on_frame): receives each decoded input frame (RGB), one camera at a time, before the position is
processed.
Registering one turns frame decoding on.
Examples found in repository?
53fn main() -> Result<(), String> {
54 let path = std::env::args().nth(1).ok_or("usage: frame_hook_plan <plan.toml>")?;
55 let plan = Plan::load(&path)?;
56 let seen = Arc::new(Mutex::new(Seen::default()));
57 let refined = Arc::new(Mutex::new(Vec::new()));
58 let t0 = Instant::now();
59 let (s, r) = (seen.clone(), refined.clone());
60 let recon = Recon::from_plan(plan)
61 .on_frame(move |f: &Arc<Frame>| {
62 let mut s = s.lock().unwrap();
63 let t = t0.elapsed().as_secs_f64();
64 s.first_s.get_or_insert(t);
65 s.last_s = t;
66 *s.per_camera.entry(f.camera.clone()).or_default() += 1;
67 *s.sizes.entry((f.width, f.height)).or_default() += 1;
68 s.bytes += f.rgb.len();
69 s.positions = s.positions.max(f.position + 1);
70 if f.rgb.len() != (f.width * f.height * 3) as usize || f.width == 0 {
71 s.bad += 1;
72 }
73 })
74 .on_zone_refined(move |z, cloud| r.lock().unwrap().push((z.zone, cloud.len())))
75 .build()
76 .map_err(|e| e.to_string())?;
77 let summary = recon.run()?;
78 let s = seen.lock().unwrap();
79 let total: usize = s.per_camera.values().sum();
80 println!(
81 "frame hook: {total} frames over {} positions, per camera {:?}, sizes {:?}, {:.1} MB RGB, bad {}",
82 s.positions,
83 s.per_camera,
84 s.sizes,
85 s.bytes as f64 / 1e6,
86 s.bad
87 );
88 println!(
89 "frame hook: first frame at {:.2}s, last at {:.2}s; run total {:.1}s",
90 s.first_s.unwrap_or(0.0),
91 s.last_s,
92 t0.elapsed().as_secs_f64()
93 );
94 println!("refined zones (zone, dense points): {:?}", refined.lock().unwrap());
95 println!("events {}, hook calls {}, hook panics {}", summary.events, summary.hook_calls, summary.hook_panics);
96 if total == 0 || s.bad > 0 || summary.hook_panics > 0 {
97 return Err("frame hook check failed".into());
98 }
99 Ok(())
100}Sourcepub fn on_any<F>(self, f: F) -> Self
pub fn on_any<F>(self, f: F) -> Self
Hook for all events (Pipeline::on_any).
Sourcepub fn on_zone_preview<F>(self, f: F) -> Self
pub fn on_zone_preview<F>(self, f: F) -> Self
Zone preview point-cloud hook (Pipeline::on_zone_preview).
Sourcepub fn on_zone_refined<F>(self, f: F) -> Self
pub fn on_zone_refined<F>(self, f: F) -> Self
Zone refined point-cloud hook (Pipeline::on_zone_refined).
Examples found in repository?
53fn main() -> Result<(), String> {
54 let path = std::env::args().nth(1).ok_or("usage: frame_hook_plan <plan.toml>")?;
55 let plan = Plan::load(&path)?;
56 let seen = Arc::new(Mutex::new(Seen::default()));
57 let refined = Arc::new(Mutex::new(Vec::new()));
58 let t0 = Instant::now();
59 let (s, r) = (seen.clone(), refined.clone());
60 let recon = Recon::from_plan(plan)
61 .on_frame(move |f: &Arc<Frame>| {
62 let mut s = s.lock().unwrap();
63 let t = t0.elapsed().as_secs_f64();
64 s.first_s.get_or_insert(t);
65 s.last_s = t;
66 *s.per_camera.entry(f.camera.clone()).or_default() += 1;
67 *s.sizes.entry((f.width, f.height)).or_default() += 1;
68 s.bytes += f.rgb.len();
69 s.positions = s.positions.max(f.position + 1);
70 if f.rgb.len() != (f.width * f.height * 3) as usize || f.width == 0 {
71 s.bad += 1;
72 }
73 })
74 .on_zone_refined(move |z, cloud| r.lock().unwrap().push((z.zone, cloud.len())))
75 .build()
76 .map_err(|e| e.to_string())?;
77 let summary = recon.run()?;
78 let s = seen.lock().unwrap();
79 let total: usize = s.per_camera.values().sum();
80 println!(
81 "frame hook: {total} frames over {} positions, per camera {:?}, sizes {:?}, {:.1} MB RGB, bad {}",
82 s.positions,
83 s.per_camera,
84 s.sizes,
85 s.bytes as f64 / 1e6,
86 s.bad
87 );
88 println!(
89 "frame hook: first frame at {:.2}s, last at {:.2}s; run total {:.1}s",
90 s.first_s.unwrap_or(0.0),
91 s.last_s,
92 t0.elapsed().as_secs_f64()
93 );
94 println!("refined zones (zone, dense points): {:?}", refined.lock().unwrap());
95 println!("events {}, hook calls {}, hook panics {}", summary.events, summary.hook_calls, summary.hook_panics);
96 if total == 0 || s.bad > 0 || summary.hook_panics > 0 {
97 return Err("frame hook check failed".into());
98 }
99 Ok(())
100}Sourcepub fn on_snapshot<F>(self, f: F) -> Self
pub fn on_snapshot<F>(self, f: F) -> Self
Snapshot hook (Pipeline::on_snapshot).
Sourcepub fn on_position_done<F>(self, f: F) -> Self
pub fn on_position_done<F>(self, f: F) -> Self
Position-done hook (Pipeline::on_position_done).
Sourcepub fn on_message<F>(self, f: F) -> Self
pub fn on_message<F>(self, f: F) -> Self
Warning/error message hook (Pipeline::on_message).
Sourcepub fn policy(self, kind: EventKind, p: QueuePolicy) -> Self
pub fn policy(self, kind: EventKind, p: QueuePolicy) -> Self
Per-kind queue policy (Pipeline::policy).
Sourcepub fn build(self) -> Result<Recon, PlanError>
pub fn build(self) -> Result<Recon, PlanError>
Validate the plan -> an executable Recon. It neither creates nor deletes files or folders (it only reads the input folder
listing and the GPS file).
Checks: input and camera folders exist, number of selected positions, alignment and GPS file, backend names and device (when CUDA
is requested),
output folder writable, option value ranges. All problems are collected and returned at once as a PlanError.
Examples found in repository?
53fn main() -> Result<(), String> {
54 let path = std::env::args().nth(1).ok_or("usage: frame_hook_plan <plan.toml>")?;
55 let plan = Plan::load(&path)?;
56 let seen = Arc::new(Mutex::new(Seen::default()));
57 let refined = Arc::new(Mutex::new(Vec::new()));
58 let t0 = Instant::now();
59 let (s, r) = (seen.clone(), refined.clone());
60 let recon = Recon::from_plan(plan)
61 .on_frame(move |f: &Arc<Frame>| {
62 let mut s = s.lock().unwrap();
63 let t = t0.elapsed().as_secs_f64();
64 s.first_s.get_or_insert(t);
65 s.last_s = t;
66 *s.per_camera.entry(f.camera.clone()).or_default() += 1;
67 *s.sizes.entry((f.width, f.height)).or_default() += 1;
68 s.bytes += f.rgb.len();
69 s.positions = s.positions.max(f.position + 1);
70 if f.rgb.len() != (f.width * f.height * 3) as usize || f.width == 0 {
71 s.bad += 1;
72 }
73 })
74 .on_zone_refined(move |z, cloud| r.lock().unwrap().push((z.zone, cloud.len())))
75 .build()
76 .map_err(|e| e.to_string())?;
77 let summary = recon.run()?;
78 let s = seen.lock().unwrap();
79 let total: usize = s.per_camera.values().sum();
80 println!(
81 "frame hook: {total} frames over {} positions, per camera {:?}, sizes {:?}, {:.1} MB RGB, bad {}",
82 s.positions,
83 s.per_camera,
84 s.sizes,
85 s.bytes as f64 / 1e6,
86 s.bad
87 );
88 println!(
89 "frame hook: first frame at {:.2}s, last at {:.2}s; run total {:.1}s",
90 s.first_s.unwrap_or(0.0),
91 s.last_s,
92 t0.elapsed().as_secs_f64()
93 );
94 println!("refined zones (zone, dense points): {:?}", refined.lock().unwrap());
95 println!("events {}, hook calls {}, hook panics {}", summary.events, summary.hook_calls, summary.hook_panics);
96 if total == 0 || s.bad > 0 || summary.hook_panics > 0 {
97 return Err("frame hook check failed".into());
98 }
99 Ok(())
100}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ReconBuilder
impl !Send for ReconBuilder
impl !Sync for ReconBuilder
impl !UnwindSafe for ReconBuilder
impl Freeze for ReconBuilder
impl Unpin for ReconBuilder
impl UnsafeUnpin for ReconBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.