Skip to content

Commit

Permalink
Add color option to python script
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Garufi committed May 5, 2015
1 parent e853ec4 commit 0ed5aa4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions python/pi-motion-lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,31 @@
from fractions import Fraction
import argparse

def parse_color(string):
colorMap = {'R': 0, 'G': 1, 'B': 2}
if colorMap.has_key(string):
return colorMap[string]
else:
msg = "%r is not a valid value. Please insert one of R G B" % string
raise argparse.ArgumentTypeError(msg)


parser = argparse.ArgumentParser()
parser.add_argument("-t", "--threshold", type=int, help="How Much a pixel has to change (default: 10)", default=10)
parser.add_argument("-s", "--sensitivity", type=int, help="How Many pixels need to change for motion detection (default: 200)", default=200)
parser.add_argument("-n", "--night", help="Set this if the script is running during the night", action="store_true")
parser.add_argument("-c", "--color", help="Pixel differences are computed using one of the RGB values for that pixel (defaults: G)", type=parse_color)
args = parser.parse_args()

#Constants
SECONDS2MICRO = 1000000 # Constant for converting Shutter Speed in Seconds to Microseconds
SECONDS2MICRO = 1000000 # Constant for converting Shutter Speed in Seconds to Microseconds

verbose = True # Display showMessage if True
verbose = True # Display showMessage if True
threshold = args.threshold # How Much a pixel has to change
sensitivity = args.sensitivity # How Many pixels need to change for motion detection
nightShut = 5.5 # seconds Night shutter Exposure Time default = 5.5 Do not exceed 6 since camera may lock up
nightShut = 5.5 # seconds Night shutter Exposure Time default = 5.5 Do not exceed 6 since camera may lock up
nightISO = 800
print args.color

testWidth = 100
testHeight = 75
Expand Down

0 comments on commit 0ed5aa4

Please sign in to comment.