示例#1
0
    def checkpass() :
        kp = keypad()
        txt = password_txt()
        display = lcddriver.lcd()
        display.lcd_clear()
        time.sleep(1)
        check = 0
        arrayPass = []
        show = ""
        count = 0
        rounds = 0
        display.lcd_display_string("Enter Password    ",1)
        while True :
            # Loop while waiting for a keypress
            digit = None
            while digit == None:
                digit = kp.getKey()
                time.sleep(0.1)
                rounds += 1
                if(rounds == 150):
                    break
            if(rounds == 150):
                break
                
            if(digit != "A" and digit != "B" and digit != "C" and digit != "D" and digit != "*" and digit != "#"):
                time.sleep(0.4)
                arrayPass.append(str(digit))
                count += 1
                rounds = 0
                
            if digit == "B" :
                    time.sleep(0.4)
                    if(count != 0) :
                        count = count - 1
                        arrayPass.pop(count)
                        display.lcd_display_string("                ",2)
                        rounds = 0
                        
            show = ""
            if(count != 0):
                for i in range(count):
                    show += str(arrayPass[i])     
            display.lcd_display_string(show,2)
            time.sleep(0.4)

            if(count == 4):
                password = txt.read()
                if(str(show) == str(password)):
                    check = 1
                else:
                    display.lcd_display_string("Incorrect!!!    ",2)
                    time.sleep(3)
                break

        display.lcd_clear()
        time.sleep(1)
        if(check == 1):
            return True
        else:
            return False
示例#2
0
 def menu(self):
     display = lcddriver.lcd()
     kp = keypad()
     display.lcd_clear()
     time.sleep(1)
     while True :
         display.lcd_display_string("A)Shutdown",1)
         display.lcd_display_string("B)Reboot",2)
         key = None
         while key == None:
             key = kp.getKey()
         if(key == "A"):
             display.lcd_clear()
             time.sleep(1)
             display.lcd_display_string("Shutdown...",1)
             time.sleep(2)
             display.lcd_clear()
             print(subprocess.call("shutdown -h now", shell=True))
             break
         if(key == "B"):
             display.lcd_clear()
             time.sleep(1)
             display.lcd_display_string("Reboot...",1)
             print(subprocess.call("sudo reboot", shell=True))
             break
         if(key == "C"):
             password.changepass()
             break
         if(key == "D"):
             display.lcd_clear()
             time.sleep(1)
             display.lcd_display_string("Cancel...",1)
             time.sleep(2)
             break
示例#3
0
    def camera_on(self):
        try:
            display = lcddriver.lcd()
            display.lcd_clear()
            time.sleep(1)
            display.lcd_display_string("Camera Detect", 1)
            cap = cv2.VideoCapture(0)
            snd = sound()
            check_eye = 0
            sound_alert = 0
            display.lcd_display_string("Ready...     ", 2)
            while (True):
                ret, frame = cap.read()
                frame = cv2.resize(frame, (240, 160),
                                   interpolation=cv2.INTER_AREA)
                frame, check_eye = self.detect(frame, self.eyeCascade,
                                               check_eye)
                if (sound_alert == 0 and check_eye > 11):
                    snd.on()
                    sound_alert = 1
                    display.lcd_display_string("Detected !!!", 2)

                elif (sound_alert == 1 and check_eye == 0):
                    snd.off()
                    sound_alert = 0
                    display.lcd_display_string("Ready...     ", 2)
                kp = keypad()
                if (kp.getKey() == "D"):
                    time.sleep(0.4)
                    display.lcd_display_string("Stopping...  ", 2)
                    time.sleep(2)
                    display.lcd_clear()
                    if (sound_alert == 1):
                        snd.off()
                    break

            cap.release()
            cv2.destroyAllWindows()

        except:
            display.lcd_display_string("Port Error!!!  ", 2)
            time.sleep(3)
            display.lcd_clear()
            time.sleep(1)
            display.lcd_display_string("Reboot...", 1)
            print(subprocess.call("sudo reboot", shell=True))
示例#4
0
    def camera_on(self):
        display = lcddriver.lcd()
        cap = cv2.VideoCapture(0)
        snd = sound()
        check_face = 0
        check_eye = 0
        sound_alert = 0
        display.lcd_clear()
        time.sleep(1)
        display.lcd_display_string("Camera Detect", 1)
        display.lcd_display_string("Ready...  ", 2)
        while (True):
            ret, frame = cap.read()
            frame = cv2.resize(frame, (176, 144), interpolation=cv2.INTER_AREA)
            frame, check_face, check_eye = self.detect(frame, self.faceCascade,
                                                       self.eyeCascade,
                                                       check_face, check_eye)
            if (sound_alert == 0 and (check_face > 30 or check_eye > 10)):
                snd.on()
                sound_alert = 1
                if (check_face > 30):
                    display.lcd_display_string("Face !!! ", 2)
                elif (check_eye > 10):
                    display.lcd_display_string("Eye !!!  ", 2)

            elif (sound_alert == 1 and (check_face == 0 and check_eye == 0)):
                snd.off()
                sound_alert = 0
                display.lcd_display_string("Ready...  ", 2)
            kp = keypad()
            if (kp.getKey() == "D"):
                time.sleep(0.4)
                display.lcd_display_string("Stopping...", 2)
                time.sleep(2)
                display.lcd_clear()
                if (sound_alert == 1):
                    snd.off()
                break

        cap.release()
        cv2.destroyAllWindows()
示例#5
0
time.sleep(1)
main_sd.off()
time.sleep(10)
display.lcd_clear()
time.sleep(3)
display.lcd_display_string("  Program     ", 1)
display.lcd_display_string("    Starting...", 2)
time.sleep(10)
display.lcd_clear()
time.sleep(1)

password.checkstart()

try:
    while True:
        main_kp = keypad()
        main_cm = camera()
        main_gps = gps()
        main_pw = power()
        display.lcd_display_string("A)Phone B)Camera", 1)
        display.lcd_display_string("C)Park  D)Power", 2)
        key = None
        while key == None:
            key = main_kp.getKey()
        if (key == "A"):
            time.sleep(0.4)
            main_kp.getNumberPhone()
        elif (key == "B"):
            time.sleep(0.4)
            main_cm.camera_on()
        elif (key == "C"):
示例#6
0
    def checkLatLng(self):
        display = lcddriver.lcd()
        display.lcd_clear()
        time.sleep(1)
        display.lcd_display_string("Parking lot  ", 1)
        global lat_df, lng_df, charlatlng, ser
        try:
            ser = serial.Serial('/dev/ttyACM0', 9600,
                                timeout=1)  # Open Serial port
        except:
            display.lcd_display_string("Port Error!!!  ", 2)
            time.sleep(3)
            display.lcd_clear()
            time.sleep(1)
            display.lcd_display_string("Reboot...", 1)
            print(subprocess.call("sudo reboot", shell=True))
        txt = phone_txt()
        phoneNumber = txt.read()
        send = sms()
        count = 0
        reconnect = 0
        try:
            while True:
                line = self.readString()
                lines = line.split(",")
                if (self.checksum(line)):
                    if lines[0] == "GPGLL":
                        latlng = self.getLatLng(lines[1], lines[3])
                        if (latlng[0] == 0 and latlng[1] == 0):
                            display.lcd_display_string("Connecting...  ", 2)
                            while (reconnect < 10):
                                if (subprocess.call(
                                        "python3 /home/pi/Desktop/Face_Detection/GPS_Tester.py",
                                        shell=True) == 0):
                                    break
                                else:
                                    reconnect = reconnect + 1
                                time.sleep(1)
                            if (reconnect == 10):
                                display.lcd_display_string("No Signal!!!  ", 2)
                                time.sleep(3)
                                display.lcd_clear()
                                time.sleep(1)
                                break
                            else:
                                time.sleep(1)
                                self.checkLatLng()
                                break
                        display.lcd_display_string("Ready...   ", 2)
                        if (count == 0):
                            lat_df = "{0:.4f}".format(float(latlng[0]))
                            lng_df = "{0:.4f}".format(float(latlng[1]))
                            lat_df = float(lat_df)
                            lng_df = float(lng_df)
                            count = 1
                        elif (count == 1):
                            lat_new = "{0:.4f}".format(float(latlng[0]))
                            lng_new = "{0:.4f}".format(float(latlng[1]))
                            lat_new = float(lat_new)
                            lng_new = float(lng_new)

                            if ((lat_df + 0.0005 < lat_new)
                                    or (lat_df - 0.0005 > lat_new)
                                    or (lng_df + 0.0005 < lng_new)
                                    or (lng_df - 0.0005 > lng_new)):
                                display.lcd_display_string("Detected !!!  ", 2)
                                send.sendsms(
                                    phoneNumber,
                                    "Detected!!!, Your car leaves the parking lot."
                                )
                                charlatlng = "http://maps.google.com/maps?q=" + str(
                                    latlng[0]) + str(lines[2]) + "," + str(
                                        latlng[1]) + str(lines[4])
                                send.sendsms(phoneNumber, charlatlng)

                                while True:
                                    lat_df = "{0:.4f}".format(float(latlng[0]))
                                    lng_df = "{0:.4f}".format(float(latlng[1]))
                                    lat_df = float(lat_df)
                                    lng_df = float(lng_df)

                                    for x in range(300):
                                        kp = keypad()
                                        if (kp.getKey() == "D"):
                                            time.sleep(0.4)
                                            if (password.checkpass()):
                                                count = 3
                                                break
                                            display.lcd_display_string(
                                                "Parking lot   ", 1)
                                            display.lcd_display_string(
                                                "Detected !!!  ", 2)
                                        else:
                                            while True:
                                                line = self.readString()
                                                lines = line.split(",")
                                                if (self.checksum(line)):
                                                    if lines[0] == "GPGLL":
                                                        latlng = self.getLatLng(
                                                            lines[1], lines[3])
                                                        break

                                    lat_new = "{0:.4f}".format(float(
                                        latlng[0]))
                                    lng_new = "{0:.4f}".format(float(
                                        latlng[1]))
                                    lat_new = float(lat_new)
                                    lng_new = float(lng_new)

                                    if ((lat_df + 0.0005 < lat_new)
                                            or (lat_df - 0.0005 > lat_new)
                                            or (lng_df + 0.0005 < lng_new)
                                            or (lng_df - 0.0005 > lng_new)):
                                        charlatlng = "http://maps.google.com/maps?q=" + str(
                                            latlng[0]) + str(
                                                lines[2]) + "," + str(
                                                    latlng[1]) + str(lines[4])
                                        send.sendsms(phoneNumber, charlatlng)

                                    if (count == 3):
                                        break
                else:
                    display.lcd_display_string("GPS Error!!! ", 2)
                    time.sleep(3)
                    display.lcd_clear()
                    break
                kp = keypad()
                if (kp.getKey() == "D" or count == 3):
                    time.sleep(0.4)
                    if (count == 3):
                        display.lcd_display_string("Parking lot  ", 1)
                        display.lcd_display_string("Stopping...    ", 2)
                        send.sendsms(phoneNumber,
                                     "Detect parking lot is stopping")
                        display.lcd_clear()
                        time.sleep(1)
                        break
                    else:
                        if (password.checkpass()):
                            display.lcd_display_string("Parking lot  ", 1)
                            display.lcd_display_string("Stopping...    ", 2)
                            time.sleep(2)
                            display.lcd_clear()
                            time.sleep(1)
                            break
                        else:
                            display.lcd_display_string("Parking lot  ", 1)

        finally:
            print("GPS Shutdown")
示例#7
0
    def changepass() :
        kp = keypad()
        txt = password_txt()
        display = lcddriver.lcd()
        display.lcd_clear()
        time.sleep(1)
        arrayPass = []
        show = ""
        count = 0
        out = 0
        display.lcd_display_string("Old Password    ",1)
        while True :
            # Loop while waiting for a keypress
            digit = None
            while digit == None:
                digit = kp.getKey()
                
            if(digit != "A" and digit != "B" and digit != "C" and digit != "D" and digit != "*" and digit != "#"):
                time.sleep(0.4)
                arrayPass.append(str(digit))
                count += 1
                
            if digit == "B" :
                    time.sleep(0.4)
                    if(count != 0) :
                        count = count - 1
                        arrayPass.pop(count)
                        display.lcd_display_string("                ",2)
                        
            if digit == "D" :
                    time.sleep(0.4)
                    display.lcd_display_string("Cancel...     ",2)
                    time.sleep(3)
                    display.lcd_clear()
                    time.sleep(1)
                    out = 1
                    break
                        
            show = ""
            if(count != 0):
                for i in range(count):
                    show += str(arrayPass[i])     
            display.lcd_display_string(show,2)
            time.sleep(0.4)

            if(count == 4):
                password = txt.read()
                if(str(show) == str(password)):
                    break
                else:
                    display.lcd_display_string("Incorrect!!!    ",2)
                    time.sleep(2)
                    display.lcd_display_string("                ",2)
                    arrayPass.clear()
                    count = 0

        if(out == 0):
            arrayPass.clear()
            count = 0
            display.lcd_display_string("New Password    ",1)
            display.lcd_display_string("                ",2)
            while True :
                # Loop while waiting for a keypress
                digit = None
                while digit == None:
                    digit = kp.getKey()
                    
                if(digit != "A" and digit != "B" and digit != "C" and digit != "D" and digit != "*" and digit != "#"):
                    time.sleep(0.4)
                    arrayPass.append(str(digit))
                    count += 1
                    
                if digit == "B" :
                        time.sleep(0.4)
                        if(count != 0) :
                            count = count - 1
                            arrayPass.pop(count)
                            display.lcd_display_string("                ",2)

                if digit == "D" :
                    time.sleep(0.4)
                    display.lcd_display_string("Cancel...     ",2)
                    time.sleep(3)
                    display.lcd_clear()
                    time.sleep(1)
                    break
                            
                show = ""
                if(count != 0):
                    for i in range(count):
                        show += str(arrayPass[i])     
                display.lcd_display_string(show,2)
                time.sleep(0.4)

                if(count == 4):
                    newpass = str(show)
                    arrayPass.clear()
                    count = 0
                    display.lcd_display_string("Confirm Password",1)
                    display.lcd_display_string("                ",2)
                    while True :
                        # Loop while waiting for a keypress
                        digit = None
                        while digit == None:
                            digit = kp.getKey()
                            
                        if(digit != "A" and digit != "B" and digit != "C" and digit != "D" and digit != "*" and digit != "#"):
                            time.sleep(0.4)
                            arrayPass.append(str(digit))
                            count += 1
                            
                        if digit == "B" :
                                time.sleep(0.4)
                                if(count != 0) :
                                    count = count - 1
                                    arrayPass.pop(count)
                                    display.lcd_display_string("                ",2)

                        if digit == "D" :
                            time.sleep(0.4)
                            display.lcd_display_string("Cancel...     ",2)
                            time.sleep(3)
                            display.lcd_clear()
                            time.sleep(1)
                            out = 1
                            break
                                    
                        show = ""
                        if(count != 0):
                            for i in range(count):
                                show += str(arrayPass[i])     
                        display.lcd_display_string(show,2)
                        time.sleep(0.4)

                        if(count == 4):
                            if(str(show) == str(newpass)):
                                out = 1
                                txt.add(newpass)
                                display.lcd_display_string("Change Complete ",2)
                                time.sleep(3)
                                break
                            else:
                                display.lcd_display_string("Not Match!!!    ",2)
                                time.sleep(2)
                                display.lcd_display_string("                ",2)
                                arrayPass.clear()
                                count = 0
                                
                if(out == 1):
                    display.lcd_clear()
                    break