Merge pull request #2492 from AlexChambers/codex/1765-panorama-verification

LR-MERGE-PANO: report omitted photos and pair verification outcomes
This commit is contained in:
FredApps
2026-12-02 00:43:46 +01:00
committed by GitHub
18 changed files with 634 additions and 66 deletions
Generated
+1
View File
@@ -4339,6 +4339,7 @@ dependencies = [
"lightcraft-raster",
"lightcraft-raw",
"lightcraft-scenes",
"log",
"rayon",
"serde",
"thiserror 2.0.21",
+7 -2
View File
@@ -12,7 +12,7 @@ from [docs/gaps.md](docs/gaps.md). The full assessment, method and evidence are
| | Value | Kind |
|---|---:|---|
| **Feature breadth** (checklist) | **81.6%** of 532 rows (P0 98.0%, P1 95.2%, P2 50.0%) | measured: [parity-checklist.md](docs/parity-checklist.md) recount |
| **Feature breadth** (checklist) | **83.2%** of 546 rows (P0 97.5%, P1 94.2%, P2 56.7%) | measured: [parity-checklist.md](docs/parity-checklist.md) recount |
| **Feature breadth** (weighted by use) | **~77%** | estimated |
| **Ready for real work** (full target) | **~62%** (57–67%) | estimated: weighted sum over the dimensions |
| **Mainstream practitioner** | **~51%** (46–56%) | estimated |
@@ -44,7 +44,7 @@ Hours are calibrated on this repo's PR history; see
| Dimension | Ready | Breadth | Remaining | Doc |
|---|---:|---:|---:|---|
| Features | ~61% | ~77% (checklist 81.1%) | 600–1,100 h | [target-app-parity](docs/target-app-parity.md#features) |
| Features | ~61% | ~77% (checklist 83.2%) | 600–1,100 h | [target-app-parity](docs/target-app-parity.md#features) |
| ↳ RAW cameras, colour, lens profiles | ~60% | 85% of 1,446 Adobe models decode, 39% verified | 255–480 h | [raw-parity](docs/raw-parity.md) |
| UI/UX fidelity | ~70% | ~85% | 32–54 h | [ui-parity](docs/ui-parity.md) |
| File formats (non-raw) | ~70% | ~85% | 30–55 h | [file-format-parity](docs/file-format-parity.md) |
@@ -122,6 +122,10 @@ Ranked toward beta; detail in [docs/roadmap.md](docs/roadmap.md), gaps in [docs/
六切 (203 × 254), 四切 (254 × 305) and 名刺 (55 × 91) — at their exact metric sizes. The Print dialog
and `print.set` take their customary names, and names are matched case-, space- and
punctuation-insensitively (`L判`, `l`, `L-size` are one paper).
- 2026-10-21: Panorama diagnostics identify omitted source photos, including all exposures in HDR
brackets. Synthetic regressions reproduce rejected genuine transforms and show why a lower
inlier fraction alone is unsafe. Registration of the full waterfall sequence remains open (#1765).
- 2026-10-13: Canon CRW (the 2000–2004 CIFF bodies) decodes from sensor data: compression
derived clean-room against a black-box reference and frozen (`craft-libs crates/crw/clean-room/02-crw-format.md`);
EOS D30/D60/10D/300D and PowerShot G1/G6 verified pixel-exact on 28 of 29 corpus files (18 of
@@ -205,6 +209,7 @@ Ranked toward beta; detail in [docs/roadmap.md](docs/roadmap.md), gaps in [docs/
| 2026-10-22 | minor | Print: Japanese photo and postcard paper sizes (L判, 2L判, KG判, はがき, 往復はがき, 六切, 四切, 名刺) in the page setup, Print dialog and PDF output; headline numbers unchanged |
| 2026-10-22 | minor | Tone Curve input histogram (#987); headline counts and readiness estimates unchanged. See [the stage contract](docs/tone-curve-input.md). |
| 2026-10-19 | minor | Indonesian interface (`id`): every plain and formats message, plus 69 command labels, locale, menu command and tests; What's New left in English; Localization ~55% → ~64% (mean of the 12 key languages), 8 of 12 present |
| 2026-10-21 | minor | Panorama and HDR panorama marked partial (#1765): omitted photos are reported; verification remains unresolved. Checklist recount 83.5% to 83.3% (543 rows); refreshed the stale headline from the checklist. Readiness estimates unchanged |
| 2026-10-13 | minor | Canon CRW decoded (clean-room): 6 bodies verified pixel-exact, G5 preview; 551 models verified after merging the coverage sweep |
| 2026-10-12 | minor | Italian interface (`it`, #1192): 2,201 of 2,398 messages, locale, menu command and tests; headline numbers unchanged |
| 2026-10-13 | minor | Sony ILCA-99M2 camera colour profile in the log; numbers unchanged |
+61 -6
View File
@@ -154,7 +154,7 @@ impl MergeJob {
let p = sub(0.25, 0.9);
let fit = fit_in_memory(pano, pixels(&frames), crate::memory::total_ram());
let r = lightcraft_merge::stitch(frames, &fit, &p).map_err(err)?;
let info = pano_info(&r, &self.sources, pano, &fit);
let info = pano_info(&r, &self.sources, 1, pano, &fit);
(
r.image,
r.color,
@@ -199,7 +199,7 @@ impl MergeJob {
let p = sub(0.6, 0.9);
let fit = fit_in_memory(pano, pixels(&merged), crate::memory::total_ram());
let r = lightcraft_merge::stitch(merged, &fit, &p).map_err(err)?;
let mut info = pano_info(&r, &self.sources, pano, &fit);
let mut info = pano_info(&r, &self.sources, b, pano, &fit);
info["bracket"] = json!(b);
(
r.image,
@@ -239,7 +239,7 @@ impl MergeJob {
/// `asked` is what the command asked for, `fit` what ran (held to memory): when the panorama came
/// out smaller than the photos' own resolution, `limit` says why (`memory`, `size`: Lightroom's
/// 512 MP / 65,000 px, or `asked`).
fn pano_info(r: &lightcraft_merge::PanoResult, sources: &[(PhotoId, String)], asked: &PanoOptions, fit: &PanoOptions) -> Value {
fn pano_info(r: &lightcraft_merge::PanoResult, sources: &[(PhotoId, String)], bracket: usize, asked: &PanoOptions, fit: &PanoOptions) -> Value {
let megapixels = (r.image.width * r.image.height) as f64 / 1e6;
let native = r.native_megapixels;
let why = if fit.max_megapixels < asked.max_megapixels && fit.max_megapixels < native {
@@ -250,9 +250,9 @@ fn pano_info(r: &lightcraft_merge::PanoResult, sources: &[(PhotoId, String)], as
"size"
};
let limit = (megapixels < native * 0.98).then_some(why);
json!({
let mut info = pano_source_info(&r.used, &r.pairs, sources, bracket);
let geometry = json!({
"projection": r.projection,
"used": r.used.iter().filter_map(|&i| sources.get(i).map(|s| s.0.0)).collect::<Vec<_>>(),
"fov": [r.fov.0, r.fov.1],
"rmsPx": r.rms,
"gains": r.gains,
@@ -260,7 +260,43 @@ fn pano_info(r: &lightcraft_merge::PanoResult, sources: &[(PhotoId, String)], as
"megapixels": megapixels,
"nativeMegapixels": native,
"limit": limit,
})
});
if let (Some(info), Some(geometry)) = (info.as_object_mut(), geometry.as_object()) {
info.extend(geometry.clone());
}
info
}
/// Stitch indices refer to frames (HDR brackets), while callers need individual source IDs.
/// Keep source order and report only the observed outcome, not an inferred scene cause.
fn pano_source_info(
used_frames: &[usize],
pairs: &[lightcraft_merge::pano::camera::PairDiagnostic],
sources: &[(PhotoId, String)],
bracket: usize,
) -> Value {
let bracket = bracket.max(1);
let mut used = Vec::new();
let mut omitted = Vec::new();
for (i, (id, path)) in sources.iter().enumerate() {
if used_frames.contains(&(i / bracket)) {
used.push(id.0);
} else {
omitted.push(json!({"id": id.0, "path": path, "reason": "notRegistered"}));
}
}
let ids = |i: usize| sources.chunks(bracket).nth(i).unwrap_or_default().iter().map(|s| s.0.0).collect::<Vec<_>>();
let pairs: Vec<Value> = pairs
.iter()
.map(|p| {
json!({
"a": ids(p.i), "b": ids(p.j), "matches": p.matches, "inliers": p.inliers, "status": p.status,
})
})
.collect();
let frames = sources.len().div_ceil(bracket);
let total_pairs = frames.saturating_mul(frames.saturating_sub(1)) / 2;
json!({"used": used, "omitted": omitted, "pairs": pairs, "pairsTruncated": pairs.len() < total_pairs})
}
/// Peak memory of a panorama per pixel of its output (bytes), measured as the peak resident size
@@ -517,3 +553,22 @@ impl Session {
self.finish_merge(&job, out)
}
}
#[cfg(test)]
mod inclusion_tests {
use super::*;
#[test]
fn source_ids_keep_their_order_across_nonconsecutive_brackets() {
let sources = [71, 9, 401, 3, 6, 12].map(|id| (PhotoId(id), format!("{id}.png")));
let info = pano_source_info(&[2, 0], &[], &sources, 2);
assert_eq!(info["used"], json!([71, 9, 6, 12]));
assert_eq!(
info["omitted"],
json!([
{"id": 401, "path": "401.png", "reason": "notRegistered"},
{"id": 3, "path": "3.png", "reason": "notRegistered"},
])
);
}
}
+50
View File
@@ -237,6 +237,56 @@ fn panorama_command_with_auto_crop() {
let _ = std::fs::remove_dir_all(&dir);
}
/// Issue #1765: keep source IDs and order, including every exposure of an HDR position.
/// The first position has no features. The other two overlap. Check preview and final output.
#[test]
fn panorama_reports_omitted_source_photos() {
for bracket in [1, 2] {
let dir = temp_dir(&format!("1765-{bracket}"));
let mut images = vec![lightcraft_raster::Rgb32f::from_fn(400, 300, |_, _| [0.2; 3])];
images.extend(lightcraft_merge::synth::pano_views(400, 300, 350.0, &[-15.0, 15.0]).unwrap());
let mut paths = Vec::new();
for (i, image) in images.iter().enumerate() {
for exposure in 0..bracket {
let img = image.map(|p| p.map(|v| v * (1.0 + exposure as f32 * 0.1))).to_srgb8();
let png = lightcraft_codecs::encode_png(&lightcraft_codecs::EncodeImage::rgba8(&img), &Default::default()).unwrap();
let path = dir.join(format!("position-{i}-exposure-{exposure}.png"));
std::fs::write(&path, png).unwrap();
paths.push(path.to_string_lossy().to_string());
}
}
if let Ok(dump) = std::env::var("LC_MERGE_DUMP") {
let dest = std::path::Path::new(&dump).join(format!("1765-{bracket}"));
std::fs::create_dir_all(&dest).unwrap();
for path in &paths {
std::fs::copy(path, dest.join(std::path::Path::new(path).file_name().unwrap())).unwrap();
}
}
let mut s = Session::new().with_fs();
let ids = import(&mut s, paths.clone());
let cmd = if bracket == 1 { "merge.panorama" } else { "merge.hdrPanorama" };
for preview in [true, false] {
let r = s.execute(cmd, &json!({"ids": ids, "bracket": bracket, "align": false, "autoSettings": false, "preview": preview})).unwrap();
assert_eq!(r["used"], json!(ids[bracket..]), "{r}");
let omitted = r["omitted"].as_array().expect("explicit omitted photos");
assert_eq!(omitted.len(), bracket);
for (i, entry) in omitted.iter().enumerate() {
assert_eq!(entry["id"], ids[i]);
assert_eq!(entry["path"], paths[i]);
assert_eq!(entry["reason"], "notRegistered");
}
let pairs = r["pairs"].as_array().expect("pair verification diagnostics");
assert_eq!(r["pairsTruncated"], false);
assert_eq!(pairs.len(), 3);
assert_eq!(pairs[0]["a"], json!(ids[..bracket]));
assert_eq!(pairs[0]["b"], json!(ids[bracket..2 * bracket]));
assert_eq!(pairs[0]["status"], "insufficientMatches");
assert_eq!(pairs[2]["status"], "accepted");
}
let _ = std::fs::remove_dir_all(&dir);
}
}
/// HDR for Each Bracket Set: two stacks of brackets → two merged DNGs, each next to its first photo; photos that form
/// no set are refused.
#[test]
+1
View File
@@ -19,3 +19,4 @@ lightcraft-scenes = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
rayon = { workspace = true }
log = { workspace = true }
+14 -5
View File
@@ -72,8 +72,10 @@ pub struct PanoResult {
pub crop: Option<[f64; 4]>,
/// The projection used (never `Auto`).
pub projection: Projection,
/// Indices (into the inputs) of the frames in the panorama; the others didn't connect.
/// Indices (into the inputs) of the frames with recovered cameras in this panorama.
pub used: Vec<usize>,
/// Measurements for the first [`camera::MAX_PAIR_DIAGNOSTICS`] input pairs, including rejected pairs.
pub pairs: Vec<camera::PairDiagnostic>,
/// Cameras of the inputs (`None` = not used), in their full-resolution pixels, straightened.
pub cameras: Vec<Option<Camera>>,
/// Per-input exposure gains applied.
@@ -176,6 +178,11 @@ struct Tile {
/// Register the frames: cameras for the connected set.
pub fn register(frames: &[Frame], progress: &Progress) -> Result<(Vec<Option<Camera>>, f64, f64)> {
let (cameras, before, after, _) = register_impl(frames, progress, false)?;
Ok((cameras, before, after))
}
fn register_impl(frames: &[Frame], progress: &Progress, report_pairs: bool) -> Result<(Vec<Option<Camera>>, f64, f64, Vec<camera::PairDiagnostic>)> {
let n = frames.len();
let work: Vec<(crate::features::Features, f64)> = frames
.par_iter()
@@ -188,10 +195,11 @@ pub fn register(frames: &[Frame], progress: &Progress) -> Result<(Vec<Option<Cam
check(progress, 0.2, "Matching")?;
let feats: Vec<_> = work.iter().map(|(f, _)| f.clone()).collect();
let scales: Vec<f64> = work.iter().map(|(_, s)| *s).collect();
let pairs = camera::match_pairs(&feats, &scales);
let (pairs, diagnostics) =
if report_pairs { camera::match_pairs_with_diagnostics(&feats, &scales) } else { (camera::match_pairs(&feats, &scales), Vec::new()) };
let ids = camera::largest_component(n, &pairs);
if ids.len() < 2 {
return Err(MergeError::NoOverlap("the photos don't overlap enough to be stitched".into()));
return Err(MergeError::NoOverlap("could not align at least two photos for a panorama".into()));
}
check(progress, 0.3, "Aligning")?;
// focal length: EXIF 35 mm equivalent, else the homographies, else ~50° horizontal
@@ -220,7 +228,7 @@ pub fn register(frames: &[Frame], progress: &Progress) -> Result<(Vec<Option<Cam
let adj = camera::bundle_adjust(&cams, &pairs, anchor, 60);
let mut cams = adj.cameras;
camera::straighten(&mut cams);
Ok((cams, adj.rms_before, adj.rms))
Ok((cams, adj.rms_before, adj.rms, diagnostics))
}
/// A frame's focal length in pixels, from EXIF's 35 mm equivalent.
@@ -239,7 +247,7 @@ pub fn stitch(mut frames: Vec<Frame>, opts: &PanoOptions, progress: &Progress) -
return Err(MergeError::TooMany(n, MAX_FRAMES));
}
check(progress, 0.01, "Finding features")?;
let (cams, rms_before, rms) = register(&frames, progress)?;
let (cams, rms_before, rms, pairs) = register_impl(&frames, progress, true)?;
let used: Vec<usize> = (0..n).filter(|&i| cams[i].is_some()).collect();
let fov = fov(&frames, &cams);
let projection = match opts.projection {
@@ -408,6 +416,7 @@ pub fn stitch(mut frames: Vec<Frame>, opts: &PanoOptions, progress: &Progress) -
crop,
projection,
used,
pairs,
cameras: cams,
gains,
rms_before,
+95 -28
View File
@@ -58,37 +58,104 @@ pub struct PairMatch {
pub levels: Vec<u8>,
}
/// Why a pair did or did not pass registration verification. This is not a scene diagnosis.
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub enum PairStatus {
InsufficientMatches,
NoModel,
Rejected,
Accepted,
}
/// Verification measurements at the working resolution (long edge at most 1000 pixels).
#[derive(Clone, Debug, serde::Serialize)]
pub struct PairDiagnostic {
pub i: usize,
pub j: usize,
pub matches: usize,
/// Unknown when RANSAC could not return a model with at least 12 inliers.
pub inliers: Option<usize>,
pub status: PairStatus,
}
/// Maximum pair records returned with a stitch. Full measurements are available in debug logs.
pub const MAX_PAIR_DIAGNOSTICS: usize = 1024;
/// Generate pairs lazily so comparing frames with no usable features needs no quadratic storage.
fn input_pairs(n: usize) -> impl ParallelIterator<Item = (usize, usize)> {
(0..n).into_par_iter().flat_map_iter(move |i| ((i + 1)..n).map(move |j| (i, j)))
}
/// Match every pair of images. `feats[k]` are in work coordinates scaled by `scales[k]`.
pub fn match_pairs(feats: &[Features], scales: &[f64]) -> Vec<PairMatch> {
let mut pairs: Vec<_> = input_pairs(feats.len()).filter_map(|(i, j)| match_pair(feats, scales, i, j, |_, _, _| {})).collect();
pairs.sort_unstable_by_key(|p| (p.i, p.j));
pairs
}
/// As [`match_pairs`], with measurements for the first [`MAX_PAIR_DIAGNOSTICS`] pairs in input
/// order. All comparisons still run and any additional outcomes appear only in the debug log.
pub fn match_pairs_with_diagnostics(feats: &[Features], scales: &[f64]) -> (Vec<PairMatch>, Vec<PairDiagnostic>) {
let n = feats.len();
// the pairs are generated lazily: materialising all n(n−1)/2 up front is quadratic memory, including
// when every comparison comes up empty (no usable features)
let mut out: Vec<PairMatch> = (0..n)
.into_par_iter()
.flat_map_iter(|i| ((i + 1)..n).map(move |j| (i, j)))
.filter_map(|(i, j)| {
let m = features::match_features(&feats[i], &feats[j], 0.8);
if m.len() < 12 {
return None;
}
let a: Vec<Point> = m.iter().map(|(p, _)| Point::new(feats[i].points[*p].x as f64, feats[i].points[*p].y as f64)).collect();
let b: Vec<Point> = m.iter().map(|(_, q)| Point::new(feats[j].points[*q].x as f64, feats[j].points[*q].y as f64)).collect();
let fit = ransac::ransac(Model::Homography, &a, &b, 3.0, 12, (i * 1000 + j) as u64)?;
// Brown & Lowe's probabilistic verification
if (fit.inliers.len() as f64) <= 8.0 + 0.3 * m.len() as f64 {
return None;
}
let (si, sj) = (scales[i], scales[j]);
let pts = fit.inliers.iter().map(|&k| (Point::new(a[k].x / si, a[k].y / si), Point::new(b[k].x / sj, b[k].y / sj))).collect();
let levels = fit.inliers.iter().map(|&k| feats[i].points[m[k].0].level.max(feats[j].points[m[k].1].level)).collect();
// conjugate to full resolution: H_full = S_j⁻¹ · H · S_i
let s_i = Homography([si, 0.0, 0.0, 0.0, si, 0.0, 0.0, 0.0, 1.0]);
let s_j_inv = Homography([1.0 / sj, 0.0, 0.0, 0.0, 1.0 / sj, 0.0, 0.0, 0.0, 1.0]);
Some(PairMatch { i, j, h: s_j_inv.mul(&fit.h).mul(&s_i), pts, levels })
})
.collect();
out.sort_by_key(|p| (p.i, p.j));
out
let (mut pairs, mut diagnostics) = input_pairs(n)
.fold(
|| (Vec::new(), Vec::new()),
|(mut pairs, mut diagnostics), (i, j)| {
pairs.extend(match_pair(feats, scales, i, j, |matches, inliers, status| {
log::debug!("panorama pair {i}-{j}: matches={matches}, inliers={inliers:?}, status={status:?}");
// The preceding rows have n-1, n-2, …, n-i pairs. A row with
// i >= the cap cannot contribute because each preceding row has a pair.
if i < MAX_PAIR_DIAGNOSTICS {
let preceding = i.saturating_mul(n - 1).saturating_sub(i * i.saturating_sub(1) / 2);
if preceding.saturating_add(j - i - 1) < MAX_PAIR_DIAGNOSTICS {
diagnostics.push(PairDiagnostic { i, j, matches, inliers, status });
}
}
}));
(pairs, diagnostics)
},
)
.reduce(
|| (Vec::new(), Vec::new()),
|(mut pairs, mut diagnostics), (right_pairs, right_diagnostics)| {
pairs.extend(right_pairs);
diagnostics.extend(right_diagnostics);
(pairs, diagnostics)
},
);
pairs.sort_unstable_by_key(|p| (p.i, p.j));
diagnostics.sort_unstable_by_key(|d| (d.i, d.j));
(pairs, diagnostics)
}
fn match_pair(feats: &[Features], scales: &[f64], i: usize, j: usize, report: impl FnOnce(usize, Option<usize>, PairStatus)) -> Option<PairMatch> {
let m = features::match_features(&feats[i], &feats[j], 0.8);
if m.len() < 12 {
report(m.len(), None, PairStatus::InsufficientMatches);
return None;
}
let a: Vec<Point> = m.iter().map(|(p, _)| Point::new(feats[i].points[*p].x as f64, feats[i].points[*p].y as f64)).collect();
let b: Vec<Point> = m.iter().map(|(_, q)| Point::new(feats[j].points[*q].x as f64, feats[j].points[*q].y as f64)).collect();
let Some(fit) = ransac::ransac(Model::Homography, &a, &b, 3.0, 12, (i * 1000 + j) as u64) else {
report(m.len(), None, PairStatus::NoModel);
return None;
};
let inliers = fit.inliers.len();
// Brown & Lowe's probabilistic verification. Issue #1765 demonstrates false
// negatives here, but lowering only the slope also admits coherent wrong matches.
if (inliers as f64) <= 8.0 + 0.3 * m.len() as f64 {
report(m.len(), Some(inliers), PairStatus::Rejected);
return None;
}
report(m.len(), Some(inliers), PairStatus::Accepted);
let (si, sj) = (scales[i], scales[j]);
let pts = fit.inliers.iter().map(|&k| (Point::new(a[k].x / si, a[k].y / si), Point::new(b[k].x / sj, b[k].y / sj))).collect();
let levels = fit.inliers.iter().map(|&k| feats[i].points[m[k].0].level.max(feats[j].points[m[k].1].level)).collect();
// conjugate to full resolution: H_full = S_j⁻¹ · H · S_i
let s_i = Homography([si, 0.0, 0.0, 0.0, si, 0.0, 0.0, 0.0, 1.0]);
let s_j_inv = Homography([1.0 / sj, 0.0, 0.0, 0.0, 1.0 / sj, 0.0, 0.0, 0.0, 1.0]);
Some(PairMatch { i, j, h: s_j_inv.mul(&fit.h).mul(&s_i), pts, levels })
}
/// The largest connected component of the match graph (sorted image indices).
+26
View File
@@ -258,6 +258,32 @@ fn a_stitch_of_more_than_the_frame_cap_is_refused_up_front() {
assert!(err.to_string().contains("refused"), "the frame cap errors, it does not begin the quadratic match: {err}");
}
#[test]
fn moving_texture_registration_remains_conservative() {
let e = env();
let rs: Vec<M3> = [-22.0, 0.0, 21.0].into_iter().map(|yaw| rot(yaw, 0.0, 0.0)).collect();
let clean: Vec<Frame> = rs.iter().map(|r| shoot(&e, r, 800.0, 800, 600, 1.0)).collect();
let (cameras, _, rms) = lightcraft_merge::pano::register(&clean, &no_progress).unwrap();
assert_eq!(cameras.iter().flatten().count(), 3);
eprintln!("three clean frames: used=3, rms={rms:.4}");
let mut moving = clean;
for (i, frame) in moving.iter_mut().enumerate() {
// An original textured band changes independently between exposures. Keep the
// surrounding scene fixed to the known cameras. This is not a waterfall model.
let mut rng = lightcraft_merge::ransac::Rng::new(1765 + i as u64);
let cells: Vec<f32> = (0..80 * 36).map(|_| rng.unit() as f32).collect();
for y in 120..480 {
for x in 0..800 {
let v = cells[(y - 120) / 10 * 80 + x / 10] * 0.7 + 0.1;
frame.image.set(x, y, [v; 3]);
}
}
}
let result = lightcraft_merge::pano::register(&moving, &no_progress);
eprintln!("three moving-texture frames: {result:?}");
assert!(matches!(result, Err(lightcraft_merge::MergeError::NoOverlap(_))));
}
/// Issue #1455: a panorama came out at 40 MP whatever its photos' resolution. It now keeps their
/// own resolution unless a size is asked for (up to Lightroom's 512 MP); a size scales it down,
/// and a NaN one (from an agent) is no size at all, not a 0.1 MP thumbnail.
+143
View File
@@ -0,0 +1,143 @@
//! Issue #1765: deterministic correspondences isolate verification from feature detection.
//! These are original procedural fixtures, not the reporter's waterfall photos.
use lightcraft_geom::{Homography, Point};
use lightcraft_merge::features::{Features, Keypoint, match_features};
use lightcraft_merge::pano::camera::match_pairs;
use lightcraft_merge::ransac::{Model, Rng, ransac};
fn correspondences(n: usize, inliers: usize, seed: u64, h: Homography) -> [Features; 2] {
let mut rng = Rng::new(seed);
let mut a = Features::default();
let mut b = Features::default();
for k in 0..n {
let p = Point::new(80.0 + rng.unit() * 640.0, 60.0 + rng.unit() * 480.0);
let q = if k < inliers { h.apply(p) } else { Point::new(rng.unit() * 800.0, rng.unit() * 600.0) };
let desc = std::array::from_fn(|_| rng.unit() as f32);
for (f, p) in [(&mut a, p), (&mut b, q)] {
f.points.push(Keypoint { x: p.x as f32, y: p.y as f32, level: 0, angle: 0.0, strength: 1.0 });
f.desc.push(desc);
}
}
[a, b]
}
fn fit(f: &[Features; 2]) -> Option<lightcraft_merge::ransac::Fit> {
let matches = match_features(&f[0], &f[1], 0.8);
assert_eq!(matches.len(), f[0].len());
let points = |side: usize| -> Vec<Point> {
matches
.iter()
.map(|&(i, j)| {
let p = f[side].points[if side == 0 { i } else { j }];
Point::new(p.x as f64, p.y as f64)
})
.collect()
};
ransac(Model::Homography, &points(0), &points(1), 3.0, 12, 1)
}
#[test]
fn moving_scene_regime_is_rejected_despite_a_recovered_homography() {
let h = Homography([1.0, 0.01, 23.0, -0.01, 1.0, 7.0, 0.00001, -0.00002, 1.0]);
for (n, inliers) in [(104, 31), (136, 36), (100, 30), (140, 30)] {
let f = correspondences(n, inliers, 1765, h);
let recovered = fit(&f).expect("RANSAC recovers the known transform");
assert!(recovered.rms < 0.001);
for p in [Point::new(100.0, 100.0), Point::new(700.0, 500.0)] {
assert!(lightcraft_merge::ransac::transfer_error2(&recovered.h, p, h.apply(p)) < 0.001);
}
// Keep the conservative gate until a policy distinguishes this from a coherent moving
// object or a repeated patch. Lowering only the fraction does not establish that.
assert!(match_pairs(&f, &[1.0; 2]).is_empty());
assert!(recovered.inliers.len() as f64 > 8.0 + 0.15 * n as f64, "the proposed lower slope admits it");
}
}
#[test]
fn a_repeated_patch_can_pass_the_lower_slope_with_the_wrong_camera_motion() {
// A copied, textured panel covers the image: 36 distinctive features agree with a false
// 160 px translation. All other correspondences disagree. Spatial spread cannot tell a
// repeated panel from static scene support using these observations alone.
let false_motion = Homography([1.0, 0.0, 160.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]);
let f = correspondences(136, 36, 1765, false_motion);
let r = fit(&f).unwrap();
eprintln!("repeated panel: {}/136, rms={:.6}, lower slope accepts=true", r.inliers.len(), r.rms);
assert!(r.rms < 0.001);
assert!(r.inliers.len() as f64 > 8.0 + 0.15 * 136.0);
assert!(match_pairs(&f, &[1.0; 2]).is_empty());
}
#[test]
fn unrelated_low_overlap_duplicates_and_ambiguous_descriptors() {
let h = Homography([1.0, 0.0, 30.0, 0.0, 1.0, 12.0, 0.0, 0.0, 1.0]);
for seed in 1..=8 {
for inliers in [0, 8] {
let f = correspondences(120, inliers, seed, h);
assert!(match_pairs(&f, &[1.0; 2]).is_empty(), "seed {seed}, {inliers} inliers");
}
}
let identity = Homography([1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]);
let mut f = correspondences(100, 100, 1765, identity);
assert_eq!(match_pairs(&f, &[1.0; 2]).len(), 1, "duplicates remain one verified pair");
for side in &mut f {
side.desc.fill([1.0; 64]);
}
assert!(match_pairs(&f, &[1.0; 2]).is_empty(), "identical repeating descriptors are ambiguous");
}
#[test]
fn translated_camera_with_multiple_depths_does_not_establish_a_panorama() {
// Pinhole cameras with f=800, translated horizontally by 0.2 world units. Points
// span depths 1..5, so their parallax is 32..160 px and no rotation explains them.
let identity = Homography([1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]);
let mut f = correspondences(136, 136, 1765, identity);
let mut rng = Rng::new(987);
for p in &mut f[1].points {
p.x -= (160.0 / (1.0 + 4.0 * rng.unit())) as f32;
}
let r = fit(&f);
eprintln!(
"translated camera, varying depths: fit={:?}, accepted={}",
r.as_ref().map(|r| (r.inliers.len(), r.rms)),
!match_pairs(&f, &[1.0; 2]).is_empty()
);
assert!(match_pairs(&f, &[1.0; 2]).is_empty());
assert!(r.unwrap().inliers.len() as f64 > 8.0 + 0.15 * 136.0, "the lower slope accepts genuine parallax");
}
#[test]
fn diagnostics_keep_rejected_and_unmatched_pairs_in_input_order() {
use lightcraft_merge::pano::camera::{PairStatus, match_pairs_with_diagnostics};
let h = Homography([1.0, 0.0, 23.0, 0.0, 1.0, 7.0, 0.0, 0.0, 1.0]);
let [a, b] = correspondences(104, 31, 1765, h);
let (pairs, diagnostics) = match_pairs_with_diagnostics(&[a, b, Features::default()], &[1.0; 3]);
assert!(pairs.is_empty());
assert_eq!(diagnostics.iter().map(|d| (d.i, d.j)).collect::<Vec<_>>(), [(0, 1), (0, 2), (1, 2)]);
let rejected = &diagnostics[0];
assert_eq!(rejected.status, PairStatus::Rejected);
assert!(rejected.inliers.is_some_and(|n| (n as f64) <= 8.0 + 0.3 * rejected.matches as f64));
assert_eq!((diagnostics[1].matches, diagnostics[1].inliers, diagnostics[1].status), (0, None, PairStatus::InsufficientMatches));
let f = correspondences(120, 0, 1, h);
let (_, diagnostics) = match_pairs_with_diagnostics(&f, &[1.0; 2]);
assert_eq!((diagnostics[0].inliers, diagnostics[0].status), (None, PairStatus::NoModel));
}
#[test]
fn diagnostics_are_bounded_without_skipping_late_matches() {
use lightcraft_merge::pano::{
MAX_FRAMES,
camera::{MAX_PAIR_DIAGNOSTICS, PairMatch, match_pairs_with_diagnostics},
};
let mut features = vec![Features::default(); MAX_FRAMES - 2];
let identity = Homography([1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]);
features.extend(correspondences(32, 32, 1765, identity));
let scales = vec![1.0; features.len()];
let (matches, diagnostics) = match_pairs_with_diagnostics(&features, &scales);
let expected = (0..features.len()).flat_map(|i| ((i + 1)..features.len()).map(move |j| (i, j)));
assert!(diagnostics.iter().map(|d| (d.i, d.j)).eq(expected.take(MAX_PAIR_DIAGNOSTICS)));
let indices = |pairs: &[PairMatch]| pairs.iter().map(|p| (p.i, p.j)).collect::<Vec<_>>();
assert_eq!(indices(&matches), [(features.len() - 2, features.len() - 1)]);
assert_eq!(indices(&matches), indices(&match_pairs(&features, &scales)));
}
+3
View File
@@ -482,6 +482,7 @@ fn dialog_title(app: &LightcraftApp, dlg: &Dialog) -> String {
Dialog::SlideshowExport { .. } => "Export Slideshow",
Dialog::Print => "Print",
Dialog::Merge { opts } => opts.title(),
Dialog::MergeResult { .. } => "Photo Merge Result",
Dialog::Settings { .. } => "Settings",
Dialog::ConfirmDelete { .. } => "Delete Photos",
Dialog::MovePhotos { .. } => "Move Photos",
@@ -629,6 +630,7 @@ fn fixed_ok_label(app: &LightcraftApp, dlg: &Dialog, informational: bool) -> &'s
| Dialog::WhatsNew
| Dialog::ManageEffects { .. }
| Dialog::ViewOptions
| Dialog::MergeResult { .. }
| Dialog::LightroomResult { .. }
| Dialog::DenoiseModel { .. }
| Dialog::FaceModel { .. } => "Close",
@@ -2228,6 +2230,7 @@ fn dialog_content(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, body_m
Dialog::ContactSheet { .. } => contact_sheet_body(app, ui, dlg),
Dialog::Export { .. } => export_body(app, ui, t, dlg),
Dialog::Merge { opts } => crate::merge::body(app, ui, opts),
Dialog::MergeResult { summary, omitted } => crate::merge::result_body(ui, summary, omitted),
Dialog::Import { opts } => crate::import::body(app, ui, opts),
// (Settings is never taller than `body_max`, so the scroll area round it never
// scrolls: its tab bar stays put and its pages scroll by themselves)
+6 -3
View File
@@ -263,8 +263,11 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result<serde_jso
Dialog::DeleteEffects { names } => app.run("mask.deleteEffect", json!({"names": names})),
Dialog::RemoveFolder { path, disk, .. } => app.run("library.removeFolder", json!({"path": path, "disk": disk})),
d @ Dialog::SynchronizeFolder { .. } => crate::sync::confirm(app, d),
Dialog::About | Dialog::Shortcuts | Dialog::Settings { .. } | Dialog::ManageEffects { .. } | Dialog::ViewOptions => {
Ok(serde_json::Value::Null)
}
Dialog::About
| Dialog::Shortcuts
| Dialog::Settings { .. }
| Dialog::ManageEffects { .. }
| Dialog::ViewOptions
| Dialog::MergeResult { .. } => Ok(serde_json::Value::Null),
}
}
+1
View File
@@ -277,5 +277,6 @@ pub(super) fn only_shows(dlg: &Dialog) -> bool {
| Dialog::Welcome { .. }
| Dialog::ManageEffects { .. }
| Dialog::ViewOptions
| Dialog::MergeResult { .. }
) || matches!(dlg, Dialog::SynchronizeFolder { counts: Some(c), .. } if c.up_to_date())
}
+104 -19
View File
@@ -116,6 +116,8 @@ pub struct MergeState {
pub ids: Vec<PhotoId>,
/// HDR for Each Bracket Set: the sets still to merge after the running one.
pub batch: std::collections::VecDeque<Vec<PhotoId>>,
/// A finished panorama's list of omitted photos, waiting for the dialog open when it finished to close.
pub pending_result: Option<crate::state::Dialog>,
}
impl MergeState {
@@ -160,22 +162,28 @@ pub fn last_options(app: &LightcraftApp, command: &str) -> MergeDialog {
MergeDialog { command: command.into(), ..saved.unwrap_or_default() }
}
/// Open the merge dialog for the selection, with the options of the last merge of this kind.
pub fn open(app: &mut LightcraftApp, command: &str) -> Result<Value, String> {
let ids = app.session.selected();
if ids.len() < 2 {
return Err("select at least 2 photos to merge".into());
}
/// Set the photos the dialog merges. A preview of other photos is dropped and its task cancelled: the dialog compares
/// a preview's options only, so it would go on describing the photos it was made from.
fn set_ids(app: &mut LightcraftApp, ids: Vec<PhotoId>) {
app.merge.ids = ids;
app.merge.error = None;
// a preview that failed before is tried again, or the dialog would show neither a preview nor its error (#2708)
app.merge.failed_options = None;
app.merge.preview = None;
app.merge.preview_pixels = None;
app.merge.zoom = None;
if let Some(t) = app.merge.preview_task.take() {
t.cancel.store(true, Ordering::Relaxed);
}
}
/// Open the merge dialog for the selection, with the options of the last merge of this kind.
pub fn open(app: &mut LightcraftApp, command: &str) -> Result<Value, String> {
let ids = app.session.selected();
if ids.len() < 2 {
return Err("select at least 2 photos to merge".into());
}
set_ids(app, ids);
app.merge.error = None;
// a preview that failed before is tried again, or the dialog would show neither a preview nor its error (#2708)
app.merge.failed_options = None;
app.ui.dialog = Some(crate::state::Dialog::Merge { opts: last_options(app, command) });
Ok(json!({"photos": app.merge.ids.len()}))
}
@@ -209,7 +217,7 @@ pub fn start_last(app: &mut LightcraftApp, command: &str) -> Result<Value, Strin
if ids.len() < 2 {
return Err("select at least 2 photos to merge".into());
}
app.merge.ids = ids;
set_ids(app, ids);
let opts = last_options(app, command);
start_final(app, &opts)
}
@@ -234,7 +242,7 @@ pub fn start_batch(app: &mut LightcraftApp, p: &Value) -> Result<Value, String>
/// Start the next bracket set of a batch, if any.
fn next_in_batch(app: &mut LightcraftApp) -> Result<(), String> {
let Some(ids) = app.merge.batch.pop_front() else { return Ok(()) };
app.merge.ids = ids;
set_ids(app, ids);
let opts = last_options(app, "merge.hdr");
start_final(app, &opts).map(|_| ())
}
@@ -313,11 +321,7 @@ pub fn poll(app: &mut LightcraftApp, ctx: &egui::Context) {
"HDR"
});
match r.map_err(lightcraft_engine::EngineError::Other).and_then(|out| app.session.finish_merge(&t.job, out)) {
Ok(v) => {
let message = added_message(what, &v);
app.merge.last_result = Some(v);
app.toast(ctx, message);
}
Ok(v) => finished(app, ctx, what, v),
Err(_) if t.cancel.load(Ordering::Relaxed) => {
// cancelling one merge of a batch stops the batch
app.merge.batch.clear();
@@ -347,13 +351,47 @@ pub fn poll(app: &mut LightcraftApp, ctx: &egui::Context) {
}
}
}
// (never over a dialog the user has open: it waits until that one closes)
if app.ui.dialog.is_none()
&& let Some(dialog) = app.merge.pending_result.take()
{
app.ui.dialog = Some(dialog);
}
}
/// A merge finished and was added (`what`: "Panorama", …; `info`: its result): say so, and when it left photos out,
/// name them in a dialog that stays until closed (shown by [`poll`] once no other dialog is open).
pub(crate) fn finished(app: &mut LightcraftApp, ctx: &egui::Context, what: &str, info: Value) {
let message = added_message(what, &info);
if let Some(dialog) = result_dialog(&message, &info) {
app.merge.pending_result = Some(dialog);
}
app.merge.last_result = Some(info);
app.toast(ctx, message);
}
/// The dialog that names the photos a finished panorama left out, from that result's own source paths (the
/// preview registered smaller copies, so it can leave out other photos). `None` when it left none out.
fn result_dialog(message: &str, info: &Value) -> Option<crate::state::Dialog> {
let omitted: Vec<String> = info["omitted"].as_array()?.iter().filter_map(|p| p["path"].as_str().map(str::to_string)).collect();
(!omitted.is_empty()).then(|| crate::state::Dialog::MergeResult { summary: message.to_string(), omitted })
}
/// The body of the result dialog: the completion message (a live region: the dialog opens when a background merge
/// finishes, away from where the user is) and the omitted files' names.
pub fn result_body(ui: &mut egui::Ui, summary: &str, omitted: &[String]) {
let t = crate::theme::Tokens::get(ui.ctx());
let r = ui.add(egui::Label::new(egui::RichText::new(summary).strong().color(t.caution)).wrap());
ui.ctx().accesskit_node_builder(r.id, |node| node.set_live(egui::accesskit::Live::Polite));
ui.label(crate::i18n::tr("LightCraft could not align these photos with the included set, so the panorama leaves them out."));
omitted_names(ui, omitted.iter().map(String::as_str));
}
/// The message for a finished merge (`what`: "Panorama", …; `info`: its result): a panorama
/// smaller than its photos' resolution says why (issue #1455).
fn added_message(what: &str, info: &Value) -> String {
let size = |k: &str| info[k].as_f64().map(|mp| format!("{mp:.0} MP"));
match (info["limit"].as_str(), size("megapixels"), size("nativeMegapixels")) {
let message = match (info["limit"].as_str(), size("megapixels"), size("nativeMegapixels")) {
(Some("memory"), Some(mp), Some(full)) => crate::i18n::tr_format!(
"{what} merge added at {mp}: its full size, {full}, needs more memory than this computer has",
what = what,
@@ -367,7 +405,33 @@ fn added_message(what: &str, info: &Value) -> String {
full = full
),
_ => crate::i18n::tr_format!("{what} merge added", what = what),
}
};
if info["used"].is_array() && info["omitted"].is_array() { format!("{message}\n{}", inclusion_summary(info)) } else { message }
}
fn inclusion_summary(info: &Value) -> String {
let used = info["used"].as_array().map_or(0, Vec::len);
let omitted = info["omitted"].as_array().map_or(0, Vec::len);
crate::i18n::tr_format!("{used} of {total} photos included", used = used, total = used.saturating_add(omitted))
}
/// Names come from this result's source paths, not the current selection or an older preview.
fn omitted_photos(ui: &mut egui::Ui, info: &Value) {
let Some(omitted) = info["omitted"].as_array().filter(|v| !v.is_empty()) else { return };
let t = crate::theme::Tokens::get(ui.ctx());
ui.label(egui::RichText::new(inclusion_summary(info)).strong().color(t.caution));
ui.label(crate::i18n::tr("LightCraft could not align these photos with the included set. Review the preview before merging."));
omitted_names(ui, omitted.iter().filter_map(|photo| photo["path"].as_str()));
}
/// The omitted photos' file names, scrolling past a few; each one's full path on hover.
fn omitted_names<'a>(ui: &mut egui::Ui, paths: impl Iterator<Item = &'a str>) {
egui::ScrollArea::vertical().id_salt("merge-omitted").max_height(76.0).show(ui, |ui| {
for path in paths {
let name = std::path::Path::new(path).file_name().and_then(|s| s.to_str()).unwrap_or(path);
ui.add(egui::Label::new(name).wrap()).on_hover_text(path);
}
});
}
fn last_failed_matches(app: &LightcraftApp, opts: &MergeDialog) -> bool {
@@ -430,6 +494,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, opts: &mut MergeDialog)
ui.horizontal_top(|ui| {
// preview
ui.vertical(|ui| {
ui.set_width(520.0);
let box_size = egui::vec2(520.0, 360.0);
let (rect, resp) = ui.allocate_exact_size(box_size, egui::Sense::click_and_drag());
ui.painter().rect_filled(rect, 4.0, t.canvas);
@@ -454,7 +519,9 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, opts: &mut MergeDialog)
if let Some(e) = &app.merge.error {
ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, e, t.font(13.0), t.text);
}
let info = app.merge.preview.as_ref().map(|p| p.3.clone());
// A previous preview may stay visible while the options change. Only describe
// inclusions once this preview is current and its replacement has finished.
let info = app.merge.preview.as_ref().filter(|p| p.2 == *opts && app.merge.preview_task.is_none()).map(|p| &p.3);
if let Some(info) = info {
let txt = if opts.is_pano() {
crate::i18n::tr_format!(
@@ -470,6 +537,9 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, opts: &mut MergeDialog)
crate::i18n::tr_format!("{} photos · exposures {} EV", ev.len(), ev.join(" / "))
};
ui.label(egui::RichText::new(txt).color(t.text_dim));
if opts.is_pano() {
omitted_photos(ui, info);
}
}
});
ui.add_space(12.0);
@@ -598,6 +668,21 @@ mod tests {
assert!((r.center().y - area().center().y).abs() < 0.5 && r.left() < area().left() && r.right() >= area().right(), "{r:?}");
}
#[test]
fn completed_panorama_reports_its_actual_inclusion_count() {
for (what, used, omitted) in
[("Panorama", vec![71, 9], vec![401]), ("HDR panorama", vec![71, 9, 401, 3], vec![6, 12]), ("Panorama", vec![1, 2], vec![])]
{
let info = json!({"used": used, "omitted": omitted.iter().map(|id| json!({"id": id})).collect::<Vec<_>>()});
let message = added_message(what, &info);
let mut lines = message.lines();
assert_eq!(lines.next(), Some(added_message(what, &Value::Null).as_str()));
let count = lines.next().expect("the completion message reports inclusion");
let numbers = count.split_whitespace().filter_map(|word| word.parse::<usize>().ok());
assert!(numbers.eq([used.len(), used.len() + omitted.len()]), "{count}");
}
}
/// Issue #1455: a panorama held to the computer's memory, or to the largest size, says so.
#[test]
fn a_smaller_panorama_says_why() {
+6
View File
@@ -44,6 +44,12 @@ pub enum Dialog {
details: Vec<String>,
first: Option<u64>,
},
/// A finished panorama that left photos out: its message and the omitted files' paths, taken from the final
/// result (the preview registered smaller copies and can leave out other photos).
MergeResult {
summary: String,
omitted: Vec<String>,
},
/// File ▸ Print…: the Print module. Its state is the session's (`print.*`); the page on show
/// and the selected cell are [`UiState::print`].
Print,
+72
View File
@@ -417,6 +417,78 @@ fn final_merge_shows_a_row_and_cancels() {
let _ = std::fs::remove_dir_all(dir);
}
/// Merging other photos while the dialog is open ("with Last Settings", or the next set of an HDR batch) drops the
/// dialog's preview of the photos it had: the preview is kept while its options match, and the dialog went on
/// describing the old photos (their count and omitted files) for the new ones.
#[test]
fn merging_other_photos_drops_the_dialogs_preview() {
let (mut h, dir) = bracket("merge-ids");
let all = h.app.session.selected();
crate::merge::open(&mut h.app, "merge.hdr").unwrap();
assert!(h.step_until(T, |h| h.app.merge.preview.is_some()), "the dialog previews the three photos");
let ev = |h: &Headless| h.app.merge.preview.as_ref().and_then(|p| p.3["ev"].as_array().map(Vec::len));
assert_eq!(ev(&h), Some(3));
h.app.session.execute("library.select", &json!({"ids": &all[..2]})).unwrap();
crate::merge::start_last(&mut h.app, "merge.hdr").unwrap();
assert_eq!(h.app.merge.ids, all[..2].to_vec());
assert!(h.app.merge.preview.is_none() && h.app.merge.preview_pixels.is_none(), "no preview of the three photos left");
let rows = h.app.session.activity.list();
let merging = rows.iter().find(|r| r.kind == "merge").map(|r| r.id).unwrap();
h.app.session.activity.cancel(merging).unwrap();
assert!(h.step_until(T, |h| h.app.merge.final_task.is_none() && h.app.merge.preview.is_some()));
assert_eq!(ev(&h), Some(2), "the dialog previews the photos it now merges");
let _ = std::fs::remove_dir_all(dir);
}
/// PR #2492 review: the final merge registers the full-size photos again, so it can leave out other photos than the
/// preview did. The completion names the final result's omitted files (to a screen reader too, announced where the
/// user is), waits for a dialog the user has open, and a panorama that left nothing out shows no list.
#[test]
fn a_finished_panorama_names_the_photos_it_left_out() {
let mut h = demo();
let ctx = h.view.ctx.clone();
// the preview left out another photo than the final merge does
let tex = ctx.load_texture("t", egui::ColorImage::new([1, 1], vec![egui::Color32::BLACK]), Default::default());
let preview_info = json!({"used": [1, 3], "omitted": [{"id": 2, "path": "/photos/Preview-only.png"}]});
h.app.merge.preview = Some((tex, [1, 1], crate::merge::MergeDialog::for_command("merge.panorama"), preview_info));
// a dialog the user has open is not replaced
h.app.ui.dialog = Some(crate::state::Dialog::About);
let final_info = json!({"id": 9, "used": [1, 2], "omitted": [{"id": 3, "path": "/photos/Final-only.png"}]});
crate::merge::finished(&mut h.app, &ctx, "Panorama", final_info);
h.step();
assert_eq!(h.app.ui.dialog, Some(crate::state::Dialog::About));
h.app.ui.dialog = None;
h.step();
h.step();
let painted = h.painted_text().join("\n");
assert!(painted.contains("Final-only.png"), "the final omitted name is listed");
assert!(!painted.contains("Preview-only.png"), "not the preview's");
// what a screen reader gets: a dialog, the name, a polite live region, and a button to close it
ctx.enable_accesskit();
let raw = crate::headless::HeadlessView::raw_input(h.size, h.pixels_per_point, h.time, Vec::new());
let app = &mut h.app;
let mut out = ctx.run_ui(raw, |ui| {
app.logic(ui.ctx());
app.ui(ui);
});
let tree = out.platform_output.accesskit_update.take().expect("an accessibility tree");
let nodes: Vec<_> = tree.nodes.iter().map(|(_, n)| n).collect();
let named =
|role: egui::accesskit::Role, text: &str| nodes.iter().any(|n| n.role() == role && n.label().or(n.value()).is_some_and(|l| l.contains(text)));
let title = nodes.iter().find(|n| n.role() == egui::accesskit::Role::Dialog).and_then(|n| n.label()).expect("a dialog node");
assert!(painted.contains(title), "the dialog is named by its visible title");
assert!(named(egui::accesskit::Role::Label, "Final-only.png"));
assert!(nodes.iter().any(|n| n.live() == Some(egui::accesskit::Live::Polite)), "the result is announced");
assert!(h.app.widgets.iter().any(|(w, _)| w == "button:dialogOk"), "it closes from a button");
// a panorama that left nothing out: the message only
h.app.ui.dialog = None;
crate::merge::finished(&mut h.app, &ctx, "Panorama", json!({"id": 10, "used": [1, 2], "omitted": []}));
h.step();
h.step();
assert_eq!(h.app.ui.dialog, None);
assert!(!h.painted_text().iter().any(|t| t.contains("Final-only.png")));
}
/// The merge dialog opens with the options of the last merge of its kind (per kind), and "with Last
/// Settings" uses them; a kind never merged opens with the defaults.
#[test]
+3 -1
View File
@@ -42,6 +42,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app
| 25 | **File writes**: AVIF import; Render to DNG as a catalog command (lossy DNG and the Render to DNG export format landed) (PSD export landed with Edit in PhotoCraft, #953) | file-format-parity.md | interchange edge cases | 19–34 | [file-format-parity](file-format-parity.md) |
| 26 | **Performance at scale**: flags, ratings and edits are written and synced to the catalog log by a thread of its own, so a key never waits for a busy drive (a 300 ms sync: 0.2 ms per flag, was 305 ms), and a write that fails is held, retried and counted as unsaved, never dropped (PERF-STEP-STALL); 85k-photo library opens in 1.7–4.7 s; 100k grid test pending; colour NR at half resolution; at 100k photos stack and album lookups are indexed (an "In a Stack" or "Album" smart album counts in ~14 ms, was 0.6–2.7 s); culling a wedding: first photos of a 2,933-raw folder in 0.9 s and camera JPEGs ready ahead of each step, but a full-size 45 MP camera JPEG still takes ~150 ms to decode (held-arrow stepping at a 2,560 px loupe can outrun it), the 100 % view of the raw itself still takes ~5 s to render (the camera JPEG is shown at 100 % meanwhile, ~0.9 s), and browsing or importing still reads and hashes every raw whole (~10 ms a file on SSD, ~1 s a 25 MB file from a NAS); the loupe uses built previews and photos are prepared ahead and the whole view in the background (face detection, AI masks and denoise are not yet part of that preparation) | ROADMAP log, gpu-pipeline.md | large-catalog users | 15–30 | [target-app-parity](target-app-parity.md#by-dimension) |
| 27 | **Windows / Linux runtime coverage**: the Windows x64 installer is verified on Windows 11 (0.9.1: install and upgrade end on the completion page, a custom folder is kept, Launch works, removal is clean), but uninstalling from Settings → Apps ends with no confirmation (#892, #931); GPU path proven on Apple and on one AMD GPU on Linux (Radeon 8060S, Vulkan); NVIDIA, Intel and DX12 unverified; Windows DirectComposition VRR workaround implemented, monitor verification pending; the Linux riscv64 tarball (new in 0.6.0, #844) is cross-compiled and never run beyond a QEMU smoke test | ROADMAP, issues, `release.yml` | non-Mac users find bugs first | 13–27 | [hardware-parity](hardware-parity.md) |
| 32 | **Panorama verification in moving scenes** (LR-MERGE-PANO, LR-MERGE-HDRPANO): genuine overlaps can fail the inlier-fraction gate; omitted source photos are now reported | #1765; original procedural known-homography and parallax tests in `crates/merge/tests/pair_verification.rs`; the [waterfall raws](https://github.com/storytold/lightcraft/issues/1765#issuecomment-7026674014) still register as two groups | panoramas may omit part of the scene | not estimated | [merge](merge.md#panorama-inclusion-diagnostics) |
| 29 | **HDR merge leftovers** (LR-MERGE-HDR): AI Denoise doesn't run on merged (linear) DNGs; JPEG brackets are treated as linear (no camera response curve); every frame is held as 32-bit float, ~0.86 GB per 67 MP frame (half-float frames would halve it) | tested on Sony A7R VI brackets 2026-10-14 ([merge.md](merge.md)); Lightroom's Denoise supports HDR DNGs | HDR shooters who denoise their merges, merge JPEGs, or merge 7+ frames of high-resolution raws on 16 GB machines | 10–20 (+ denoise linear-RGB contract, gap 11) | [merge](merge.md) |
| 28 | **Small Classic shortcuts and keys**: Tab (hide the side panels; Tab moves the keyboard focus here) and F5. Rating `[` `]`, flag cycling (`` ` ``), `\` (Filter Bar), ⌘L (Enable Filters), ⌘⌥⇧C / ⌘⌥⇧V (Copy / Paste Metadata), F1 help, F6 / F7 / F8 (filmstrip, left panel, right panel) and ⇧Tab (all panels) are bound; the grid-cycle key is shown beside both grid rows in View (#2500) | [ui-parity](ui-parity.md#shortcuts) | Classic muscle memory | 2–4 | [ui-parity](ui-parity.md) |
| 30 | **Multi-select metadata editing in the UI**: `photo.setMeta` already iterates all selected photos, so the engine applies changes to every target. The Info panel's Show Metadata For choice (Target Photo / Selected Photos) shows the values the selected photos share and marks each field where they differ as Mixed; the All Metadata dialog still shows one photo's values with no "mixed" indication | standard in Lightroom Classic's multi-select Info panel | anyone editing metadata on a batch (copyright, keywords, custom fields) | 1–3 | [ui-parity](ui-parity.md) |
@@ -57,7 +58,7 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w
- **File format:** 2, 6, 7, 10, 13, 20, 25 (raw ones in [raw-parity.md](raw-parity.md))
- **Hardware:** 14, 17, 22, 27
- **Localization:** 21
- **Quality / fidelity:** 1, 3
- **Quality / fidelity:** 1, 3, 32
- **Stability and platforms:** 9, 26, 27
## Closed recently (kept for calibration)
@@ -143,6 +144,7 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w
| 2026-10-19 | minor | Gap 9 shrinks: `.github/workflows/ci.yml` runs `cargo xtask ci` on Linux x64 for every PR and push to main; macOS and Windows remain |
| 2026-10-19 | minor | Gap 21: Indonesian (`id`) shipped with every catalog message but What's New; four new languages left (Hindi, Arabic, Korean, Vietnamese), 135–239 h |
| 2026-10-19 | minor | Gap 27: the released 0.9.1 x64 MSI is tested on Windows 11 Pro 24H2 (a fresh install and an upgrade from 0.8.0 end on the completion page, so #790 is fixed; the upgrade keeps a custom folder; Launch starts the app; removal leaves nothing behind); uninstalling from Settings → Apps still ends with no confirmation (#892, #931); hours unchanged |
| 2026-10-21 | minor | Gap 32 records unresolved panorama verification (#1765); included counts and omitted filenames are now reported |
| 2026-10-18 | patch | Gap 1: six X-Trans CMOS 4 Fujifilm bodies (X-T30 …) take the X-T3's spectral matrices instead of the neutral matrix |
| 2026-10-15 | minor | Gap 15 shrinks: the Page panel's Page Options (Page Numbers, Page Info, Crop Marks) print on Single Image and Contact Sheet pages; identity plate, watermark, photo info, Cut Guides, direct printing and JPEG output remain |
| 2026-10-14 | minor | Gap 4 follow-up: the diagnostic overlays (Visualize Spots, Point Color range, HDR range) render zoom windows too; soft proofing runs on the GPU |
+38
View File
@@ -24,6 +24,41 @@ All algorithms are our own implementations from published papers (cited in the m
among the files, e.g. a whole folder);
`lightcraft-cli synth-merge hdr|panorama -o DIR` writes synthetic inputs (procedural scene).
## Panorama inclusion diagnostics
Panorama and HDR panorama results include `used` (source photo IDs, in source order),
`omitted` (`{id, path, reason: "notRegistered"}`), and `pairs`. Each pair has `a` and `b`
(source photo ID arrays), `matches`, `inliers` (null if no fit was returned), and `status`:
`insufficientMatches`, `noModel`, `rejected`, or `accepted`. HDR panorama expands each
stitched bracket to all of its source photos. The result keeps the first 1,024 pairs in
input order. `pairsTruncated` is true when there are more pairs. All pairs are still
verified, and the `used` and `omitted` lists cover every source photo. A preview and a full
merge can use different photos because they run at different resolutions.
The preview lists omitted filenames and the included count. The completion message uses
the final merge's count. When the final merge omits photos, a Photo Merge Result dialog lists
the final result's omitted filenames, because they can differ from the preview's: the preview
registers copies at most 1,024 pixels on the long side, and the final merge registers the
full-size photos again. Pair measurements also appear at debug log level, including when
registration fails entirely. An accepted pair can belong to a component that is not used.
`notRegistered` means the photo has no camera in the final registered set. It does not
establish missing overlap, moving water, or parallax as the cause.
Issue [#1765](https://github.com/storytold/lightcraft/issues/1765) and @aterveus's
[logging prototype](https://github.com/aterveus/lightcraft/commit/49054c2b94) prompted these
diagnostics. Their [lower-slope experiment](https://github.com/aterveus/lightcraft/commit/e7ed794c72)
identified a useful test regime. The verification threshold remains `inliers > 8 + 0.3 * matches`:
original procedural correspondence tests recover known homographies with 30 to 36 inliers
among 100 to 140 matches, then reproduce their rejection. A slope of 0.15 also accepts the
tests' coherent wrong panel match and translated-camera parallax. Spatial spread and a
small reprojection error alone do not distinguish all of these cases.
The [waterfall registration report](https://github.com/storytold/lightcraft/issues/1765#issuecomment-7026674014)
found two groups in the original raws. No pair between the groups reached the minimum
inlier count for a model, so changing the verification slope would leave those groups
apart. A separate three-frame moving-texture experiment fails registration, while its
clean control registers all three frames.
## What it does
**HDR** (`hdr.rs`): frames ordered by EXIF exposure (or median luminance); the middle one is the
@@ -75,6 +110,9 @@ scale in `BaselineExposure`; raw sources keep their DNG colour tags (camera RGB)
## Limits (known gaps)
- Pair verification can reject genuine overlaps in moving scenes (#1765). Omitted photos are
reported, but a safer acceptance policy still needs validation on real inputs.
- No lens-distortion model in the panorama bundle adjustment (rectilinear lenses assumed); no
360° wrap-around; flat (translating-camera) scans are fitted with the rotation model. Panoramas and HDR
panoramas carry no lens corrections, nor does an HDR whose frames don't share an orientation (they are turned
+3 -2
View File
@@ -12,7 +12,7 @@ have their own documents: [raw-parity.md](raw-parity.md), [file-format-parity.md
| Number | Value | Kind |
|---|---:|---|
| **Feature breadth**, checklist | **83.2%** of 543 in-scope rows (P0 97.5%, P1 94.4%, P2 56.7%) | **measured**: recount of [parity-checklist.md](parity-checklist.md) rows (✅ 1, 🟡 ½, 🚫 left out), the same rule `cargo xtask parity` uses |
| **Feature breadth**, checklist | **83.2%** of 546 in-scope rows (P0 97.5%, P1 94.2%, P2 56.7%) | **measured**: recount of [parity-checklist.md](parity-checklist.md) rows (✅ 1, 🟡 ½, 🚫 left out), the same rule `cargo xtask parity` uses |
| **Feature breadth**, weighted by use | **~77%** | estimated: feature-area table below |
| **Ready for real work** (full target) | **~62%** (range 57–67%) | estimated: weighted sum over the dimensions with written weights, see [below](#ready-for-real-work-mainstream-practitioner-and-essentials-user) |
| **Mainstream practitioner** | **~51%** (range 46–56%) | estimated: weekly areas of a working photographer, depth 74.5% × 0.804 × colour 0.85 |
@@ -75,7 +75,7 @@ from the checklist sections and the deep-dive documents.
| Remove, heal, Enhance (denoise, Raw Details, Super Resolution, Lens Blur) | 7% | 45% | 30% | 70–130 h | checklist I 75%, P 0% |
| Presets, profiles, versions, history, sync | 5% | 95% | 85% | 8–15 h | |
| Export | 6% | 89% | 75% | 15–30 h | checklist S 88.9% |
| Merge and HDR | 3% | 85% | 60% | 20–35 h | merge 88% (HDR merge 🟡: AI Denoise on merged DNGs, JPEG response, memory; gap 29), HDR 70% (no HDR display) |
| Merge and HDR | 3% | 85% | 60% | 20–35 h | merge 63% (HDR limitations, gap 29; panorama and HDR panorama verification in moving scenes, gap 31), HDR 70% (no HDR display) |
| Views, compare, zoom, culling | 5% | 90% | 70% | 15–30 h | zoom detail P0 gap |
| Classic output modules (Map, Book, Slideshow, Print, Web, publish, tethering) | 4% | 15% | 10% | 90–150 h | Classic extras 48% counts many small keys; the modules themselves are mostly ⬜ |
| Video | 1% | 0% | 0% | 25–45 h | catalogued only |
@@ -310,6 +310,7 @@ P2 items 12–25 h; look tuning, performance, packaging, hardening 25–45 h.
| 2026-10-22 | minor | Tone Curve input histogram (#987); headline counts and readiness estimates unchanged. See [the stage contract](tone-curve-input.md). |
| 2026-10-19 | minor | Localization ~55% → ~64% (mean of the 12 key languages): Indonesian (`id`) catalog, every message but What's New; full target 61.2% → 61.5% (still ~61%) |
| 2026-10-19 | patch | Platforms: the Windows installer is no longer listed as unverified (the 0.9.1 x64 MSI is tested on Windows 11; a confirmation after uninstalling from Settings → Apps, #892, remains); #790 noted as fixed in 0.9.1; percentages and hours unchanged |
| 2026-10-21 | minor | Panorama and HDR panorama marked partial (#1765): omitted photos are reported; verification remains unresolved. Checklist recount 83.5% to 83.3% (543 rows); refreshed the stale headline from the checklist. Readiness estimates unchanged |
| 2026-10-17 | minor | Object / Describe masks: SAM 3's text detector mask decoder also on the GPU outside macOS; status unchanged |
| 2026-10-17 | minor | Object / Describe masks: SAM 3's necks and text detector's encoder also on the GPU outside macOS; status unchanged |
| 2026-10-17 | minor | Object / Describe masks: SAM 3's image encoder runs on the GPU through wgpu on Windows and Linux (CPU fallback); status and numbers unchanged |