Files
Microscope-Display/system/microscope-camera.service
Microscope Camera 34cd247dca Microscope camera kiosk
Touchscreen kiosk for the Raspberry Pi HQ camera (IMX477) used as a
microscope: live preview from boot, raw frame recording, full-resolution
stills, and automatic capture-SSD mounting.

- app.py: GTK3 fullscreen UI over cage — preview, REC/STOP, PHOTO,
  90-degree rotate button, tap-to-open exposure/gain/settings sliders,
  and an "SSD NOT MOUNTED" badge
- camera.py: picamera2 wrapper with separate video (ISP preview + packed
  12-bit raw) and still (4056x3040) configurations
- recorder.py: writer thread turning the raw stream into one Bayer frame
  per file plus index.jsonl/session.json, with dropped/missed accounting
- photos.py: still capture to DNG + JPEG, and a background worker that
  renders a viewable 16-bit sRGB TIFF from the 12-bit Bayer frame
- storage.py: SSD mount state and the date/time/format session layout
- tools/unpack_raw.py: desktop-side unpacker/demosaicer
- system/ + install.sh: systemd units, udev rule, mount helper, sudoers

Note: raw frames are written byte-for-byte as the sensor produced them, so
they stay decodeable regardless of how the stills pipeline evolves.
2026-10-31 00:44:46 -04:00

36 lines
1007 B
Desktop File

[Unit]
Description=Microscope camera kiosk (cage + capture UI)
Documentation=file:/opt/microscope-camera/README.md
After=systemd-user-sessions.service systemd-logind.service
Wants=systemd-logind.service
Conflicts=getty@tty1.service
After=getty@tty1.service
ConditionPathExists=/opt/microscope-camera/app.py
[Service]
Type=simple
User=tyler
Group=tyler
# A logind session on tty1 gives cage DRM master plus input device access.
PAMName=login
TTYPath=/dev/tty1
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
StandardInput=tty
StandardOutput=journal
StandardError=journal
Environment=XDG_RUNTIME_DIR=/run/user/1000
Environment=HOME=/home/tyler
Environment=PYTHONUNBUFFERED=1
ExecStartPre=/bin/sh -c 'install -d -m 700 -o tyler -g tyler /run/user/1000'
ExecStart=/usr/bin/cage -s -- /usr/bin/python3 /opt/microscope-camera/app.py
Restart=always
RestartSec=2
# Keep the recorder alive long enough to flush its last frames on restart.
KillSignal=SIGTERM
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target