feat(ocr): live camera viewfinder + invert-colours toggle
Four wins:
1. Replace <input type=file capture> with a getUserMedia
viewfinder modal on mobile. Tapping the shutter goes straight
to the crop modal — skips the OS "retake/use" confirm step.
Falls back to file picker if camera permission is denied or
the API is unavailable. "Pick from file" icon
(photo_library) inside the camera modal opens the gallery
on demand.
2. Drop the Reset button — with no default crop box, "reset" is
just "no box again," which is the starting state anyway.
3. The check (Use this) button is now larger and more prominent
— wider padding, 24px icon, accent fill.
4. Invert-colours toggle (invert_colors icon) in the crop modal.
White-on-dark text (signs, menus, screenshots) breaks
Tesseract because the binariser was made for ink on paper.
Toggling the button flips the grayscale buffer before
adaptive thresholding so the binary output ends up
black-on-white. State plumbed cleanly: openCropper now
resolves with {blob, invert}; preprocessForOCR takes an
{invert} option; binarizeAdaptive applies the flip.
Also: drop `capture=environment` from the file <input>. Without
it the file path correctly opens the gallery/file dialog instead
of re-opening the OS camera when the user picks "Pick from file".
This commit is contained in:
@@ -18,10 +18,14 @@ Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
- "Scan image" button replaced with a floating action button at the bottom-right of the viewport, using a Material Symbols Outlined camera glyph (`photo_camera`) for consistent rendering across platforms (was a small text button in the input pane header).
|
||||
- Crop modal:
|
||||
- No default crop box. User drags on the image to draw the region; falls back to full image if they confirm without drawing.
|
||||
- Rotate left / Rotate right / Reset / Use this buttons replaced with Material Symbols icons (`rotate_left`, `rotate_right`, `restart_alt`, `check`). Cancel kept as text.
|
||||
- Buttons are now Material Symbols icons: `rotate_left`, `rotate_right`, `invert_colors` (new — see below), `check`. Cancel kept as text. The `check` (Use this) button is larger and more prominent. The Reset button was removed (rarely useful with no default box).
|
||||
- Inner padding bumped to 2 rem so cropperjs's corner handles never sit on the right/bottom edges where Android's edge-swipe back gesture fires. iOS safe-area insets honoured on the backdrop and FAB.
|
||||
- Header text is now a hint ("Drag on the image to select the text region") instead of a title.
|
||||
|
||||
### Added
|
||||
- Camera viewfinder modal on mobile (via `navigator.mediaDevices.getUserMedia` with `facingMode: environment`) — replaces the `<input type=file capture>` flow. Tapping the shutter goes directly to the crop modal, skipping the OS-level "retake / use" confirm step. Falls back to the file picker if camera access is denied or unavailable; a "Pick from file" icon (`photo_library`) inside the camera modal also routes to the picker on demand.
|
||||
- Invert-colours toggle (`invert_colors`) in the crop modal. Tap to flip light-on-dark text into the dark-on-light polarity Tesseract expects. The grayscale buffer is inverted before adaptive thresholding so the binarised output is correct.
|
||||
|
||||
### Fixed
|
||||
- "Hot: …" status no longer claims "unloads in X" when the server's `keep_alive` is `-1` (Ollama returns an absurd year-4001 `expires_at`). Threshold: any expiry >7 days drops the suffix and just shows the model name.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user