pub struct Session { /* private fields */ }Expand description
Incremental reconstruction state value.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(cfg: SessionConfig) -> Self
pub fn new(cfg: SessionConfig) -> Self
Create an empty session from the settings.
Examples found in repository?
49fn main() -> Result<(), String> {
50 let out = std::env::args().nth(1).map(PathBuf::from).unwrap_or_else(|| std::env::temp_dir().join("cumulus3d_hooks"));
51 let src = out.with_extension("src");
52 if !src.join("gps_ref.txt").exists() {
53 common::make_dataset(&src);
54 }
55 if out.exists() {
56 std::fs::remove_dir_all(&out).map_err(|e| e.to_string())?;
57 }
58 let layout = Layout::discover(&src, 1)?;
59 let npos = layout.frames.len();
60
61 let mut cfg = SessionConfig::new(src.join("images"));
62 cfg.gps = read_gps_file(src.join("gps_ref.txt")).map_err(|e| e.to_string())?;
63 (cfg.span, cfg.overlap, cfg.total_positions, cfg.seed) = (4, 1, Some(npos), Some(7));
64 if cumulus3d_cuda::is_available() {
65 let mut d = DenseConfig::new(make_pm_backend("cuda"), parse_profile("fast")?);
66 d.undistort.max_image_size = 160;
67 cfg.dense = Some(d);
68 }
69
70 // Hook: print event text, zone point-cloud point counts, warnings and errors; plus the default output hook (files).
71 let pipeline = Pipeline::new(Session::new(cfg))
72 .on_any(|e: &Event| {
73 if let Some(t) = e.timeline_text() {
74 println!("[event v{}] {t}", e.meta().version);
75 }
76 })
77 .on(EventKind::ZonePreview, |e: &Event| {
78 if let Event::ZonePreview { range, cloud, model, .. } = e {
79 println!(" 초벌 {}: 조밀 점 {} / 희소 점 {}", range.zone, cloud.len(), model.num_points3d());
80 }
81 })
82 .on(EventKind::ZoneRefined, |e: &Event| {
83 if let Event::ZoneRefined { range, cloud, model, .. } = e {
84 println!(" 정밀 {}: 조밀 점 {} / 희소 점 {}", range.zone, cloud.len(), model.num_points3d());
85 }
86 })
87 .on_message(|k, m| eprintln!(" {k:?}: {m}"));
88 let mut pipeline = sinks::attach(pipeline, &out, &SinkOptions::default()).map_err(|e| e.to_string())?;
89
90 for p in 0..npos {
91 pipeline.push(Input::Frames(FrameSet::new(CAMS.iter().map(|c| (*c, layout.name(c, p))))));
92 }
93 let (_, summary) = pipeline.finish();
94 println!("이벤트 {} 개, 훅 호출 {} 번, 훅 패닉 {}", summary.events, summary.hook_calls, summary.hook_panics);
95
96 for f in ["timeline.txt", "run.log", "snapshots/manifest.json", "snapshots/timeline.txt", "DONE"] {
97 let p = out.join(f);
98 println!("{} {}", if p.exists() { "있음" } else { "없음" }, p.display());
99 }
100 Ok(())
101}Sourcepub fn set_sink(&self, sink: Option<EventSink>)
pub fn set_sink(&self, sink: Option<EventSink>)
Set/clear the immediate-delivery receiver (shared by the session lineage). When set, background events accumulated so far are delivered first.
Sourcepub fn emit_external(&self, make: impl FnOnce(Meta) -> Event)
pub fn emit_external(&self, make: impl FnOnce(Meta) -> Event)
Emit an event from outside (e.g. a hook runner) in this session’s version order. If there is no receiver, it accumulates in the inbox.
Sourcepub fn advance(self, input: Input) -> (Session, Vec<Event>)
pub fn advance(self, input: Input) -> (Session, Vec<Event>)
State transition (owned version, no copying). step/poll/command/finish are thin wrappers around this.
Sourcepub fn apply(&mut self, input: Input) -> Vec<Event>
pub fn apply(&mut self, input: Input) -> Vec<Event>
In-place state transition. Returned events are in version order (events emitted by background jobs in the meantime are also inserted in place).
Sourcepub fn frames(&self) -> &[Vec<FrameImage>]
pub fn frames(&self) -> &[Vec<FrameImage>]
Frame bundle per position.
Sourcepub fn position_of(&self, name: &str) -> Option<usize>
pub fn position_of(&self, name: &str) -> Option<usize>
Position of an image name.
Sourcepub fn model(&self) -> Option<&Reconstruction>
pub fn model(&self) -> Option<&Reconstruction>
Current chain model (None before the first model).
Sourcepub fn store(&self) -> &FeatureStore
pub fn store(&self) -> &FeatureStore
Feature store.
Sourcepub fn graph(&self) -> &MatchGraph
pub fn graph(&self) -> &MatchGraph
Correspondence graph.
Sourcepub fn config(&self) -> &SessionConfig
pub fn config(&self) -> &SessionConfig
Session settings.
Sourcepub fn arrived_zones(&self) -> Vec<ZoneRange>
pub fn arrived_zones(&self) -> Vec<ZoneRange>
Zones that have arrived (been processed).
Sourcepub fn previews(&self) -> &BTreeMap<usize, PreviewZone>
pub fn previews(&self) -> &BTreeMap<usize, PreviewZone>
Per-zone preview results.
Sourcepub fn refined(&self) -> BTreeMap<usize, RefinedZone>
pub fn refined(&self) -> BTreeMap<usize, RefinedZone>
Per-zone refined results (those with finalized poses, the current value shared with background jobs).
Sourcepub fn pending_jobs(&self) -> usize
pub fn pending_jobs(&self) -> usize
Number of background refinement jobs not yet finished.
Sourcepub fn failed(&self) -> Option<&str>
pub fn failed(&self) -> Option<&str>
Fatal error (feature extraction, matching, first model failure). If set, later frames are ignored.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether Finish was handled.
Sourcepub fn lookahead(&self) -> Lookahead
pub fn lookahead(&self) -> Lookahead
Handle that starts the feature extraction of upcoming positions ahead of the position loop (see Lookahead). It is
inert unless SessionConfig::lookahead is above 0. Usable from any thread, also while the session is busy.
Trait Implementations§
Source§impl Reducer for Session
The session as a reducer driven by crate::pipeline::Pipeline. finish closes the remaining zones and waits for all background
refinement jobs.
impl Reducer for Session
The session as a reducer driven by crate::pipeline::Pipeline. finish closes the remaining zones and waits for all background
refinement jobs.
Source§fn step(&mut self, input: Input) -> Vec<Event>
fn step(&mut self, input: Input) -> Vec<Event>
Source§fn prelude(&mut self, input: &Input) -> Vec<Event>
fn prelude(&mut self, input: &Input) -> Vec<Event>
step processes it (e.g. decoded frames). Default: none.Auto Trait Implementations§
impl !RefUnwindSafe for Session
impl !UnwindSafe for Session
impl Freeze for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.