Banana g(r)o(w)ing bananas
Time lapse experiment
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. 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 :-)
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 code to take an image: #!/bin/bash unset DISPLAY MYDIR="/tmp/imgs" mkdir -p $MYDIR cd $MYDIR # Make sure we have GPIO 4 exported [ -d /sys/class/gpio/gpio4 ] || sudo echo "4" > /sys/class/gpio/export sleep 0.5 # Turn on the light if [ -d /sys/class/gpio/gpio4 ]; then sudo echo "out" > /sys/class/gpio/gpio4/direction sudo echo "1" > /sys/class/gpio/gpio4/value sleep 1 fi # 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 light if [ -d /sys/class/gpio/gpio4 ]; then sudo echo "0" > /sys/class/gpio/gpio4/value fi # Save data to remote server if [ -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>&1 fi cd /tmp rm -f $MYDIR/* #!/bin/bash # The script directory contains all images. Make sure we are there cd $(dirname "$0") # Annotate the image(s) with date/time stamp for i in banana-*.jpg do # file must exist (it doesn't if glob failed) [ -f "$i" ] || continue mv $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 -pointsize 20 \ -fill black \ -stroke black \ -strokewidth 2 \ -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 -framerate 24 -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 -crf 30 -pass 1 -an -f webm /dev/null ffmpeg -loglevel error -y -i zzbanana.mp4 -cpu-used -5 -b:v 0 -crf 30 -pass 2 zzbanana.webm rm -f ffmpeg2pass-0.log # Make accesible by webserver mv -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
Posted: 2022-12-03 |
Overengineering @ request | Prutsen & Pielen since 1982 |