====== 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 \\
{{:projects:pasted:20201029-160202.png?0x400}}
With a USB telescope mounted to it with velcro scraps \\
{{:projects:pasted:20201029-160102.png?0x400}}
The website was only temporary (I've sinced moved house) but with the camera movement interface it looked like this:
{{:projects:pasted:20201029-153406.png}}
Compared to the normal image taken from an iPhone at the same distance (you can see the pub sign in yellow/orange):
{{:projects:pasted:20201029-153526.png}}
===== Technical details =====
[[https://motion-project.github.io/|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, [[https://www.lukecole.name/research_and_projects/personal/usb_missile_launcher/|USB missile launcher]] ([[https://sourceforge.net/projects/usbmissile/|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).
===== Gallery =====
I didn't save many pictures from this. Here are some images from the few months it ran:
{{:projects:pasted:20201029-155203.png}}
{{:projects:pasted:20201029-154538.png}}
{{:projects:pasted:20201029-154620.png}}
==== Timelapse ====
{{:projects:bon-webcam-timelapse.mp4?500|Testing out a 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