Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No issue: made a script to switch cameras and a new overlay #21

Open
Bishamon1987 opened this issue Aug 15, 2019 · 1 comment
Open

No issue: made a script to switch cameras and a new overlay #21

Bishamon1987 opened this issue Aug 15, 2019 · 1 comment
Labels
documentation Documentation

Comments

@Bishamon1987
Copy link

So, I have a Chevrolet Volt, which has pretty poor vision to the front.
I wanted to be able to switch camera's when I need to park.

I copied the cam_overlay folder and changed the names of the folder and bin file to some thing with rearcam and frontcam.

I made these overlays.

Frontcam overlay

New Project-2(9)

Rearcam overlay

New Project-2(8)

Illustration of the buttons the script makes

New Project-2

Bash Script

#!/bin/bash
device='/dev/input/event0'

coord_x_check='*type 3 (EV_ABS), code 0 (ABS_X), value*'
coord_y_check='*type 3 (EV_ABS), code 1 (ABS_Y), value*'
running_cam=1
echo "Rearcam activated on default"
~/rearcam_overlay/bin/rearcam.bin -d /dev/v4l/by-id/usb-ARKMICRO_USB2.0_PC_CAMERA-video-index0 &
sudo evtest "$device" | while read line; do
    case $line in
        ($coord_x_check)    x=$(echo $line | awk -F value '{ print $2 }' | tr -dc '0-9');;
        ($coord_y_check)    y=$(echo $line | awk -F value '{ print $2 }' | tr -dc '0-9')
        if (( $x>=1920 && $y<=850 && $running_cam==1 ));
        then
                echo Rearcam deactivated
                killall -wq rearcam.bin &

                echo Frontcam activated X $x  Y $y
                ~/frontcam_overlay/bin/frontcam.bin -d /dev/v4l/by-id/usb-ARKMICRO_USB2.0_PC_CAMERA-video-index0 &
                running_cam=2
                sleep 1
        elif (( $x>=1920 && $y<=850 && $running_cam==2 ));
        then
                echo Frontcam is running allready
        elif (( $x<=1919 && $y<=850 && $running_cam==2 ));
        then
                echo Frontcam deactivated
               killall -wq frontcam.bin &
                echo Rearcam activated X $x Y $y
                ~/cam_overlay/bin/rearcam.bin -d /dev/v4l/by-id/usb-ARKMICRO_USB2.0_PC_CAMERA-video-index0 &
                running_cam=1
                sleep 1
        elif (( $x<=1919 && $y<=850 && $running_cam==1 ));
        then
                echo Rearcam is running allready
        elif (( $y>850 && $running_cam==1 ));
        then
                echo Camview deactivated X $x Y $y
                killall -wq rearcam.bin
                killall -wq test-2.sh
                exit 1
        elif (( $y>850 && $running_cam==2 ));
        then
                echo Camview deactivated X $x Y $y
                killall frontcam.bin &
                killall camview.sh    #this script
                exit 1

        fi
        ;;
    esac
sleep 0.1
done

You should find out using evtest what the min X & Y values and max X & Y values are. Also check where you like to have the buttons and check the values. Use them in this script.

@meekys meekys added the documentation Documentation label Aug 22, 2019
@meekys
Copy link
Owner

meekys commented Aug 22, 2019

Nice little script. I'm sure others will appreciate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation
Projects
None yet
Development

No branches or pull requests

2 participants