I've had my Raspberry Pi Zero for over a month, all powered and connected with its camera ready to go, but I had a problem positioning the camera because the ribbon cable I had was too short. So I finally got the extended ribbon cable and mounted it properly today. Prior to this, I was able to capture stills and also do broadcasts on YouTube (private feed). This was helpful to get it focused and pointing where I wanted it.
But what I really wanted was a way to capture an image and compare it to the previous image so that it could send it off to Dropbox only when there was a significant change. Here are the scripts I'm using:
Gemfile
source 'https://rubygems.org'
gem 'phashion'
camera.sh
#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M%S")
raspistill --rotation 90 -q 10 -w 640 -h 480 -o $HOME/stills/$DATE.jpg
echo $DATE
find_non_dupe.rb
require 'rubygems'
require 'bundler/setup'
Bundler.require
now = Time.now
one_minute_ago = now - 60
pattern1 = one_minute_ago.strftime('%Y-%m-%d_%H%M')
pattern2 = now.strftime('%Y-%m-%d_%H%M')
files = Dir.glob("~/stills/#{pattern1}*.jpg")
files += Dir.glob("~/stills/#{pattern2}*.jpg")
last_img = nil
unique_dir = '~/unique'
files.each do |f|
if File.exist?(File.join(unique_dir, File.basename(f)))
puts "Skipping: #{f}"
next
end
this_img = Phashion::Image.new f
if !!last_img &&
if this_img.duplicate? last_img
puts "Duplicate: #{f}"
else
puts "Non duplicate: #{f}"
FileUtils.cp f, unique_dir
end
end
last_img = this_img
end
Then I use Dropbox-Uploader to send only the changes. Here's what it can capture and upload to Dropbox:
Update: Here's how I mounted it.