VISION RECYCLING - BENCH COUNTER
Counts each TV / panel put on the dismantling bench once, and saves a photo of it.

START: double-click start.bat. Chrome opens http://localhost:8765 . Allow the camera.
(Opening index.html directly also works for "Test with video file", but the webcam needs start.bat.)

SETTINGS (PIN 1234): pick camera, "Test with video file", draw the bench zone, calibrate empty bench,
sensitivity sliders, snapshot download/delete. Reset count also needs the PIN.

HOW IT COUNTS
- Looks for a large smooth dark area (a screen/panel) inside the bench zone. The grate is textured so it is ignored.
- The item must be there for 3 s before it counts. It then stays "Item on bench" while it is moved,
  turned over, taken apart (black back -> white inside) or covered by hands.
- A new item only counts after the zone has been clear for 5 s.
- If something covers the camera (someone walking
  across, a head over the lens), it shows "Paused - view blocked" and does not count. Only a near-total cover of the lens (over 70% of the whole picture) pauses it, and never for more than 3 s at a time. Dark shapes coming in from the picture edge (people leaning in) are never counted. Lighting changes are evened out automatically.
- It learns the empty bench by itself when the bench is clear and still, and slowly adapts; tools left on the
  bench become background.
- Snapshot = the stillest frame in the first 12 s after counting. Stored in the browser (IndexedDB);
  click a snapshot to download it. Export CSV lists every item.
TIPS: draw the zone around the grate only. If a TV is missed, lower "Item size to count" or raise "Dark level".

PEOPLE, CLIPS AND ZOOM (Nov 2026 update)
- A dark shape only counts if it looks like a TV: solid and not too long and thin, still inside for the whole
  3 seconds, and not a small object held by a person (a small dark thing joined to a moving body at the zone
  edge is ignored). A big TV with hands on it still counts.
- Draw the bench zone tightly around the bench top. A person standing still in dark clothes INSIDE the zone
  can still look like a TV, so leave where people stand outside the zone.
- Clips: if something sits on the bench for 15 s and isn't counted, the last ~10 s is saved as a video clip
  (shown in the gallery as "Not counted · clip", with a Download link). Turn this off in Settings.
- Camera zoom (Settings): zoom 1-4x with pan left/right and up/down, or "Drag a box to zoom". Counting,
  snapshots and clips all use the zoomed picture. If the camera has its own zoom it is used first.
  Changing zoom relearns the empty bench - keep the bench clear for a few seconds afterwards, and redraw the zone.

HANDLED ITEMS, WHITE-BACKED PANELS, NO DUPLICATES (update)
- Dark items AND light/white-backed panels (bright, smooth, colourless areas that are not part of
  the empty bench) are detected.
- An item being carried or tilted counts once a clearly rectangular shape has been in the zone for
  about 4 seconds in total, even if it never stays still.
- No duplicates: one "occupancy session" = at most one count. A new count is only possible after the
  zone has been still and empty (matching the learnt empty bench) for 5 seconds. Moving or partly
  hiding an item does not start a new session.
- "Add to count" button on every "Not counted" clip: one tap counts it, using the clip's still frame as
  the snapshot. It is greyed out ("Already counted") if that session was already counted.
