Sunday, November 12, 2017

Time lapse of cutting limbs off a mostly dead tree using a bucket lift

Here's how I put together a time lapse video of cutting limbs off a mostly dead tree.



I took images, 1 per second using my mac laptop using imagesnap, installed using homebrew (from this Ask Different Stack Exchange).  Initially I used the -t option to have the program automatically take 1 image per second, but that failed when it got to 999 images, so then I went with a variant of the while loop actually recommended in the post:
let index=1
while [ 1 ]
do
    imagesnap snapshot_$index.png
    let index=index+1
done
Once I sat down to work with the images, I got the dimensions of the images using the command line too "identify" (part of imagemagick) (https://stackoverflow.com/questions/4670013/fast-way-to-get-image-dimensions-not-filesize).

I created symbolic links to the image files with the symbolic links named so that they would be in the correct chronological order:

let index=1
while read line
do
    padded=$(printf "%04d" $index)
    link_name=jpg_snapshot_$padded.jpg
    echo $padded $index $line $link_name

    ln -s $line $link_name

    let index=index+1
done < ../jpg_snapshots.grp
I stitched the above into a timelapse video:
ffmpeg -r 60 -f image2 -s 1280x720 \
    -i ordered_symbolic_links/png_snapshot_%04d.png \
    -vcodec libx264 -crf 25 -pix_fmt yuv420p test2.mp4
stitch time lapse videos together (https://trac.ffmpeg.org/wiki/Concatenate#samecodec):

ffmpeg -f concat -i movie_file_list.grp -c copy all.mp4
The result is what you see above.

attempt to fix "flashing" in later part of video by adjusting individual images' brightness

It didn't really work!  The later part of the video appears to be flashing bright and darks as the clouds obscure the sun and then race away.  I tried to "correct" for this by adjusting the brightness of the individual images.  This didn't work!  It produced these weird oversaturated colors, in almost a 70's psychedelic effect.

First I calculated the overall brightness of each image:  (from http://www.imagemagick.org/discourse-server/viewtopic.php?t=11304)

for a in ordered_symbolic_links/png_snapshot_*.png
do
      echo $a
      b=$(convert $a -colorspace Gray -format "%[fx:quantumrange*image.mean]" info:)
      echo $b >> png_brightness.grp
done
I then calculated the adjustment required to make the brightness uniform with this python script:  calc_brightness_adjustment.py


Using the file generated from the above, I then adjusted the brightness of the images (from:  http://www.imagemagick.org/Usage/color_mods/#modulate)
while read line
do
     f=$(echo $line | awk '{print $1}')
     ba=$(echo $line | awk '{print $2}')
     echo $ba $f
     convert ../ordered_symbolic_links/$f -modulate $ba,100,100 $f
done < ../png_snapshot_and_brightness_adjustment.txt


No comments:

Post a Comment