User Tools

Site Tools


projects:bon_accord_webcam

This is an old revision of the document!


Bon Accord Webcam

I set this up over lockdown (in the summer) to see how busy the beer garden was (and whether there was a table available) at a glance on my phone. It could be moved horizontonally and vertically from both the web interface and from a command line interface (much more responsive). It was a USB telescope (I'm about 150 meters from the beer garden) velcro mounted on a USB missile launcher. I controlled it with a PHP script that moved the mount using shell commands to a raspberry pi mounted in the window of one of the bedrooms.

The website was only temporary (I've sinced moved) but with the camera movement interface it looked like this:

Compared to the normal image taken from an iPhone at the same distance (you can see the pub sign in yellow/orange):

Technical details

Motion was used to stream the output from the USB telescope to a port on the Rasperry Pi. Then was then embedded in an img tag on the front end (refreshed every second). The movement buttons were PHP wrappers to a python command line program, USB missile launcher.

This command line program took simple parameters to move the USB missile mount, for example:

./USBMissileLauncherUtils -R -S 30

Would move the missible launcher right for 30 milliseconds. I wrote a simple command line wrapper to allow me to control the movement from the console:

#!/bin/bash
escape_char=$(printf "\u1b")
speed=10
while true; do
        read -rsn1 mode
        if [[ $mode == $escape_char ]]; then
                read -rsn2 mode
        fi
        case $mode in
                'q') exit ;;
                '1') speed=1 ; echo "Speed is now $speed";;
                '2') speed=10 ; echo "Speed is now $speed";;
                '3') speed=20 ; echo "Speed is now $speed";;
                '4') speed=30 ; echo "Speed is now $speed";;
                '5') speed=50 ; echo "Speed is now $speed";;
                '6') speed=100 ; echo "Speed is now $speed";;
                '7') speed=200 ; echo "Speed is now $speed";;
                '8') speed=500 ; echo "Speed is now $speed";;
                '[A') ./USBMissileLauncherUtils -U -S $speed;;
                '[B') ./USBMissileLauncherUtils -D -S $speed;;
                '[C') ./USBMissileLauncherUtils -R -S $speed;;
                '[D') ./USBMissileLauncherUtils -L -S $speed;;
                *) >&2 'ERR'; return;;
        esac
done

This allowed the camera to be moved using the keyboard arrows ([A, [B, [C, [D) and the speed (length of time the motor would be turned on) could be set using the number keys.

The PHP wrapper was pretty simple, it only allowed a fix amount of movement (30 milliseconds):

if($_REQUEST['dir'] == 'left') {
        exec("/home/seven/projects/usb_missile/USBMissileLauncher-1.5/cam_control -L -S 30");
} elseif($_REQUEST['dir'] == 'right') {
        exec("/home/seven/projects/usb_missile/USBMissileLauncher-1.5/cam_control -R -S 30");
} elseif($_REQUEST['dir'] == 'up') {
        exec("/home/seven/projects/usb_missile/USBMissileLauncher-1.5/cam_control -U -S 30");
} elseif($_REQUEST['dir'] == 'down') {
        exec("/home/seven/projects/usb_missile/USBMissileLauncher-1.5/cam_control -D -S 30");
}

I also had a private interface with a bit more control (and it could lock out the public interface).

I didn't save many pictures from this. Here are some images from the few months it ran:

Timelapse

projects/bon_accord_webcam.1603987033.txt.gz · Last modified: 2020/10/29 15:57 by neil