Commit 3d6ffb31 authored by Simpson, Thomas's avatar Simpson, Thomas
Browse files

Initial commit

parents
This diff is collapsed.
### Determine which quad-camera platform being used
### Note: This script currently only supports ZCU102, ZCU104, and UltraZed-EV
if [[ `hostname` == "zcu102_mc4" ]]; then
N=24
elif [[ `hostname` == "zcu104_mc4" ]]; then
N=11
elif [[ `hostname` == "uz7evcc_mc4" ]]; then
N=7
fi
### Set the number of camera streams to 4
yavta --no-query -w '0x0098c981 4' /dev/v4l-subdev4
### Set the image sensor resolution and format
media-ctl -d /dev/media0 -V "\"AR0231.$N-0011\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0012\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0013\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0014\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
### Set the SERDES resolution and format
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":1 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":2 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":3 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":4 [fmt:SGRBG8/1920x4320 field:none colorspace:srgb]"
### Set up the CSI Rx subsystem resolution and format
media-ctl -d /dev/media0 -V '"a0060000.csiss":0 [fmt:SGRBG8/1920x4320 field:none]'
media-ctl -d /dev/media0 -V '"a0060000.csiss":1 [fmt:SGRBG8/1920x4320 field:none]'
### Setup the AXI Switch resolution and format
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":0 [fmt:SGRBG8/1920x4320 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":1 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":2 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":3 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":4 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
### Set Camera 0 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b0040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 1 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b1040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 2 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b2040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 3 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b3040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Brightness of CSC to 100%
echo 'Setting brightness to 100%'
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev10
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev11
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev12
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev13
gst-launch-1.0 \
v4l2src device=/dev/video2 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaifacedetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=30 \
render-rectangle=\"<0,0,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video3 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaifacedetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=31 \
render-rectangle=\"<640,0,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video4 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaifacedetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=32 \
render-rectangle=\"<0,360,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video5 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaifacedetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=33 \
render-rectangle=\"<640,360,640,360>\"" sync=false fullscreen-overlay=true \
\
#-v
### Set brightness of CSC back to 50%
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev10
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev11
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev12
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev13
### Determine which quad-camera platform being used
### Note: This script currently only supports ZCU102, ZCU104, and UltraZed-EV
if [[ `hostname` == "zcu102_mc4" ]]; then
N=24
elif [[ `hostname` == "zcu104_mc4" ]]; then
N=11
elif [[ `hostname` == "uz7evcc_mc4" ]]; then
N=7
fi
### Set the number of camera streams to 4
yavta --no-query -w '0x0098c981 4' /dev/v4l-subdev4
### Set the image sensor resolution and format
media-ctl -d /dev/media0 -V "\"AR0231.$N-0011\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0012\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0013\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0014\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
### Set the SERDES resolution and format
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":1 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":2 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":3 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":4 [fmt:SGRBG8/1920x4320 field:none colorspace:srgb]"
### Set up the CSI Rx subsystem resolution and format
media-ctl -d /dev/media0 -V '"a0060000.csiss":0 [fmt:SGRBG8/1920x4320 field:none]'
media-ctl -d /dev/media0 -V '"a0060000.csiss":1 [fmt:SGRBG8/1920x4320 field:none]'
### Setup the AXI Switch resolution and format
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":0 [fmt:SGRBG8/1920x4320 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":1 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":2 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":3 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":4 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
### Set Camera 0 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b0040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 1 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b1040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 2 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b2040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 3 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b3040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Brightness of CSC to 100%
echo 'Setting brightness to 100%'
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev10
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev11
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev12
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev13
gst-launch-1.0 \
v4l2src device=/dev/video2 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaipersondetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=30 \
render-rectangle=\"<0,0,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video3 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaipersondetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=31 \
render-rectangle=\"<640,0,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video4 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaipersondetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=32 \
render-rectangle=\"<0,360,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video5 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaipersondetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=33 \
render-rectangle=\"<640,360,640,360>\"" sync=false fullscreen-overlay=true \
\
#-v
### Set brightness of CSC back to 50%
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev10
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev11
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev12
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev13
### Determine which quad-camera platform being used
### Note: This script currently only supports ZCU102, ZCU104, and UltraZed-EV
if [[ `hostname` == "zcu102_mc4" ]]; then
N=24
elif [[ `hostname` == "zcu104_mc4" ]]; then
N=11
elif [[ `hostname` == "uz7evcc_mc4" ]]; then
N=7
fi
### Set the number of camera streams to 4
yavta --no-query -w '0x0098c981 4' /dev/v4l-subdev4
### Set the image sensor resolution and format
media-ctl -d /dev/media0 -V "\"AR0231.$N-0011\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0012\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0013\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"AR0231.$N-0014\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
### Set the SERDES resolution and format
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":0 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":1 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":2 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":3 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]"
media-ctl -d /dev/media0 -V "\"MAX9286-SERDES.$N-0048\":4 [fmt:SGRBG8/1920x4320 field:none colorspace:srgb]"
### Set up the CSI Rx subsystem resolution and format
media-ctl -d /dev/media0 -V '"a0060000.csiss":0 [fmt:SGRBG8/1920x4320 field:none]'
media-ctl -d /dev/media0 -V '"a0060000.csiss":1 [fmt:SGRBG8/1920x4320 field:none]'
### Setup the AXI Switch resolution and format
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":0 [fmt:SGRBG8/1920x4320 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":1 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":2 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":3 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media0 -V '"amba:axis_switch@0":4 [fmt:SGRBG8/1920x1080 field:none colorspace:srgb]'
### Set Camera 0 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b0040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b0080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 1 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b1040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b1080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 2 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b2040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b2080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Camera 3 capture pipeline properties, resize from 1920x1080 to 640x360
media-ctl -d /dev/media0 -V '"b3040000.v_demosaic":0 [fmt:SGRBG8/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3040000.v_demosaic":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3060000.csc":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3060000.csc":1 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3080000.scaler":0 [fmt:RBG24/1920x1080 field:none]'
media-ctl -d /dev/media0 -V '"b3080000.scaler":1 [fmt:RBG24/640x360 field:none]'
### Set Brightness of CSC to 100%
echo 'Setting brightness to 100%'
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev10
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev11
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev12
yavta --no-query -w '0x0098c9a1 100' /dev/v4l-subdev13
gst-launch-1.0 \
v4l2src device=/dev/video2 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaipersondetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=30 \
render-rectangle=\"<0,0,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video3 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaifacedetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=31 \
render-rectangle=\"<640,0,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video4 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaifacedetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=32 \
render-rectangle=\"<0,360,640,360>\"" sync=false fullscreen-overlay=true \
\
v4l2src device=/dev/video5 io-mode=4 ! \
video/x-raw, width=640, height=360, format=BGR, framerate=30/1 ! \
queue ! vaipersondetect ! queue ! \
fpsdisplaysink video-sink="kmssink bus-id=b00c0000.v_mix plane-id=33 \
render-rectangle=\"<640,360,640,360>\"" sync=false fullscreen-overlay=true \
\
#-v
### Set brightness of CSC back to 50%
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev10
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev11
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev12
yavta --no-query -w '0x0098c9a1 50' /dev/v4l-subdev13
/*
* Copyright 2019 Xilinx Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* NOTICE: This file has been modified from the original verson.
* The original code for drawing bounding boxes was taken from
* https://github.com/Xilinx/Vitis-AI/blob/v1.1/Vitis-AI-Library/ssd/test/test_ssd.cpp
*
* TJS - Removed floating-point round operations; that level of accuracy is
* not needed for demonstration purposes
* - Created DrawBoxes template function
* - Removed other code that wasn't used in this app context
*/
#include <iostream>
#include <opencv2/opencv.hpp>
template<class T>
void DrawBoxes( cv::Mat img, T results, cv::Scalar color = cv::Scalar(0, 255, 0))
{
/* Draw bounding boxes */
for (auto &box : results)
{
int xmin = box.x * img.cols;
int ymin = box.y * img.rows;
int xmax = xmin + (box.width * img.cols);
int ymax = ymin + (box.height * img.rows);
xmin = std::min(std::max(xmin, 0), img.cols);
xmax = std::min(std::max(xmax, 0), img.cols);
ymin = std::min(std::max(ymin, 0), img.rows);
ymax = std::min(std::max(ymax, 0), img.rows);
cv::rectangle(img, cv::Point(xmin, ymin), cv::Point(xmax, ymax), color, 2, 1, 0);
}
}
## Copyright 2019 Xilinx Inc.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## NOTICE: This file has been modified from the original version.
## The original file is https://github.com/Xilinx/Vitis-AI/blob/v1.1/mpsoc/vitis_ai_dnndk_samples/face_detection/Makefile
##
## TJS - Updated for GStreamer and Vitis-AI-Library support
PROJECT = libgstvaifacedetect.so
CXX ?= aarch64-linux-gnu-g++
CC ?= aarch64-linux-gnu-gcc
CFLAGS := -O2 -Wall -Wpointer-arith -Wno-unused-function -ffast-math -fPIC -shared
CFLAGS += --sysroot=$(SYSROOT)
CFLAGS += -I$(SYSROOT)/usr/include/gstreamer-1.0 -I$(SYSROOT)/usr/lib/gstreamer-1.0/include
CFLAGS += -I$(SYSROOT)/usr/include/glib-2.0 -I$(SYSROOT)/usr/lib/glib-2.0/include
CFLAGS += -I../common
LDFLAGS := -lpthread -lrt -ldl -lcrypt -lstdc++ -lglog
LDFLAGS += -lgstbase-1.0 -lgstvideo-1.0
LDFLAGS += -lopencv_core -lopencv_video -lopencv_videoio -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lopencv_ximgproc
LDFLAGS += -lxilinxopencl -lvitis_ai_library-facedetect
CUR_DIR = $(shell pwd)
BUILD = $(CUR_DIR)/build
C_DIR := $(shell find $(SRC) -name *.c)
OBJ = $(patsubst %.c, %.o, $(notdir $(C_DIR)))
CPP_DIR := $(shell find $(SRC) -name *.cpp)
OBJ += $(patsubst %.cpp, %.o, $(notdir $(CPP_DIR)))
CFLAGS += -mcpu=cortex-a53
SRC = $(CUR_DIR)
.PHONY: all clean
all: $(BUILD) $(PROJECT)
$(PROJECT) : $(OBJ)
$(CXX) $(CFLAGS) $(addprefix $(BUILD)/, $^) -o $@ $(LDFLAGS)
%.o : %.cpp
$(CXX) -c $(CFLAGS) $< -o $(BUILD)/$@
clean:
$(RM) -rf $(BUILD)
$(RM) $(PROJECT)
$(BUILD) :
-mkdir -p $@
/* GStreamer
* Copyright (C) 2020 AVNET Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-gstvaifacedetect
*
* The vaifacedetect element does face detection using the Vitis-AI-Library.
*
* <refsect2>
* <title>Vitis-AI-Library face detection</title>
* |[
* gst-launch-1.0 -v fakesrc ! vaifacedetect ! fakesink
* ]|
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideofilter.h>
#include "gstvaifacedetect.h"
/* OpenCV header files */
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
/* Vitis-AI-Library specific header files */
#include <vitis/ai/facedetect.hpp>
#include <vitis/ai/nnpp/facedetect.hpp>
/* Header file for custom drawing function */
#include <drawboxes.hpp>
GST_DEBUG_CATEGORY_STATIC (gst_vaifacedetect_debug_category);
#define GST_CAT_DEFAULT gst_vaifacedetect_debug_category
/* prototypes */
static void gst_vaifacedetect_set_property (GObject * object,
guint property_id, const GValue * value, GParamSpec * pspec);
static void gst_vaifacedetect_get_property (GObject * object,
guint property_id, GValue * value, GParamSpec * pspec);
static void gst_vaifacedetect_dispose (GObject * object);
static void gst_vaifacedetect_finalize (GObject * object);
static gboolean gst_vaifacedetect_start (GstBaseTransform * trans);
static gboolean gst_vaifacedetect_stop (GstBaseTransform * trans);
static gboolean gst_vaifacedetect_set_info (GstVideoFilter * filter, GstCaps * incaps,
GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info);
static GstFlowReturn gst_vaifacedetect_transform_frame_ip (GstVideoFilter * filter,
GstVideoFrame * frame);
enum
{
PROP_0
};
/* pad templates */
/* Input format */
#define VIDEO_SRC_CAPS \
GST_VIDEO_CAPS_MAKE("{ BGR }")
/* Output format */
#define VIDEO_SINK_CAPS \
GST_VIDEO_CAPS_MAKE("{ BGR }")
/* class initialization */
G_DEFINE_TYPE_WITH_CODE (GstVaifacedetect, gst_vaifacedetect, GST_TYPE_VIDEO_FILTER,
GST_DEBUG_CATEGORY_INIT (gst_vaifacedetect_debug_category, "vaifacedetect", 0,
"debug category for vaifacedetect element"));
static void
gst_vaifacedetect_class_init (GstVaifacedetectClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstBaseTransformClass *base_transform_class = GST_BASE_TRANSFORM_CLASS (klass);
GstVideoFilterClass *video_filter_class = GST_VIDEO_FILTER_CLASS (klass);
/* Setting up pads and setting metadata should be moved to
base_class_init if you intend to subclass this class. */
gst_element_class_add_pad_template (GST_ELEMENT_CLASS(klass),
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_caps_from_string (VIDEO_SRC_CAPS ",width = (int) [1, 640], height = (int) [1, 360]")));
gst_element_class_add_pad_template (GST_ELEMENT_CLASS(klass),
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_caps_from_string (VIDEO_SINK_CAPS ", width = (int) [1, 640], height = (int) [1, 360]")));
gst_element_class_set_static_metadata (GST_ELEMENT_CLASS(klass),
"Face detection using the Vitis-AI-Library",
"Video Filter",
"Face Detection",
"Tom Simpson @ AVNET");
gobject_class->set_property = gst_vaifacedetect_set_property;
gobject_class->get_property = gst_vaifacedetect_get_property;
gobject_class->dispose = gst_vaifacedetect_dispose;
gobject_class->finalize = gst_vaifacedetect_finalize;
base_transform_class->start = GST_DEBUG_FUNCPTR (gst_vaifacedetect_start);
base_transform_class->stop = GST_DEBUG_FUNCPTR (gst_vaifacedetect_stop);
video_filter_class->set_info = GST_DEBUG_FUNCPTR (gst_vaifacedetect_set_info);
video_filter_class->transform_frame_ip = GST_DEBUG_FUNCPTR (gst_vaifacedetect_transform_frame_ip);
}
static void
gst_vaifacedetect_init (GstVaifacedetect *vaifacedetect)
{
}
void
gst_vaifacedetect_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GstVaifacedetect *vaifacedetect = GST_VAIFACEDETECT (object);
GST_DEBUG_OBJECT (vaifacedetect, "set_property");
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gst_vaifacedetect_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
GstVaifacedetect *vaifacedetect = GST_VAIFACEDETECT (object);
GST_DEBUG_OBJECT (vaifacedetect, "get_property");
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gst_vaifacedetect_dispose (GObject * object)
{
GstVaifacedetect *vaifacedetect = GST_VAIFACEDETECT (object);