Exemple #1
0
def selfie():
	synthesize.say("Selfie Time!")
	time.sleep(1.2)
	synthesize.say('Say Cheese!')
	time.sleep(1.5)
	filename = ('image{}.jpg'.format(time.time()))
	take_picture('./selfies/' + filename)
	synthesize.say('Snip!')
	emailio.send_mail('*****@*****.**', '*****@*****.**', '', '', ['./selfies/' + filename])
Exemple #2
0

#Source: http://www.pyimagesearch.com/2014/09/15/python-compare-two-images/
def mse(imageA, imageB):
    h1 = imageA.histogram()
    h2 = imageB.histogram()
    rms = math.sqrt(reduce(operator.add,
                           map(lambda a,b: (a-b)**2, h1, h2))/len(h1))
    return rms
in_alarm = False
while True:
    if in_normal_mode:
        command = inputs.next()
        if interpreter.interpret(command):
            in_normal_mode = not in_normal_mode
            emailio.send_mail('*****@*****.**','*****@*****.**','Security mode has been enabled','Security mode has been enabled. Yikes!')
            synthesize.say('Security Mode Activated.  Yikes!')
    else:
        check_email_count += 1
        light.turn_on(True)
        #Take a picture
        camera_util.take_picture("pictures/current.jpg")
        #Compare to previous picture
        if (compare_photos("pictures/current.jpg", "pictures/last.jpg", in_alarm) == True) and pic_count > 3:
            #Store current photo
            shutil.copyfile('pictures/current.jpg','pictures/kept/sec_'+str(time.time()))
            if not in_alarm:
                in_alarm = True
                #Email current photo to Trevor
		synthesize.say("You shouldn't be snooping around here at this time.  Someone might think you're... up to something.")
                emailio.send_mail('*****@*****.**','*****@*****.**','Uh oh...','Possible security breach detected',['pictures/current.jpg','pictures/last.jpg'])