diff --git a/general/package/ingenic-libimp-control/src/imp-control.sh b/general/package/ingenic-libimp-control/src/imp-control.sh index 51633b14..c3bf7e65 100755 --- a/general/package/ingenic-libimp-control/src/imp-control.sh +++ b/general/package/ingenic-libimp-control/src/imp-control.sh @@ -3,54 +3,60 @@ # This script provides a control interface for the libimp_control library. # It sends commands to the server listening on localhost port 4000. -# Function to display the usage of the script -show_help() { - echo "Usage: imp-control.sh [command] [parameters]" - echo " Use without parameters to retrieve current values." - echo "Available commands:" - echo "Command Parameters Description" - echo "------- ---------- -----------" - echo "aihpf [on/off] High Pass Filter" - echo "aiagc [off/gainLevel compGaindB] Auto Gain Control" - echo "ains [off/0-3] Noise Suppression" - echo "aiaec [on/off] Echo Cancellation" - echo "aivol [-30-120] Audio Input Volume" - echo "aigain [0-31] Audio Input Gain" - echo "aialc [0-7] Audio Input ALC Gain" - echo "aovol [-30-120] Audio Output Volume" - echo "aogain [0-31] Audio Output Gain" - echo "contrast [0-255] Contrast" - echo "brightness [0-255] Brightness" - echo "saturation [0-255] Saturation" - echo "sharpness [0-255] Sharpness" - echo "sinter [0-255] Sinter Strength" - echo "temper [0-255] Temper Strength" - echo "aecomp [0-255] AE Compensation" - echo "aeitmax [value] AE Max parameters" - echo "backlightcomp [strength] Set Backlight Comp." - echo "dpc [0-255] DPC Strength" - echo "drc [0-255] DRC Strength" - echo "hilight [0-10] Highlight Intensity" - echo "again [value] Analog Gain" - echo "dgain [value] Digital Gain" - echo "hue [0-255] Hue" - echo "ispmode [0/1] ISP Mode (Day/Night)" - echo "flicker [0/1/2] Anti-Flicker" - echo "flip [normal/flip/mirror/flip_mirror] Image Flip" - echo "fps [fps_num] [fps_den] Set Sensor FPS" - echo "whitebalance [mode] [rgain] [bgain] Set White Balance" - echo "gamma Get Gamma Values" - echo "autozoom [ch] [scaler enable] [scale w] [scale h] [crop enable] [crop left] [crop top] [crop w] [crop h]" - echo " Set Auto Zoom" - echo "frontcrop [enable] [top] [left] [width] [height]" - echo " Set Front Crop" - echo "mask [ch] [enable] [top] [left] [width] [height] [green] [blue] [red]" - echo " Set Mask" +full_demo() { + +demo() { + echo "imp_control $*" | nc localhost 4000 >/dev/null 2>&1 } -# Check for no arguments and display help -if [ "$#" -eq 0 ]; then - show_help +random_range() { + echo $(($1 + RANDOM % ($2 - $1 + 1))) +} + +run_demo() { + echo "Running $1..." + for v in $(seq 127 -1 1) $(seq 1 255) $(seq 254 -1 127); do + echo -n "$v." + demo $1 $v + sleep 0.004 + done + echo -e "\n$1 Done" +} + +mask() { + start=$(date +%s) + echo "Mask demo" + while [ $(($(date +%s) - start)) -lt 10 ]; do + demo mask "0 1 $(random_range 0 640) $(random_range 0 1024) 320 240 $(random_range 0 255) $(random_range 0 255) $(random_range 0 255)" + sleep 0.5 + done + demo mask 0 0 516 34 320 240 49 98 163 +} +mask + +echo "Whitebalance demo" +for wb in $(seq 1 9) 0; do demo whitebalance $wb; sleep 1; done +echo "isp mode demo" +demo ispmode 1; sleep 3; demo ispmode 0; sleep 1 + +echo "Front Crop Demo" +for v in $(seq 0 400); do demo frontcrop 1 $v 0 1280 720; done +for v in $(seq 0 800); do demo frontcrop 1 0 $v 1280 720; done +demo frontcrop 1 0 0 1920 1080 + +echo "autozoom demo" +for zoom in 1.05 1.10 1.15 1.20 1.15 1.10 1.05; do + demo autozoom 0 1 $(awk "BEGIN {print int(1920 * $zoom)}") $(awk "BEGIN {print int(1080 * $zoom)}") 1 0 0 1920 1080 + echo "Autozoom: $zoom" + sleep 1 +done +demo autozoom 0 0 2304 1296 0 0 0 1920 1080 + +for func in brightness contrast saturation sharpness sinter temper aecomp dpc drc hue; do run_demo $func; done +} + +if [ "$1" == "full_demo" ]; then + full_demo else # Send the command and parameters to the server echo "imp_control $*" | nc localhost 4000