Ответсообщение недоступно
Верно, для полусотни строк это лишнее. Вот тем же куском, вставляется целиком:
cat > ~/lanekit/shots.sh <<'SH'
#!/bin/sh
# Sweep the lens, render every frame to PNG and pack the lot into one archive.
W=${W:-4000}; H=${H:-3000}; PAT=${PAT:-rggb}; BLOCK=${BLOCK:-4}
EXPOSURE=${EXPOSURE:-3006}; GAIN=${GAIN:-960}
POSITIONS=${POSITIONS:-"0 200 400 600 800 1000"}
PREVIEW=${PREVIEW:-$HOME/raw10preview}
OUT=/tmp/shots
command -v convert >/dev/null || { echo "imagemagick is not installed"; exit 1; }
[ -x "$PREVIEW" ] || { echo "no raw10preview at $PREVIEW"; exit 1; }
rm -rf $OUT; mkdir -p $OUT
D=$(media-ctl -d /dev/media0 -e "dw9768 12-000c" 2>/dev/null)
sed -i "s/^W=[0-9]*/W=$W/; s/^H=[0-9]*/H=$H/" capture.sh
for f in $POSITIONS; do
if [ -n "$D" ]; then
v4l2-ctl -d "$D" --set-ctrl focus_absolute=$f >/dev/null 2>&1
sleep 1
fi
EXPOSURE=$EXPOSURE GAIN=$GAIN sh capture.sh $OUT/f$f.raw >/dev/null 2>&1
sz=$(stat -c %s $OUT/f$f.raw 2>/dev/null || echo 0)
[ "$sz" -lt 1000 ] && { echo "position $f: no frame"; continue; }
line=$("$PREVIEW" $OUT/f$f.raw $OUT/f$f.ppm $W $H $PAT $BLOCK 2>&1 | tail -1)
convert $OUT/f$f.ppm $OUT/f$f.png && rm -f $OUT/f$f.ppm $OUT/f$f.raw
echo "position $f: $line"
done
tar czf /tmp/shots.tar.gz -C /tmp shots
ls -l /tmp/shots.tar.gz
SH
cd ~/lanekit && sh shots.sh
Дальше по вкусу:
W=8000 H=6000 PAT=quad sh shots.sh # полный кадр
POSITIONS="300 400 500 600" sh shots.sh # только интересный участок
💰 21.70₽ · ⬇️ 903.6k / ⬆️ 1.0k · opus-5 · max · 13с