Having fun with a very old webcam and a banana plant. Yes, it is a miracle,
both the banana plant and the webcam.
Taking one picture every hour using a raspberry pi, hacked together lighting
and very old webcam. Doesn't matter, it works and is fantastic. Nature still
makes the most fascinating and wonderful imagery.
Banana growing with images taken at 1 hour interval. This video should update
on the server automatically every hour. Reload the page to view the update.
Images start on 2022-11-17. The first week is missing night images. The
light added on the 23rd of November for 24 hour coverage. And, yes, the plant
also grows during the night.
The system is kept very simple. A RPi on the local WiFi has a cron script
running to capture an image every hour. The script also controls a 12V light
via GPIO. Everything is cobbled together from what was found in the drawers,
kitchen and garage. A lovely hack project :-)
The setup with camera and light.Raspberry Pi connected via WiFi.Lighting control switch... One whole wonderfully ancient metal-can
NPN transistor. Absolute magic at work.
Small update: The plant is approximately growing at a rate of 125μm per hour
(3mm per day). At the 11th of December 2022 it had grown out of the
top of the image. The camera was adjusted and recordings continue. The plant
will again grow out of the top soon. I will probably stop the recordings when
that happens. Maybe I can find another target ;-)
Final update: the plant is too big and the rig too inflexible to continue.
The final size when I quit recording (01-Jan-2023). The plant's
growth was mainly out of the field of vision and the rig was not flexible
enough to keep everything in view.
The code to take an image:
#!/bin/bashunset DISPLAY
MYDIR="/tmp/imgs"mkdir-p$MYDIRcd$MYDIR# Make sure we have GPIO 4 exported[-d/sys/class/gpio/gpio4 ] || sudo echo"4"> /sys/class/gpio/exportsleep0.5# Turn on the lightif[-d/sys/class/gpio/gpio4 ];then
sudo echo"out"> /sys/class/gpio/gpio4/direction
sudo echo"1"> /sys/class/gpio/gpio4/value
sleep1fi# The extra shell is to kill the SIGSEGV message from the shell because guvcview crashes on exit
bash -c"guvcview -i$MYDIR/banana.jpg -g none -m none -n 1 -t 1 -e > /dev/null 2>&1"2> /dev/null
# Turn off the lightif[-d/sys/class/gpio/gpio4 ];then
sudo echo"0"> /sys/class/gpio/gpio4/value
fi# Save data to remote serverif[-f"$MYDIR/banana-1.jpg"];then
scp "$MYDIR/banana-1.jpg""user@server.example.com:bananas/banana-$(date "+%Y%m%d%H%M%S").jpg"> /dev/null 2>&1ficd/tmp
rm-f$MYDIR/*
And converting it to a movie:
#!/bin/bash# The script directory contains all images. Make sure we are therecd$(dirname "$0")# Annotate the image(s) with date/time stampfor i in banana-*.jpg
do# file must exist (it doesn't if glob failed)[-f"$i"] ||continuemv$i tmp.jpg
# Extract date/time from filename
TXT="$(echo "$i" | cut -c 8-15)$(echo "$i" | cut -c 16-19)"
convert tmp.jpg \
-font DejaVu-Sans -pointsize20 \
-fill black \
-stroke black \
-strokewidth2 \
-annotate+20+25"$TXT" \
-stroke None \
-fill white \
-annotate+20+25"$TXT" \
"a${i}"rm-f tmp.jpg
done# Video ahead, one image at a time
ffmpeg -loglevel error -y -framerate24-pattern_type glob -i'abanana-*.jpg'-c:v libx264 -pix_fmt yuv420p zzbanana.mp4
# Covert it to webm too
ffmpeg -loglevel error -y -i zzbanana.mp4 -cpu-used -5 -b:v 0-crf30-pass1-an -f webm /dev/null
ffmpeg -loglevel error -y -i zzbanana.mp4 -cpu-used -5 -b:v 0-crf30-pass2 zzbanana.webm
rm-f ffmpeg2pass-0.log
# Make accesible by webservermv-f zzbanana.mp4 /my-web-directory-somewhere-in-space-and-time/banana.mp4
mv-f zzbanana.webm /my-web-directory-somewhere-in-space-and-time/banana.webm
Note: Make sure you understand the scripts if you copy these scripts. You need the right
directories setup across multiple machines.