Keep blank frames and new cameras off the home page's mosaic - #382
Conversation
The mosaic on openipc.org's front page showed whatever a camera sent last: on 2026-10-03 a flat grey frame with a clock on it (280228abf9b1e84c5ee8) and a white one (878a7b98ed37538b9b91). And any camera, new that day, could put a picture of its choosing there within fifteen minutes. - Each frame's brightness percentiles (5th, median, 95th of a 64x36 greyscale copy) are measured from the decode it is already checked with: Go's JPEG decode, or ffmpeg's for a HEIF keyframe, which now writes the greyscale copy instead of a framemd5. Stored on the row (migration 022). - The mosaic reads Store.Showcase: the newest measured frame per camera, leaving out a flat one (spread < 16), a blown-out one (median >= 245), a black one (95th < 20), and any camera first seen less than 30 days ago. The gallery is unchanged. - cameras(mac_key, first_seen), written by a trigger on every upload and never purged, since snapshots are kept two days. Calibrated on the 4,123 frames on the wall: 309 fall under the rule, every one of them flat grey or white, a night frame with no light, or a garden camera blown out to white; frames with a spread of 24 or more were real scenes. The Go measurement agreed with an independent one (Pillow) on 4,121 of them; the other two sit on a threshold.
PR Summary by QodoKeep blank frames and new cameras off the home page mosaic
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1.
|
Review of #382 (Qodo): - One upload a month ago, or a MAC invented then, was enough: first_seen came from a trigger on every inserted row, refused uploads included. cameras now keeps the first accepted frame and the number of UTC days with one, written by MarkGenerated in the same statement that marks the frame; Showcase also requires ShowcaseMinDays (20) days. - A JPEG smaller than the 64x36 copy measured 0/0/0 and was dropped as black; it is now sampled, each cell reading at least one pixel. - The conformance mosaic test uploaded the default JPEG -- a header and padding the wall refuses -- under a new MAC and expected a tile. It now uploads a real picture, requires it absent while the camera is new, and present once the database says the camera is established; the suite's cleanup removes its cameras rows.
|
Review addressed in e3e095d:
Deployment note: the 17 cameras seeded from the off-site backups (seen 2026-08-21…29 and still uploading) will be seeded with |
The mosaic on openipc.org's front page shows whatever a camera sent last. On 2026-10-03 that included a flat grey frame with only the camera's clock on it (280228abf9b1e84c5ee8) and a white one (878a7b98ed37538b9b91). And any camera, new that day, could put a picture of its choosing there within fifteen minutes.
Change
Brightness, measured once. Each frame's 5th / 50th / 95th brightness percentiles over a 64×36 greyscale copy, taken from the decode it is already checked with: Go's JPEG decode, or ffmpeg's for a HEIF keyframe (which now writes the greyscale copy instead of a
framemd5). Stored on the row —snapshots.luma_p5/p50/p95, migration 022. Nothing a camera sends is re-encoded.Store.Showcasefor/api/v1/wall/mosaic.json: the newest measured frame per camera, leaving outThe gallery (
/open-wall,page/N.json) is unchanged.cameras (mac_key, first_seen), written by a trigger on every upload and never purged (snapshots are kept two days), and backfilled from the snapshots present when the migration runs.Calibration on the 4,123 frames on the wall: 309 fall under the rule — all flat grey or white, a night frame with no light, or one garden camera blown out to white. Frames with a spread of 24 or more were real scenes. The Go measurement, run over every frame on the production wall, agreed with an independent one (Pillow) on 4,121 of 4,123; the other two sit exactly on a threshold.
Tests:
TestShowcase(a scene shown; grey-with-clock, white, black and a month-old camera that went flat left out; an unmeasured newest frame falls back to the measured one before it; a new camera ages in),TestCamerasFirstSeen(written once, any MAC spelling, survives the purge),TestLumaOfJPEG(a flat frame with a clock overlay measures flat; a gradient does not),TestCheckDecodes(testsrc through ffmpeg measures as a picture).After merge — not part of the code:
first_seenfor 17 cameras from the off-site backups older than 30 days (MAC and date only,LEASTwith what the migration wrote).Preview from today's data: of 21 cameras active, 11 qualify; the 10 left out are 9 first seen this week (several of them probably older, but absent from the three two-day backups) and "The shelf", whose newest frame is the grey one above.