print(face) elif id == res[0] and res[1] > 70: face = False print(face) #elif id == res[0] and res[1] < 80: # face = True # Solenoid.unlock_door(Solenoid.lock) break if __name__ == '__main__': while True: res = fr.recognize() #print("%s, %s" % (id, res)) print(res) #res[0] = id #print (id) #sleep(.5) if res is not None and res[1] < 77: id = res[0] t = Thread(target=check) t.start() t.join() face = True Solenoid.unlock_door(Solenoid.lock) #GPIO.cleanup() #face = False print(face) GPIO.cleanup()
res = fr.recognize() if res is not None: print("%s, %s" % (id, res)) if id != res[0]: face = False print(face) elif id == res[0] and res[1] > 85: face = False print(face) break if __name__ == '__main__': while True: res = fr.recognize() print(res) if res is not None and res[1] < 80: id = res[0] face = True t = Thread(target=check) t.start() t.join() if face is True: Solenoid.unlock_door(21) #GPIO.cleanup() #face = Falseeee111111 print(face) sleep(10) #GPIO.cleanup()
def get(self): # oldpos = "" while True: try: print("Starting the loop for checking values on Firebase") data = fb.get_data() # getting firebase values lock = data['doorbell']['lock']['state'] face = data['doorbell']['face']['state'] camera = data['doorbell']['camera']['state'] audio = data['doorbell']['audio']['state'] time.sleep(.5) print(lock) # checking if door has been unlockedd if lock == "open": print("The lock has been opened") Solenoid.unlock_door(Solenoid.lock) readings = {'doorbell/lock/state': "closed"} fb.update_data(readings) # take pictures for new face recognition if face == "new": print("New face being added..") nface.take_pictures() print("Face Added and Trained") readings = {'doorbell/face/state': "added"} fb.update_data(readings) """ elif face == "train": print ("Face being trained") tface.train_faces() readings = {'doorbell/face/state': "trained"} fb.update_data(readings) if camera == "start": print ("camera start") #p = subprocess.call( # 'gst-launch-1.0 -v v4l2src device=/dev/video0 ! videoconvert ! video/x-raw,width=640,height=480,framerate=30/1,format=I420 ! omxh264enc periodicty-idr=45 inline-header=FALSE ! h264parse ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink name=sink stream-name="test" access-key="AKIAIEKOVTSQMMS4JRTQ" secret-key="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" alsasrc device=hw:2,0 ! audioconvert ! avenc_aac ! queue ! sink.', shell=True) #print(p) #os.system("docker start bell") #start_stream.start() #time.sleep(20) readings = {'doorbell/camera/state': "waiting"} fb.update_data(readings) elif camera == "stop": print ("camera stop") os.system("docker stop bell") readings = {'doorbell/camera/state': "waiting"} fb.update_data(readings)""" if audio == "new": fb.download_file() print("new audio") #file = "audio.mp3" # m = alsaaudio.Mixer("PCM") # current_volume = m.getvolume() # Get the current Volume # m.setvolume(75) # Set the volume to 70%. # print (current_volume) #os.system("mpg123 " + file) os.system("omxplayer audio.mp3") readings = {'doorbell/audio/state': "waiting"} fb.update_data(readings) except KeyboardInterrupt: #p.stop() GPIO.cleanup() sys.exit(0) #threadGet.join() print("Interrupted")
def get(self): # oldpos = "" while True: try: print("Starting the loop for checking values on Firebase") data = fb.get_data() # getting firebase values lock = data['doorbell']['lock']['state'] face = data['doorbell']['face']['state'] camera = data['doorbell']['camera']['state'] audio = data['doorbell']['audio']['state'] time.sleep(.5) print(lock) # checking if door has been unlockedd if lock == "open": print ("The lock has been opened") Solenoid.unlock_door(Solenoid.lock) readings = {'doorbell/lock/state': "closed"} fb.update_data(readings) # take pictures for new face recognition if face == "new": print ("New face being added..") nface.take_pictures() print ("Face Added and Trained") readings = {'doorbell/face/state': "added"} fb.update_data(readings) # elif face == "train": # print ("Face being trained") # tface.train_faces() # readings = {'doorbell/face/state': "trained"} # fb.update_data(readings) if camera == "start": print ("camera start") os.system("docker start youtube") readings = {'doorbell/camera/state': "waiting"} fb.update_data(readings) elif camera == "stop": print ("camera stop") os.system("docker stop youtube") readings = {'doorbell/camera/state': "waiting"} fb.update_data(readings) if audio == "new": fb.download_file() print ("new audio") #file = "audio.mp3" # m = alsaaudio.Mixer("PCM") # current_volume = m.getvolume() # Get the current Volume # m.setvolume(75) # Set the volume to 70%. # print (current_volume) #os.system("mpg123 " + file) os.system("omxplayer audio.mp3") readings = {'doorbell/audio/state': "waiting"} fb.update_data(readings) except KeyboardInterrupt: #p.stop() GPIO.cleanup() sys.exit(0) #threadGet.join() print ("Interrupted") #def threads(self): # print("STARTING LISTENER") # threadGet = Thread(target=self.get()) # threadGet.start() # threadGet.join() #print("before thread") #listener.threads(self) # running the main #if __name__ == '__main__': # print("IN MAIN") # setup threads # threadGet = Thread(target=listener.get(self)) # start threads # threadGet.start() # join threads # threadGet.join()