Skip to content

Instantly share code, notes, and snippets.

@makcuk
Created February 25, 2026 21:24
Show Gist options
  • Select an option

  • Save makcuk/36481e472af579e2641697460a63f640 to your computer and use it in GitHub Desktop.

Select an option

Save makcuk/36481e472af579e2641697460a63f640 to your computer and use it in GitHub Desktop.
If you need to run YOLO inference on radxa zero 3w with radxa camera you need to downscale to 640x480
#!/bin/bash
set -euo pipefail
MEDIA=/dev/media0
# 0) stop anything that may grab ISP
pkill -9 -f rkaiq_3A_server 2>/dev/null || true
fuser -k /dev/video0 /dev/video1 /dev/video2 /dev/video8 /dev/video9 $MEDIA 2>/dev/null || true
sleep 0.2
# 1) reset graph
media-ctl -d $MEDIA -r
# 2) enable links (imx219 -> dphy -> csi -> isp -> mainpath, plus raw writer)
media-ctl -d $MEDIA -l '"m00_b_imx219 2-0010":0->"rockchip-csi2-dphy0":0[1]'
media-ctl -d $MEDIA -l '"rockchip-csi2-dphy0":1->"rkisp-csi-subdev":0[1]'
media-ctl -d $MEDIA -l '"rkisp-csi-subdev":1->"rkisp-isp-subdev":0[1]'
media-ctl -d $MEDIA -l '"rkisp-isp-subdev":2->"rkisp_mainpath":0[1]'
media-ctl -d $MEDIA -l '"rkisp-csi-subdev":2->"rkisp_rawwr0":0[1]'
# 3) formats along the RAW chain
media-ctl -d $MEDIA --set-v4l2 '"m00_b_imx219 2-0010":0[fmt:SRGGB10_1X10/1920x1080]'
media-ctl -d $MEDIA --set-v4l2 '"rockchip-csi2-dphy0":0[fmt:SRGGB10_1X10/1920x1080]'
media-ctl -d $MEDIA --set-v4l2 '"rkisp-csi-subdev":0[fmt:SRGGB10_1X10/1920x1080]'
# 4) ISP sink format + crop (keep full FOV, no crop-to-640; downscale via /dev/video0 format)
media-ctl -d $MEDIA --set-v4l2 '"rkisp-isp-subdev":0[fmt:SRGGB10_1X10/1920x1080]'
media-ctl -d $MEDIA --set-v4l2 '"rkisp-isp-subdev":0[crop:(0,0)/1920x1080]'
# 5) start AIQ (3A)
nohup /usr/bin/rkaiq_3A_server >/var/log/rkaiq_3A_server.log 2>&1 &
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment