资源简介
支持Python 2.7
代码片段和文件信息
#!/usr/bin/python
# original script by brainflakes improved by pageauc peewee2 and Kesthal
# www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=45235
# You need to install PIL to run this script
# type “sudo apt-get install python-imaging-tk“ in an terminal window to do this
import StringIO
import subprocess
import os
import time
from datetime import datetime
from PIL import Image
# Motion detection settings:
# Threshold - how much a pixel has to change by to be marked as “changed“
# Sensitivity - how many changed pixels before capturing an image needs to be higher if noisy view
# ForceCapture - whether to force an image to be captured every forceCaptureTime seconds values True or False
# filepath - location of folder to save photos
# filenamePrefix - string that prefixes the file name for easier identification of files.
# diskSpaceToReserve - Delete oldest images to avoid filling disk. How much byte to keep free on disk.
# cameraSettings - ““ = no extra settings; “-hf“ = Set horizontal flip of image; “-vf“ = Set vertical flip; “-hf -vf“ = both horizontal and vertical flip
threshold = 10
sensitivity = 20
forceCapture = True
forceCaptureTime = 60 * 60 # Once an hour
filepath = “/home/pi/picam“
filenamePrefix = “capture“
diskSpaceToReserve = 40 * 1024 * 1024 # Keep 40 mb free on disk
cameraSettings = ““
# settings of the photos to save
saveWidth = 1296
saveHeight = 972
saveQuality = 15 # Set jpeg quality (0 to 100)
# Test-Image settings
testWidth = 100
testHeight = 75
# this is the default setting if the whole image should be scanned for changed pixel
testAreaCount = 1
testBorders = [ [[1testWidth][1testHeight]] ] # [ [[start pixel on left sideend pixel on right side][start pixel on top sidestop pixel on bottom side]] ]
# testBorders are NOT zero-based the first pixel is 1 and the last pixel is testWith or testHeight
# with “testBorders“ you can define areas where the script should scan for changed pixel
# for example if your picture looks like this:
#
# ....XXXX
# ........
# ........
#
# “.“ is a street or a house “X“ are trees which move arround like crazy when the wind is blowing
# because of the wind in the trees there will be taken photos all the time. to prevent this your setting might look like this:
# testAreaCount = 2
# testBorders = [ [[150][175]] [[51100][2675]] ] # area y=1 to 25 not scanned in x=51 to 100
# even more complex example
# testAreaCount = 4
# testBorders = [ [[139][175]] [[4067][4375]] [[6885][4875]] [[86100][4175]] ]
# in debug mode a file debug.bmp is written to disk with marked changed pixel an with marked border of scan-area
# debug mode should only be turned on while testing the parameters above
debugMode = False # False or True
# Capture a small test image (for motion detection)
def captureTestImage(settings width height):
command = “raspistill %s -w %s -h %s -t 200 -e bmp -n -o -“ % (settings width height
评论
共有 条评论