From d431b4bc3be8fe330c56b9a6ef191aec71b88499 Mon Sep 17 00:00:00 2001 From: dchvs Date: Thu, 4 Mar 2021 06:22:22 -0600 Subject: [PATCH] Add script to control AE on sensor-id=0 --- script_to_control_gain_exposure.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 script_to_control_gain_exposure.sh diff --git a/script_to_control_gain_exposure.sh b/script_to_control_gain_exposure.sh new file mode 100755 index 0000000..29cc4ad --- /dev/null +++ b/script_to_control_gain_exposure.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +initial_gain=0 +initial_exposure_time=0 + +while true; do sleep 0.5; + # Read center camera controls + echo `v4l2-ctl -d /dev/video1 --get-ctrl=gain --get-ctrl=exposure` > controls + awk '{print $2}' controls > get_control + actual_gain=`cat get_control` + awk '{print $4}' controls > get_control + actual_exposure_time=`cat get_control` + + # Print controls + #echo -e "\n**Center Camera Controls**" + #cat controls + # Remove temp files + rm controls get_control + # Set R/L camera controls manually + if [ $actual_gain -ne $initial_gain ]; then + v4l2-ctl -d /dev/video0 --set-ctrl=gain=$actual_gain + fi + if [ $actual_exposure_time -ne $initial_exposure_time ]; then + v4l2-ctl -d /dev/video0 --set-ctrl=exposure=$actual_exposure_time + fi + # Define new initial value + initial_gain=$actual_gain + initial_exposure_time=$actual_exposure_time +done