User Tools

Site Tools


projects:bon_accord_webcam

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. I wanted to just use what I had lying around. If I could do this again (and I probably will) I think I'd make something with stepper motors (so I could return it to fixed positions).

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.

It was one of these missile launcher USB gadgets

With a USB telescope mounted to it with velcro scraps

The website was only temporary (I've sinced moved house) 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. This was then embedded in an img tag on the front end (refreshed twice a second). The movement buttons were PHP wrappers to a python command line program, USB missile launcher (sourceforge link)

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

./USBMissileLauncherUtils -R -S 30

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, triggered from the buttons in the web interface, 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

Installing USBMissileLauncher

wget https://sourceforge.net/projects/usbmissile/files/usbmissile/1.5/USBMissileLauncher-1.5.tgz/download -o USBMissileLauncher-1.5.tgz
tar zxvf USBMissileLauncher-1.5.tgz
cd USBMissileLauncher-1.5
sudo apt install libusb-dev
make
projects/bon_accord_webcam.txt · Last modified: 2021/05/02 13:50 by admin