Skip to content

Moh review fixes - #5

Merged
dmitriy-myz merged 3 commits into
moh-opencv-cleanupfrom
moh-review-fixes
Oct 27, 2026
Merged

dmitriy-myz merged 3 commits into
moh-opencv-cleanupfrom
moh-review-fixes

Conversation

@dmitriy-myz

Copy link
Copy Markdown
Owner

No description provided.

dmitriy-myz and others added 3 commits June 12, 2026 09:50
… fill the cap

On hardware every placement saturates FRAME_KP_CAP (250), so the old
"best 4 by len(kps)" selection was a no-op. Calibration against real
captures (8-placement Wine enrollment tiles: pool 493-516 ~= 2x cap;
synthetic degradations of a real frame: even half-empty/25%-contrast
frames still hit 250) shows the UNCAPPED detector pool is the usable
quality signal — see dev/FRAME-QUALITY.md.

- extract_frame_native(..., stats=) returns n_pool / cap_score /
  med_score (pre-cap, output unchanged)
- enroll_moh ranks frames by n_pool and recaptures frames with
  n_pool < min_frame_pool (default FRAME_KP_CAP; kept-on-exhaustion)
- per-frame quality logged so hardware runs keep producing
  calibration data
- analysis tooling: dev/analyze_frame_quality.py (synthetic
  degradations), dev/analyze_real_captures.py (gdb capture mining)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
moh_enrollment: split into capture_frames / build_template / store_template.
- A chip rejection of the 0x47 store (bad parent, duplicate, full storage)
  is deterministic and now fails immediately instead of recapturing all
  placements up to 6 times behind 'enroll-retry-scan'.
- Each failed placement is reported via update_cb(None, e) so fprintd shows
  a retry cue (the docstring contract, matching the legacy path).
- usb.cancel is checked before every capture: wait_int() clears the flag on
  entry, so a Cancel landing during host-side feature extraction was lost.
- `parent` may be a callable resolved only after all captures.

sensor.py
- enroll(): user lookup/creation moved back to commit time on both paths, so
  a cancelled first enrollment no longer leaves a finger-less user record
  and the legacy 138a/9a wire order is unchanged.
- capture(): send the 0x04 capture-stop on every interrupted capture (cancel,
  USB error, scan error), skipping it only after a COMPLETED streamed capture
  on MoH devices; an a2 rejection of the stop is logged, not raised.
  NOTE: untested on hardware; the previous code never sent it on a2.
- Format the 'Response size does not match' message (was a literal '%d').

moh_native: apply the near-identity sec0_pre patch once in _load_ws_scaffold
and assert it patched 6 records, instead of a silent heuristic per template.

enroll_moh_chip: --user-sid is parsed with sid_from_string (was passing a
str, which identity_to_bytes rejects); --parent no longer defaults to a
magic dbid and must be a type-5 USER record.

Tests: tests/test_moh_enrollment.py, tests/test_enroll_moh_chip_script.py,
scaffold prepatch test (chip/USB layer stubbed, pipeline runs for real).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- moh_native.build_envelope (was _build_envelope) is the single finger
  envelope builder; Sensor.make_finger_data delegates to it (byte-identical
  format, pinned by test). Legacy devices now touch moh_native (numpy) at
  enrollment commit; numpy is already a hard dependency.
- moh_native.assemble_template(per_section_kps, subtype) is the shared
  scaffold → v30 sections → TID → envelope chain; native_template (single
  frame) and moh_enrollment.build_template (ranked frames) both use it.
  Dropped the unused native_template(fill_all_sections=) parameter.
- store_template uses db.new_record, which gains a `trailer` argument for
  the uncounted 0x00 byte the type-6 store sends, instead of a duplicate
  0x47 implementation. Chip rejections now raise via assert_status.
- DEFAULT_SUBTYPE is 0xf5 (the value tested on hardware); the CLI default
  and help text derive from it instead of a second literal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dmitriy-myz
dmitriy-myz merged commit cae4f41 into moh-opencv-cleanup Oct 27, 2026
@dmitriy-myz
dmitriy-myz deleted the moh-review-fixes branch October 27, 2026 09:34
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