Skip to content

Focus-quality (HFD) indicator on the Focus screen#449

Open
brickbots wants to merge 2 commits into
mainfrom
worktree-focus-quality-indicator
Open

Focus-quality (HFD) indicator on the Focus screen#449
brickbots wants to merge 2 commits into
mainfrom
worktree-focus-quality-indicator

Conversation

@brickbots
Copy link
Copy Markdown
Owner

What

Adds a quantitative, graphical focus aid to the Focus screen (UIPreview). It tells the user how well-focused they are and makes the point of best focus obvious as they sweep through it — independent of plate solving, across the full defocus range.

How

  • PiFinder/focus.py — pure, UI-free module: a self-contained Half-Flux Diameter (HFD) detector (detect_stars, half_flux_diameter, focus_hfd). Runs in the main process on the raw frame; tuned to accept broad/defocused blobs and reject hot pixels / oversized blobs. No dependency on the solver's centroids or SQM (see ADR 0005).
  • UIPreview — a focus strip: fixed log-axis V-curve over a 10 s window, best-focus marker, past-best "BACK UP" cue, HFD/exposure/detected-count/matched-count HUD. Replaces per-frame autocontrast with a background-anchored, EMA-smoothed display stretch. SQUARE toggles the strip; it persists across zoom (HFD is zoom-independent).
  • Testspython/tests/test_focus.py (11 unit tests: Gaussian HFD vs theory, saturated core, blank frame, oversized→too-defocused, monotonicity, median robustness, hot-pixel rejection).
  • Docs — Quick Start "Setting Focus & First Solve" reframed around the HFD readout + V-curve, with HUD example screenshots.

Design references already on main: docs/adr/0005-focus-hfd-self-contained-in-ui.md and the "Focus indicator" section of docs/ax/ui/CONTEXT.md.

Verification

  • ruff / ruff format / mypy clean; pytest -m unit (190, incl. 11 new) and -m smoke (5) pass.
  • Verified live in the headless app: strip renders with live HFD/detected/matched/exposure, empty frames show /det 0, SQUARE toggles the strip, zoom persists it with the relocated Zoom xN label, no crashes.

Notes

  • New UI strings are _()-wrapped and fall back to English until the next nox -s babel; the Babel catalog regeneration is intentionally not included (it swept up unrelated catalog drift).

🤖 Generated with Claude Code

brickbots and others added 2 commits May 29, 2026 11:34
Self-contained Half-Flux Diameter detector (PiFinder/focus.py) plus a focus
strip in UIPreview: log-axis V-curve over a 10s window, best-focus marker,
past-best "BACK UP" cue, and a background-anchored display stretch replacing
per-frame autocontrast. The detector runs in the main process on the raw frame
and does not depend on plate solving, so it works across the full defocus range.

See docs/adr/0005-focus-hfd-self-contained-in-ui.md and the "Focus indicator"
section of docs/ax/ui/CONTEXT.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reframe "Setting Focus & First Solve" around the HFD readout and its V-curve
rather than zooming in to judge stars by eye. Add a focus-strip walkthrough and
HUD example images (focused vs unfocused, with the strip composited over the
existing example frames).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant