Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

Grow cameras: a saved camera profile per Pi camera, re-applied at every start, and a Tune panel with the box drawn once and colour correction under grow light #591

Merged opened this in answer to

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

Every camera now has a saved look: a profile on the Pi (exposure, white balance, gain, focus, backlight compensation), a region the owner draws once, and a colour correction. The owner sets it from **/admin → Cameras → Tune**. The Pi puts the profile back on the camera each time the camera service starts.

shipped merged

opened this

Every camera now has a saved look: a profile on the Pi (exposure, white balance, gain, focus, backlight compensation), a region the owner draws once, and a colour correction. The owner sets it from /admin → Cameras → Tune. The Pi puts the profile back on the camera each time the camera service starts.

What to look at

  • Profile: src/camera-profile.ts checks the profile and turns it into v4l2-ctl --set-ctrl calls, one control per call, auto modes before fixed values. Each call is an argument list, never a shell.
  • Pi side: src/camera-control.ts reads camera n's device from /etc/so101/camera<n> and keeps the profile in camera-profiles/<n>.json beside the poses. A control the camera lacks is reported and the rest still go on.
  • Arm server: GET/PUT /camera-profile/<n>[?try=1]. Only so101 serve passes in the code that runs v4l2-ctl, so the forge's simulation never runs it and answers 501.
  • CLI: so101 camera-profile <n> re-applies the saved profile from the camera service's ExecStartPre. The README has the unit drop-in and a udev rule for re-plugs. With no profile saved it leaves the camera alone and exits 0, so the stream still starts.
  • Relay: PUT /admin/cameras/<id> saves the look and sends the profile to the Pi to keep; POST /admin/cameras/<id>/try puts it on the camera without keeping it. Both are owner-only. The relay answers 404 to any request for /camera-profile/*, so only these two routes reach it.
  • Pixels: src/ui/still-frame.js holds the pure maths. The region is stored as fractions of the frame, so it crops the 640×360 stream and a 1920×1080 still the same way. Gray-world correction skips blown-out and black pixels and caps each channel at ×4. There is also a white-card variant. The visibility check gives the "Camera can't see the plants…" hint.
  • Tune panel (src/camera-list.html):

- a snapshot every second; drag on it to mark the box; - each control can be leave, auto or fixed, and a slider goes on the camera after a short pause; - Grow-box settings loads the 2026-10-26 hand-tuned values; - Measure colour shows the box marked "corrected" next to the raw picture; - the visibility verdict sits under the pictures, and Save keeps everything.

Not done here

  • Full-res 1920×1080 stills, cropped and corrected, and the optional photo light: there are no stills until #583, and ustreamer holds the camera device. Split off as #589, waiting on #583.
  • The hint on the grow card: there is no grow card until #581. Split off as #590, waiting on #581.
  • No new dependencies. A profile only reaches the camera while the arm server is running on the Pi, which needs the arm plugged in until #581 lands.
  • The README's ExecStartPre line uses placeholders for the tree and poses.json paths, because the Pi's live paths aren't in the repo.

Tests: camera-profile.test.ts, still-frame.test.ts and camera-tune.test.ts cover the issue's list:

  • a saved profile → the v4l2-ctl calls the camera service runs;
  • the crop maths at 64×36, 640×360 and 1920×1080;
  • gray-world correction on a fixture image of the box under blue light;
  • an overexposed overhead view flagged as blown out.

They also cover owner-only access, the cross-site refusal and bad input being refused before anything runs. These plus the hub, page-parse, README and admin-page suites pass (51), and the server, relay and CLI suites pass (108). The app boots and / answers in 67 ms. The local Node is v20, so the CLI was tested through Bun, not Node 24 as on the Pi. I haven't seen the Tune panel in a browser. The full type check still reports errors in files this change doesn't touch; the files it does touch are clean.

Try it: open /admin → Cameras → Tune on a camera, press Grow-box settings, drag over the box, press Measure colour, then Save. On the Pi, so101 camera-profile 2 prints what it set.

🤖 Generated with Claude Code

Closes #584

2 earlier comments · 1 event
commented

Every camera now has a saved look: a profile on the Pi (exposure, white balance, gain, focus, backlight compensation), a region the owner draws once, and a colour correction. The owner sets it from /admin → Cameras → Tune. The Pi puts the profile back on the camera each time the camera service starts.

What to look at

  • Profile: src/camera-profile.ts checks the profile and turns it into v4l2-ctl --set-ctrl calls, one control per call, auto modes before fixed values. Each call is an argument list, never a shell.
  • Pi side: src/camera-control.ts reads camera n's device from /etc/so101/camera<n> and keeps the profile in camera-profiles/<n>.json beside the poses. A control the camera lacks is reported and the rest still go on.
  • Arm server: GET/PUT /camera-profile/<n>[?try=1]. Only so101 serve passes in the code that runs v4l2-ctl, so the forge's simulation never runs it and answers 501.
  • CLI: so101 camera-profile <n> re-applies the saved profile from the camera service's ExecStartPre. The README has the unit drop-in and a udev rule for re-plugs. With no profile saved it leaves the camera alone and exits 0, so the stream still starts.
  • Relay: PUT /admin/cameras/<id> saves the look and sends the profile to the Pi to keep; POST /admin/cameras/<id>/try puts it on the camera without keeping it. Both are owner-only. The relay answers 404 to any request for /camera-profile/*, so only these two routes reach it.
  • Pixels: src/ui/still-frame.js holds the pure maths. The region is stored as fractions of the frame, so it crops the 640×360 stream and a 1920×1080 still the same way. Gray-world correction skips blown-out and black pixels and caps each channel at ×4. There is also a white-card variant. The visibility check gives the "Camera can't see the plants…" hint.
  • Tune panel (src/camera-list.html):

- a snapshot every second; drag on it to mark the box; - each control can be leave, auto or fixed, and a slider goes on the camera after a short pause; - Grow-box settings loads the 2026-10-26 hand-tuned values; - Measure colour shows the box marked "corrected" next to the raw picture; - the visibility verdict sits under the pictures, and Save keeps everything.

Not done here

  • Full-res 1920×1080 stills, cropped and corrected, and the optional photo light: there are no stills until #583, and ustreamer holds the camera device. Split off as #589, waiting on #583.
  • The hint on the grow card: there is no grow card until #581. Split off as #590, waiting on #581.
  • No new dependencies. A profile only reaches the camera while the arm server is running on the Pi, which needs the arm plugged in until #581 lands.
  • The README's ExecStartPre line uses placeholders for the tree and poses.json paths, because the Pi's live paths aren't in the repo.

Tests: camera-profile.test.ts, still-frame.test.ts and camera-tune.test.ts cover the issue's list:

  • a saved profile → the v4l2-ctl calls the camera service runs;
  • the crop maths at 64×36, 640×360 and 1920×1080;
  • gray-world correction on a fixture image of the box under blue light;
  • an overexposed overhead view flagged as blown out.

They also cover owner-only access, the cross-site refusal and bad input being refused before anything runs. These plus the hub, page-parse, README and admin-page suites pass (51), and the server, relay and CLI suites pass (108). The app boots and / answers in 67 ms. The local Node is v20, so the CLI was tested through Bun, not Node 24 as on the Pi. I haven't seen the Tune panel in a browser. The full type check still reports errors in files this change doesn't touch; the files it does touch are clean.

Try it: open /admin → Cameras → Tune on a camera, press Grow-box settings, drag over the box, press Measure colour, then Save. On the Pi, so101 camera-profile 2 prints what it set.

🤖 Generated with Claude Code

Changes requested — before the latest push

The profile, crop maths and owner-only routes look sound, and the preview boots and serves /admin/camera-list. Two experience misses block it, though. I could not see the Tune panel in a browser, and neither could the builder, so these come from reading the CSS and JS.

Fix first: the Tune panel is unusable on a 360px phone. .ctl is a fixed grid of 7.5rem + 6.5rem + 1fr + 4rem, which is 18rem (288px) plus gaps. That leaves about 15px for the slider on a 360px screen. Stack each control at narrow widths: label and mode on one line, slider and output on the next.

Second: marking the box can only be done by dragging with a pointer. A keyboard or screen-reader user cannot set the region. The only alternative is "Whole frame". Add four number inputs (x, y, w, h as percentages) beside the canvas, bound to the same region. Give the canvas a text alternative that says what it is.

Smaller points:

  • The whole panel needs JavaScript. That is fine for an admin tool, but say so in a <noscript> line.
  • sayPi and #seen are role=status, which is good. The Save result goes to a different live region than errors do, so errors from say() and results from sayPi can be missed. Put them in one place.
  • In camera-tune.test.ts the dataDir and void dataDir in the owner-only test are dead code. Remove them.
  • There is no tty.ts door for tuning a camera. so101 camera-profile applies a saved profile but cannot set or save one. Either add it or say in the README that tuning is page-only on purpose.
  • Full-res cropped stills are split to #589 and the grow-card hint to #590. That is fine, but the title promises them, so retitle the pull.
commented

Every camera now has a saved look: a profile on the Pi (exposure, white balance, gain, focus, backlight compensation), a box the owner marks once, and a colour correction. The owner sets it from /admin → Cameras → Tune. The Pi puts the profile back on the camera each time the camera service starts.

Changed after review

  • Phone: under 34rem each control stacks. The label and its leave/auto/fixed choice sit on one line; the slider (44 px tall, full width) and its value go on the line below. Wider screens keep the four-column grid.
  • Without a pointer: four number inputs (Left, Top, Width, Height, in percent) set the same box as dragging, and follow it when you drag.

- The checks are regionFromPercent / regionToPercent in src/ui/still-frame.js. A box pushed past an edge is cut at the edge. - The fieldset's legend describes the box, and the canvas points to it. Both canvases are role="img" with a text description.

  • One status line: the panel has a single live line, #note, for Save and try results and for every error. #seen stays separate, for whether the camera can see the box. The <noscript> line now mentions tuning.
  • Terminal: tuning stays page-only on purpose, and the README says why: you judge an exposure by looking at the picture, which the terminal can't show. so101 camera-profile only re-applies what the panel saved.
  • The dead dataDir in camera-tune.test.ts is gone, and the pull is retitled. Full-res stills and the photo light are #589 (waiting on #583); the grow-card hint is #590 (waiting on #581).

What to look at

  • Profile: src/camera-profile.ts checks the profile and turns it into v4l2-ctl --set-ctrl calls, one control per call, auto modes before fixed values. Each call is an argument list, never a shell.
  • Pi side: src/camera-control.ts reads camera n's device from /etc/so101/camera<n> and keeps its profile in camera-profiles/<n>.json beside the poses.
  • Arm server: PUT /camera-profile/<n>[?try=1]. Only so101 serve passes in the code that runs v4l2-ctl, so the forge's simulation never runs it.
  • CLI: so101 camera-profile <n> re-applies the saved profile from the camera service's ExecStartPre. The README has the unit drop-in and a udev rule for re-plugs.
  • Relay: PUT /admin/cameras/<id> saves the look and sends the profile to the Pi; POST …/try puts it on the camera without keeping it. Both are owner-only. The relay answers 404 to any request for /camera-profile/*.
  • Pixels: src/ui/still-frame.js crops to the box, applies gray-world or white-card correction, and runs the visibility check that gives "Camera can't see the plants…".

Tests: the new page tests read the HTML and CSS, so they check structure, not a rendered page. They fail without the phone stack, the box inputs or the single status line. 45 tests across the camera suites, the page-parse test and the README test pass, and the type check is clean in the files this pull touches. Neither the reviewer nor I have seen the panel in a browser yet.

Try it: open /admin → Cameras → Tune on a phone. Press Grow-box settings, type a box (for example 30 / 25 / 40 / 50), press Measure colour, then Save.

🤖 Generated with Claude Code

commented

Every camera now has a saved look: a profile on the Pi, a box the owner marks once, and a colour correction. The owner sets it from /admin → Cameras → Tune. Until a profile is saved, each camera gets the settings the owner chose by hand on 2026-10-26. The Pi puts the profile back on the camera each time the camera service starts, so both settings survive a re-plug or reboot from the first deploy on.

The owner's settings as defaults (OWNER_DEFAULTS in src/camera-profile.ts, by so101-camera unit):

  • Camera 1, side XWF-1080P on :8080: auto exposure, auto white balance, backlight_compensation=1.
  • Camera 2, overhead eMeet C960 on :8081: brightness=115 contrast=120 saturation=150.
  • Brightness, contrast and saturation are new in the profile and on the Tune panel. They are checked like the other controls; the brightness range allows the -64..64 kind of camera as well as 0..255.
  • Relay: a new camera on the Pi's ports starts from its unit's default, and so does an existing camera list that has no look yet.
  • Pi: so101 camera-profile <n> applies the default when nothing is saved, and GET /camera-profile/<n> returns {unit, saved, profile}. A unit with no default is left alone, and a control the camera refuses is reported without failing the stream's start.

What to look at

  • Profile: src/camera-profile.ts checks the profile and turns it into v4l2-ctl --set-ctrl calls, one control per call, auto modes before fixed values. Each call is an argument list, never a shell.
  • Pi side: src/camera-control.ts reads camera n's device from /etc/so101/camera<n> and keeps its profile in camera-profiles/<n>.json beside the poses.
  • Arm server: PUT /camera-profile/<n>[?try=1]. Only so101 serve passes in the code that runs v4l2-ctl, so the forge's simulation never runs it.
  • CLI: so101 camera-profile <n> runs from the camera service's ExecStartPre. The README has the unit drop-in and a udev rule for re-plugs.
  • Relay: PUT /admin/cameras/<id> saves the look and sends the profile to the Pi; POST …/try puts it on the camera without keeping it. Both are owner-only. The relay answers 404 to any request for /camera-profile/*.
  • Pixels: src/ui/still-frame.js crops to the box, applies gray-world or white-card correction, and runs the visibility check that gives "Camera can't see the plants…".
  • Tune panel:

- each control stacks under 34rem, so it works on a 360 px phone; - the box can be set by dragging or with four percent inputs, and both canvases have a text description; - one status line takes results and errors alike; - tuning is page-only on purpose, because you judge an exposure by looking at the picture.

Not done here: full-res 1920×1080 stills and the photo light are #589 (waiting on #583), and the grow-card hint is #590 (waiting on #581). A saved profile reaches the camera only while the arm server is running on the Pi, which needs the arm plugged in until #581 lands.

Tests: new tests check that each owner default turns into the v4l2-ctl calls that were typed by hand. They also check a new camera's starting look, the server's GET, and the CLI with and without a default. The tests across the camera suites, the page-parse test and the README test pass (49, then 2), and the type check is clean in the files this pull touches. The Tune panel hasn't been seen in a browser.

Try it: open /admin → Cameras → Tune on the overhead camera. It opens at brightness 115, contrast 120, saturation 150; press Save to keep it. On the Pi, so101 camera-profile 2 applies the same settings even before anything is saved.

🤖 Generated with Claude Code

Approved

Approved. The profile is checked at the boundary and run through execFile with an argument list, never a shell. Both owner routes are owner-only with a same-origin check, and the relay answers 404 to /camera-profile/*. The owner defaults and the phone stack for the Tune panel are tested. The preview answers 200 on / and /admin/camera-list. I could not read the relay.ts and server.ts hunks (the diff was cut) and did not see the panel in a browser. Next: (1) have the Tune panel say when a slider try failed on the Pi, not only in the status line, and add a keyboard path for pickup of the drag box beyond the percent inputs, such as arrow-key nudging. (2) Ship the terminal door for tune with show/set once #581 lands, so the profile can be set from the Pi without a browser. The README says why it is page-only for now.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs