19 Days of Compost featuring Tomatoes, Carrot Tops, Corn Husks and Mushrooms. It's interesting to see so many mushroom caps growing up within the compost. For some reason I had assumed these would only be featured above in the sun light. Mushrooms don't photosynthesize, so that assumption was a poor one....
The scanner has been running this entire time at 300 DPI, which gives me an image width of approximately 2550 pixels (8.5" * 300 pixels per inch). The 4K UHD standard is 3840 pixels wide, and I'd love to see a video like the one above done at 4k. So I've upped the scanning resolution to 600 DPI, and will capture that for hopefully a few weeks. A 3 second test of that can be seen here:
Unfortunately, I don't have a display capable of 4k. Hopefully this is setup properly!
Thursday, July 28, 2016
Tuesday, June 21, 2016
30 Days of Compost + Panning Video + Removing 'bad' images
1. This is 2743 images taken over ~30 days.
2. A scan happens every 15 minutes, that means I should have ~2,880 images.
3. Sometimes the scanner jams halfway through a scan. This isn't horrible, but the resulting image has a streak of repeating pixels starting where the scanner jammed. This is particularly jarring when images are played back as a video.
4. I liked the effect of panning across the images (see earlier post), but wanted to clean things up + timestamp the images.
So two short scripts are run:
Clean Images:
#!/bin/bash
for file in *.jpg
do
convert $file -crop 768x1+0+10 image_a.jpg
convert $file -crop 768x1+0+30 image_b.jpg
if [ $(compare -metric RMSE image_a.jpg image_b.jpg NULL: 2>&1 \ | sed 's/.*(//' | cut -c1-4 | cut -c 4-) -gt 0 ]
then
echo "$file keep"
else
echo "$file remove"
mv $file brokenimages/
fi
done
rm image*.jpg
For every jpg image in a directory we'll create two temporary images, a single row of 768 pixels located 10 and 30 pixels down from the top. We'll use imagemagick's compare tool to get a rough idea of how different they are, this feedback looks like:
350.361 (0.00534616) for images with little to no difference
2145.33 (0.0327357) for images with some difference
I'm using BASH, it doesn't like floating point numbers. We get lazy and grab the second number past the decimal point. If this number is > 0, we can assume we're dealing with two images with enough difference that it's good to keep. This could fail, but so far it's worked with ~3,000+ images. It's not particularly fast, taking approximately 3 seconds / image on a Pi 2 Model B. Running it retroactively isn't fun, but checking images as they are scanned (once every 15 minutes) is plenty fast.
In order to get the panning / scrolling affect, I crop each image down to 1920x1080 pixels starting at the top. With (almost) every image I shift the cropped area down 1 pixel. I like the idea that I can slowly pan through the entire length of the scanned area in the time it takes to run through each image, but I have more images than pixels height to move through:
2743 images = 2743 pixels to shift.
3484 = original image height.
-1080 to account for the video height
2404 = 3484-1080. Total number of pixels I need to shift down.
If I move down one pixel for each image, we'll be 339 pixels below the bottom of the scanner. I could try shifting partial pixels but that involves more work. Again laziness, so instead we just don't shift every 6th image. This isn't exact, but it gets us close to the bottom of the scanner area.
Is it noticeable in the video? : )
Cycling through all the images in a directory, we grab the date and time from the file name and set that aside as ndate & ntime. Using the imagemagick tool convert we crop a 1920x1080 chunk out of each 2480x3484 image starting at the top, shifted 280 pixels in from the left. We add a small 400x30px background bottom center and pop the $ndate and $ntime values as a text caption on top of this background.
Each image processed we increment the value $a by 1, if $a is < 6, we shift the cropped location down 1 px. If the value of $a is equal to 6, we don't shift the the image down and we reset the value of $a to 0.
This image is saved with the prefix "temp_" and a four digit number starting with 0000. Saving in this naming format makes it easy for us in the next step to wrap these images up in a nice mpeg video file.
#!/bin/bash
a=0
shift=0
count=0
for file in *.jpg;
do
counter=$(printf %04d $count);
ndate="${file:3:4}\/${file:7:2}\/${file:9:2}"
ntime="${file:12:2}:${file:14:2}:${file:16:2}"
convert $file -crop 1920x1080+280+$shift - | convert -background '#0008' \
-gravity center \
-fill white \
-size 400x30 \
-pointsize 24 \
-kerning 2.5 \
-font Courier \
caption:"${ndate} ${ntime}" \
- \
+swap \
-gravity south \
-composite \
"temp_$counter".jpg;
if [ $a -eq 6 ];
then
let shift=$shift+0
a=0
else
let shift=$shift+1
let a=$a+1
fi
echo -e "$file\t$count\t$shift"
count=$(($count+1))
done
And then we need to turn these images into a video file:
avconv -y -r 30 -i temp_%04d.jpg -r 30 -vcodec libx264 -crf 20 -g 15 CompostCam30Days.mp4
This probably took an hour to process on a ~6 year old Mac Laptop. It could be done on the raspberry pi, but the converting and timestamping of images would have taken longer.
Nothing too crazy here, all the hard work has already been done by ImageMagick and avconv. But it's fun, and I should probably turn the compost : )
This probably took an hour to process on a ~6 year old Mac Laptop. It could be done on the raspberry pi, but the converting and timestamping of images would have taken longer.
Nothing too crazy here, all the hard work has already been done by ImageMagick and avconv. But it's fun, and I should probably turn the compost : )
Friday, June 3, 2016
Guide Posted and More Compost Cam!
Posted a guide on how to make a SoilCam / Rhizotron! Lots of things I would love to add / edit / modify, but I think it's at a point where not posting it now would mean it never would : )
Apparently ffmpeg and avconv had a security hole in their concat command. This confused me for longer than I'd like to admit before I realized they had dropped the command in a newer release. Thankfully with mpeg.ts files you can simply cat them together and then convert.
The Compost Cam continues to run and I've captured about two weeks of data. The broken images make it a bit jarring, cleaning those out is pretty easy, but even with I still find it fascinating to watch what's happening with my food!
The jarring is a result of the scanner jamming, presumably due to too much pressure from the soil pressing in on it. Al has recommended a few modifications (enclosing it in a half cylinder), I wonder if it's pressure on the edge, or the back where a plastic linear gear rail resides that causes this?
The scanner is mounted so the scan travels down, perhaps that orientation allows the gears to slip?
Either way, figuring out how to make the scanner last longer and skip less would be the ideal next steps for this whole project....
Thursday, May 26, 2016
Holy Compost Cam Batman!
Approximately 500 images taken over 5 days, roughly once every 15 minutes. A 6.4" x 4.2" view panning down 11 inches of compost located in my backyard.
It surprises me how insanely active this is. My wife started the compost a few years ago and I'm not sure when we last emptied/sifted things. Towards the bottom half the soil/compost is shifted away from the scanner which puts it out of focus, but there's still tons of activity.
I'm capturing a full 8.5 x 11.5" area at 300 DPI and this video is panning vertically across a small portion of it. We've recently put in a bunch of cilantro, strawberry, carrot, and bits and pieces of leaks along with pieces of brown paper bag and potato skins. To be able to see all of this turn to soil would be fascinating!
Tuesday, May 24, 2016
Compost, Hypha Growth and Instructables
Almost done with the guide/instructable. I need to run through the whole thing one more time to see if all of it adds up properly. In the mean time I've buried two more scanners. The first one a few weeks ago was buried with a flower (pictured in prior post), the Canon LiDE 200 seized up after ~7,000 scans.
The second scanner (another LiDE 200) was buried in our compost bin a couple days ago, and today I started seeing hypha growth along the head of a strawberry that arrived yesterday. In about 8 hours the hypha grew ~6mm. Impressive! I wonder how much further it will grow.
I know very little about fungus, but I remember reading that some forms of fungus form hypha strands capable of ensnaring nematodes. Totally wicked, and would be amazing to capture. Though I'm not sure scanning at 600 or 1200 dpi would suffice. Some details on this here: http://botany-lab.blogspot.com/2015/03/arthrobotrys-carnivorous-fungus.html
Mmmmmmmmm.
The second scanner (another LiDE 200) was buried in our compost bin a couple days ago, and today I started seeing hypha growth along the head of a strawberry that arrived yesterday. In about 8 hours the hypha grew ~6mm. Impressive! I wonder how much further it will grow.
I know very little about fungus, but I remember reading that some forms of fungus form hypha strands capable of ensnaring nematodes. Totally wicked, and would be amazing to capture. Though I'm not sure scanning at 600 or 1200 dpi would suffice. Some details on this here: http://botany-lab.blogspot.com/2015/03/arthrobotrys-carnivorous-fungus.html
Mmmmmmmmm.
Saturday, March 26, 2016
Flowers!
Polishing up an instructable on assembling a SoilCam means burying another scanner! In the process I realize I've had a 4 Port Plugable USB hub running for over a year outside, through a Michigan winter. Neat : )
This burial is in a tub that a year ago we used to grow potatoes. While still located outside, having it in a tub makes it easier to have inside which resolves having to worry about how you're going to get power outside. Though if portability is required, a five gallon bucket would be a better option (soil is heavy!) and would still fit the scanner.
This burial is in a tub that a year ago we used to grow potatoes. While still located outside, having it in a tub makes it easier to have inside which resolves having to worry about how you're going to get power outside. Though if portability is required, a five gallon bucket would be a better option (soil is heavy!) and would still fit the scanner.
Thursday, July 23, 2015
Millipede Mating
I think this brings things full circle. Two weeks ago there was a barrage of baby pill bugs, last week we saw death occur as a hungry beetle larvae happened upon a slug, and this week we have millipede mating!
Image stabilization issues
Some of the videos I compile tend to shake left and right, a result of the scanner occasionally starting at a slightly different position. It always scans the same distance and looking at one image next to another it's difficult to see any difference. Play them back in a video and it becomes very apparent that the images don't line up.
I've used FFMPEG's deshake option to smooth out this jitter, but it's difficult to remove all of it. Going through each image one at a time is a bit too time consuming, so we need to either resolve the initial problem that causes it, or figure out a more accurate work around.
What we can see occurs over a period of 6 hours, and at some point it looks like three millipedes are involved. It's difficult to tell if they are the same millipedes participating throughout the entirety.
I had originally incorrectly titled this post "Centipede Mating". You can see between 16:02:01 and 16:57:02 that each body segment has two pairs of legs. If these were Centipedes you would only see one pair per segment. Assuming these are mating Millipedes we might get to see a slew of babies in a few weeks! Apparently they start off with only three pairs of legs and only after a few molting sessions do they appear as we're used to seeing them.
Amazing piece of info: Millipedes are part of the Myriapod family (many feet), and were the first oxygen breathing animal to walk on land! And last, these creatures are a significant contributor to decomposition, that crazy process that results in this wonderful pile of material we call soil that keeps you and I fed. Next time you're eating anything or simply going somewhere on a walk, thank the Millipedes.
- https://en.wikipedia.org/wiki/Pneumodesmus
- https://en.wikipedia.org/wiki/Myriapoda
- http://www.biokids.umich.edu/critters/Myriapoda/
I had originally incorrectly titled this post "Centipede Mating". You can see between 16:02:01 and 16:57:02 that each body segment has two pairs of legs. If these were Centipedes you would only see one pair per segment. Assuming these are mating Millipedes we might get to see a slew of babies in a few weeks! Apparently they start off with only three pairs of legs and only after a few molting sessions do they appear as we're used to seeing them.
Amazing piece of info: Millipedes are part of the Myriapod family (many feet), and were the first oxygen breathing animal to walk on land! And last, these creatures are a significant contributor to decomposition, that crazy process that results in this wonderful pile of material we call soil that keeps you and I fed. Next time you're eating anything or simply going somewhere on a walk, thank the Millipedes.
- https://en.wikipedia.org/wiki/Pneumodesmus
- https://en.wikipedia.org/wiki/Myriapoda
- http://www.biokids.umich.edu/critters/Myriapoda/
Image stabilization issues
Some of the videos I compile tend to shake left and right, a result of the scanner occasionally starting at a slightly different position. It always scans the same distance and looking at one image next to another it's difficult to see any difference. Play them back in a video and it becomes very apparent that the images don't line up.
I've used FFMPEG's deshake option to smooth out this jitter, but it's difficult to remove all of it. Going through each image one at a time is a bit too time consuming, so we need to either resolve the initial problem that causes it, or figure out a more accurate work around.
A few thoughts on resolving / working around this:
1. Figure out how the scanner returns home.
- At 600 DPI even a millimeter off will result in a 20pixel shift. When viewing the whole 8.5x11" area it's not very obvious, when zooming into a smaller area it is. The intended use of these scanners from the manufacturer likely did not include building timelapse videos : )
- At 600 DPI even a millimeter off will result in a 20pixel shift. When viewing the whole 8.5x11" area it's not very obvious, when zooming into a smaller area it is. The intended use of these scanners from the manufacturer likely did not include building timelapse videos : )
2. Can we compare the first twenty rows of pixels from left to right of sequential images?
- Once we find a certain percentage match, trim all rows to the left off.
3. Apply a ~5mm solid white border to the glass scanning plate
- Use imagemagick to locate the border and crop within the boundary.
- Once we find a certain percentage match, trim all rows to the left off.
3. Apply a ~5mm solid white border to the glass scanning plate
- Use imagemagick to locate the border and crop within the boundary.
Subscribe to:
Posts (Atom)



