#12 - Live view in the app, and centering through it #8

Merged
eliott merged 16 commits from feat/live-view into main 2026-11-17 22:55:01 +01:00
Owner

The app's window shows what the camera sees, live, with what the detector finds drawn on it: the gaps between frames, the frame's edges and center, the middle of the picture, and a line saying how far the frame is from the center.

Frames are now centered, and the scanner calibrated, by looking through that live view: only the picture that is kept is a real shot, and that shot is checked. A camera that gives no live view works as before, from real shots.

Run on the real scanner, the live view showed where the detector failed on thin negatives, and this now carries the fixes: frames whose edges were not found are found, a calibration reads the frame's width off the film's height, and a camera that shakes a little no longer stops everything.

Part of #12

How it works

The live view:

  • One gphoto2 --shell stays running and is asked for frame after frame, about 20 a second on the X-T5. About one request in three fails because the camera has no new frame yet; the session survives and asks again.
  • A picture can't be taken inside that session, so it is closed for each shot and opened again after. The live view freezes for about five seconds per shot.
  • What made the X-T5's live view stop after the first capture: the shot stays in the camera's temporary memory, gphoto2's own delete of the RAW fails, and the camera refuses the live view while anything is left there. That memory is now emptied after every shot. Only memory the camera reports as fixed and fetch-and-delete-only is emptied, never a card, and only after the shot's files are on disk.
  • To look at the film, the scanner waits for three live frames in a row in which nothing changes, then averages the next five.
  • The shot that is kept is checked: found more than 8 px off-center, the film is corrected by what the shot shows and the shot is taken once more. How far the shots come out from the live view is learned from them (median of the last five) and the next frames are aimed accordingly. A frame lined up by hand is shot where it was put.
  • A calibration records whether it was measured through the live view or in shots, and is only used the way it was made.
  • The page fetches frames from GET /api/live/frame and draws them on a canvas.

What the real scanner showed, each fixed in a commit of its own:

  • A frame's edge behind a soft fringe. Between a gap and the picture a live view shows 3 to 8 columns as bright as the base but uneven. The 4 columns probed outside a bright run fell on them. The probe now reaches up to 8 columns further, and the edge is put at the first dense column.
  • A frame that starts as clear as the base. When a frame's dense edge borders a bright run on one side only, and from it to the run's other end is a gap's width (within 25%), the run is the gap and the other frame starts at its other end. Only ever one reading among the others: never paired into a frame seen with both edges, and nothing is worked out from it in turn.
  • A gap seen from both sides is believed first. An edge inside a picture could point somewhere else and veto the one reading that was right.
  • A gap cut in two by grain. A break of at most 6 columns, all as bright as the base and no more uneven than 0.04, no longer cuts a run. Tried first and dropped: measuring evenness on rows averaged together. It moved the frame on 14 of 93 still photos.
  • The frame's width from the film's height. The motor's scale (steps a millimetre on paper) put the frame 1 to 2.5% too narrow. The pressure frame's window is exactly as tall as a frame, so the film's height in the picture gives the pixels in a millimetre: 24 mm for 35mm film, 56 mm for 120, each format with its own length. The motor's scale is the cross-check (10%) and the fallback.
  • A picture that trembles is at rest. The limit between two live frames was crossed by a sideways shake of 0.02 px at the window's edge; measured on the rig, the room shakes the camera by 0.1 px. The limit goes from 0.01 to 0.1.
  • Bright fringes are not the base. A camera's sharpening leaves a column or two brighter than the film beside every sharp dark edge; with enough of them they set the base's level 0.04 too high and no gap was found. Lines thinner than 9 columns are now taken out before the level is read.

The Python reference in reference/ follows these, so tools/parity.py holds.

Tested

  • cargo test: 235 passed, with a fake gphoto2 shell for the live camera and a simulated scanner whose photos can come out shifted from its live view.
  • tools/parity.py: SAME (325 synthetic pictures, 12 JPEG cases).
  • On the X-T5, camera alone: live frames through the app, three real shots in a row with the live view back after each, the camera's memory empty afterwards.
  • On the real scanner (X-T5 through its live view, Arduino, 35mm negatives, thin ones): calibration, Check framing and scans of a few frames at a time. Each fix above was tried there as it was made, in a build of this branch at that point: frames that were not found came to be found and centered.
  • On 98 full-size X-T5 scans of three rolls, read as still photos: bridging the breaks and the base's level without fringes change no frame when a frame width is given. Without one (not calibrated), bridging moves 5 of 94 found frames by more than 4 px, one of them clearly for the worse.

Not tested

  • The branch as it now stands, as one build, has not scanned on the real scanner on its own: the last scans there ran the build of #21, which sits on top of it.
  • A full roll from end to end. The check of each photo against the live view was not looked at separately on the real scanner.
  • Whether a live frame and a photo show the film at the same scale on the X-T5 is not measured.
  • Slides, 120 film, panoramic frames: simulated scanner only. The film's height on a slide (dark where a negative is clear) relies on the cross-check with the motor's scale.
  • A pressure frame whose window is not exactly as tall as a frame.
  • macOS and Windows.

Changes in behaviour

  • A calibration made before this has to be made again once: the app says "Calibrate again: the camera is now used with its live view".
  • A calibration needs the whole height of the pressure frame's window in the picture, with black above and below, to read the frame's width off it. Without, it falls back on the motor's scale as before.
  • Check framing no longer takes a picture when the camera has a live view.
  • With the live view running, the annotated still from Check framing and from each kept frame is no longer shown; the live view takes its place.
  • The command line uses the live view too.
  • Film still creeping by less than about a fifth of a pixel between two live frames now counts as stopped.
  • Not in this pull request: following the film while it moves (slip detection, frame edges known from many viewpoints). It needs recordings from the real scanner first.
The app's window shows what the camera sees, live, with what the detector finds drawn on it: the gaps between frames, the frame's edges and center, the middle of the picture, and a line saying how far the frame is from the center. Frames are now centered, and the scanner calibrated, by looking through that live view: only the picture that is kept is a real shot, and that shot is checked. A camera that gives no live view works as before, from real shots. Run on the real scanner, the live view showed where the detector failed on thin negatives, and this now carries the fixes: frames whose edges were not found are found, a calibration reads the frame's width off the film's height, and a camera that shakes a little no longer stops everything. Part of #12 ## How it works The live view: - One `gphoto2 --shell` stays running and is asked for frame after frame, about 20 a second on the X-T5. About one request in three fails because the camera has no new frame yet; the session survives and asks again. - A picture can't be taken inside that session, so it is closed for each shot and opened again after. The live view freezes for about five seconds per shot. - What made the X-T5's live view stop after the first capture: the shot stays in the camera's temporary memory, gphoto2's own delete of the RAW fails, and the camera refuses the live view while anything is left there. That memory is now emptied after every shot. Only memory the camera reports as fixed and fetch-and-delete-only is emptied, never a card, and only after the shot's files are on disk. - To look at the film, the scanner waits for three live frames in a row in which nothing changes, then averages the next five. - The shot that is kept is checked: found more than 8 px off-center, the film is corrected by what the shot shows and the shot is taken once more. How far the shots come out from the live view is learned from them (median of the last five) and the next frames are aimed accordingly. A frame lined up by hand is shot where it was put. - A calibration records whether it was measured through the live view or in shots, and is only used the way it was made. - The page fetches frames from `GET /api/live/frame` and draws them on a canvas. What the real scanner showed, each fixed in a commit of its own: - **A frame's edge behind a soft fringe.** Between a gap and the picture a live view shows 3 to 8 columns as bright as the base but uneven. The 4 columns probed outside a bright run fell on them. The probe now reaches up to 8 columns further, and the edge is put at the first dense column. - **A frame that starts as clear as the base.** When a frame's dense edge borders a bright run on one side only, and from it to the run's other end is a gap's width (within 25%), the run is the gap and the other frame starts at its other end. Only ever one reading among the others: never paired into a frame seen with both edges, and nothing is worked out from it in turn. - **A gap seen from both sides is believed first.** An edge inside a picture could point somewhere else and veto the one reading that was right. - **A gap cut in two by grain.** A break of at most 6 columns, all as bright as the base and no more uneven than 0.04, no longer cuts a run. Tried first and dropped: measuring evenness on rows averaged together. It moved the frame on 14 of 93 still photos. - **The frame's width from the film's height.** The motor's scale (steps a millimetre on paper) put the frame 1 to 2.5% too narrow. The pressure frame's window is exactly as tall as a frame, so the film's height in the picture gives the pixels in a millimetre: 24 mm for 35mm film, 56 mm for 120, each format with its own length. The motor's scale is the cross-check (10%) and the fallback. - **A picture that trembles is at rest.** The limit between two live frames was crossed by a sideways shake of 0.02 px at the window's edge; measured on the rig, the room shakes the camera by 0.1 px. The limit goes from 0.01 to 0.1. - **Bright fringes are not the base.** A camera's sharpening leaves a column or two brighter than the film beside every sharp dark edge; with enough of them they set the base's level 0.04 too high and no gap was found. Lines thinner than 9 columns are now taken out before the level is read. The Python reference in `reference/` follows these, so `tools/parity.py` holds. ## Tested - `cargo test`: 235 passed, with a fake gphoto2 shell for the live camera and a simulated scanner whose photos can come out shifted from its live view. - `tools/parity.py`: SAME (325 synthetic pictures, 12 JPEG cases). - On the X-T5, camera alone: live frames through the app, three real shots in a row with the live view back after each, the camera's memory empty afterwards. - On the real scanner (X-T5 through its live view, Arduino, 35mm negatives, thin ones): calibration, Check framing and scans of a few frames at a time. Each fix above was tried there as it was made, in a build of this branch at that point: frames that were not found came to be found and centered. - On 98 full-size X-T5 scans of three rolls, read as still photos: bridging the breaks and the base's level without fringes change no frame when a frame width is given. Without one (not calibrated), bridging moves 5 of 94 found frames by more than 4 px, one of them clearly for the worse. ## Not tested - The branch as it now stands, as one build, has not scanned on the real scanner on its own: the last scans there ran the build of #21, which sits on top of it. - A full roll from end to end. The check of each photo against the live view was not looked at separately on the real scanner. - Whether a live frame and a photo show the film at the same scale on the X-T5 is not measured. - Slides, 120 film, panoramic frames: simulated scanner only. The film's height on a slide (dark where a negative is clear) relies on the cross-check with the motor's scale. - A pressure frame whose window is not exactly as tall as a frame. - macOS and Windows. ## Changes in behaviour - A calibration made before this has to be made again once: the app says "Calibrate again: the camera is now used with its live view". - A calibration needs the whole height of the pressure frame's window in the picture, with black above and below, to read the frame's width off it. Without, it falls back on the motor's scale as before. - Check framing no longer takes a picture when the camera has a live view. - With the live view running, the annotated still from Check framing and from each kept frame is no longer shown; the live view takes its place. - The command line uses the live view too. - Film still creeping by less than about a fifth of a pixel between two live frames now counts as stopped. - Not in this pull request: following the film while it moves (slip detection, frame edges known from many viewpoints). It needs recordings from the real scanner first.
The live view comes through one gphoto2 shell that stays running and is asked
for frame after frame (about 20 a second on the X-T5). It is closed for each
shot and opened again after.

What made the X-T5's live view stop after the first capture was the shot left
in the camera's temporary memory: that memory is now emptied after every shot.
Only memory the camera reports as fixed and fetch-and-delete-only is emptied,
never a card.

Frames are still centered from real shots. A camera that gives no live view is
used without one, as before.
It came in by mistake with the Rollscan rename (#9), whose branch was started
from feat/live-view instead of main. This puts main back to the rename and the
palette alone; the live view stays in its own pull request (#8).

Also points the repository links at its new name, rollscan.
The same work as before (0006fa0, 615ce2d), put back on top of the Rollscan
rename after it was taken out of main.
eliott changed title from Live view in the app, with the detector's findings drawn on it to WIP: Live view in the app, with the detector's findings drawn on it 2026-11-17 12:01:55 +01:00
eliott changed title from WIP: Live view in the app, with the detector's findings drawn on it to WIP: #12 - Live view in the app, with the detector's findings drawn on it 2026-11-17 12:02:21 +01:00
eliott self-assigned this 2026-11-17 12:03:49 +01:00
To look at the film the scanner waits for the live view to stop changing, then
averages five frames: no shot is taken to center a frame or to calibrate.

The shot that is kept is checked. Found more than 8 px off-center, the film is
corrected by what the shot shows and the shot is taken once more. How far the
shots come out from the live view is learned from them, and the next frames are
aimed accordingly. A frame lined up by hand is shot where it was put.

A calibration records whether it was measured through the live view or in
shots, and is only used the way it was made.
eliott changed title from WIP: #12 - Live view in the app, with the detector's findings drawn on it to WIP: #12 - Live view in the app, and centering through it 2026-11-17 18:08:37 +01:00
Between a gap and the picture, a live view can show a few columns as bright
as the base but too uneven to belong to the gap. The four columns probed
just outside the bright run then fell on that fringe, the dense picture
right after it was never seen, and no frame was found.

The probe now reaches up to 8 columns further out, and the edge is put at
the first dense column it finds.
On a thin negative a frame can start as clear as the base: the gap before it
is seen, the previous frame's dense end too, but this frame's own edge shows
nothing and no frame was found.

When a frame's dense edge borders a bright band on one side only, and from
that edge to the band's other end is a gap's width (within 25%), the band is
the gap and the other frame starts at its other end. Such an edge is only
ever good for a lone reading (partial, near the center, agreeing with the
others), and nothing is worked out from it in turn.
A gap with dense picture on both sides, a gap's width apart, placed the frame
correctly, but an edge inside the picture (where it turns as clear as the
base) put it somewhere else, and with two lone readings that disagree no
frame was found.

A lone reading from a gap seen from both sides now outweighs the others.
In a live view the bare base is close to too uneven to count as a gap, and a
speck of dust on it makes a few columns more so. From one picture to the next
a gap was cut in two, and when the piece left next to the frame was too
narrow to count, the frame's edge was lost.

A break of at most 6 columns, all as bright as the base and no more uneven
than 0.04, no longer cuts a bright run in two.
The frame and gap widths came from the motor: pixels a step, times the
drive's steps a millimetre on paper. On the real scanner that put the frame
1 to 2.5% too narrow, and a frame placed by one edge up to 10 px off center.

The pressure frame's window is exactly as tall as a frame, so the film's
height in the picture gives the pixels in a millimetre directly: 24 mm for
35mm film, standard or panoramic, 56 mm for 120. Each format's own length
then gives its frame and its gap. The motor's scale stays as the cross-check
and the fallback: it is used when the two are more than 10% apart, or the
window's top or bottom isn't in the picture.
A look at the film through the live view waits for 8 frames in a row that
differ by almost nothing. The limit, 0.01 in a column's mean brightness, is
crossed by a sideways shake of 0.02 px at the window's edge: in a room that
shakes the camera by a tenth of a pixel the picture never came to rest, and
calibration and scans stopped with that error.

The limit is now 0.1. Film that is still moving goes by whole pixels between
two frames and changes a column by far more.
The bare base's level was that of the brightest hundredth of the columns. A
camera sharpens its live view and leaves a column or two brighter than
anything on the film beside every sharp dark edge: the window's, and each
dense bar in a picture. With enough of them the level was set by fringes,
the real gaps came out just too dark to count, and no gap was found at all.

The level is now taken once lines thinner than 9 columns are taken out.
The fixes made to the detector for the live view were not made in the Python
it was ported from, and tools/parity.py found the two apart on one picture
(a slide read from a JPEG, half a pixel). The reference now takes the base's
level without the thin bright lines, bridges short breaks in a gap, looks
past a soft fringe for a frame's edge, takes a gap-wide run after a frame's
dense end for the gap, and believes a gap seen from both sides first.

tools/parity.py: SAME.
The live view fixes were only in the table of knobs. Also: the frame's width
comes from the film's height (how-it-works), what has been run on the real
scanner (README), and a camera that shakes (troubleshooting).
eliott changed title from WIP: #12 - Live view in the app, and centering through it to #12 - Live view in the app, and centering through it 2026-11-17 22:52:40 +01:00
eliott merged commit 59b83f4f15 into main 2026-11-17 22:55:01 +01:00
eliott deleted branch feat/live-view 2026-11-17 22:55:01 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
RollNote/rollscan!8
No description provided.