def checkFP(): ## Tries to initialize the sensor try: f = PyFingerprint('/dev/ttyS0', 57600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): raise ValueError('The given fingerprint sensor password is wrong!') except Exception as e: print('The fingerprint sensor could not be initialized!') print('Exception message: ' + str(e)) exit(1) ## Gets some sensor information print('Currently used templates: ' + str(f.getTemplateCount()) + '/' + str(f.getStorageCapacity())) ## Tries to search the finger and calculate hash try: print('Waiting for finger...') ## Wait that finger is read while (f.readImage() == False): pass ## Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) ## Searchs template result = f.searchTemplate() positionNumber = result[0] accuracyScore = result[1] if (positionNumber == -1): print('No match found!') return -30 else: print('Found template at position #' + str(positionNumber)) print('The accuracy score is: ' + str(accuracyScore)) ## OPTIONAL stuff ## ## Loads the found template to charbuffer 1 f.loadTemplate(positionNumber, 0x01) ## Downloads the characteristics of template loaded in charbuffer 1 characterics = str(f.downloadCharacteristics(0x01)).encode('utf-8') ## Hashes characteristics of template print('SHA-2 hash of template: ' + hashlib.sha256(characterics).hexdigest()) return positionNumber except Exception as e: print('Operation failed!') print('Exception message: ' + str(e)) exit(1)
def search(): # Search for a finger print('\tEdu Attendance v1.0') print("") print("Esperando su Huella...") try: f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): raise ValueError( 'La Contraseña del sensor de huellas dactilares dada es incorrecta!' ) except Exception as e: print('No se puedo inicializar el sensor de huellas dactilares!') print('Mensaje de exepcion: ' + str(e)) exit(1) while True: try: # Wait that finger is read prnt = f.readImage() if (prnt != False): # Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) ## Searchs template result = f.searchTemplate() positionNumber = result[0] f.loadTemplate(positionNumber, 0x01) mysqlcursor.execute( "Select nombre FROM docente WHERE id_bio = ('%i')" % (positionNumber)) nombre = mysqlcursor.fetchone() sname = nombre[0] print("Bienvenido " + sname) break except Exception as e: print('No se Encontraron Coincidencias') print('Scanea de Nuevo!') time.sleep(2)
def finger(): try: f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): raise ValueError( 'La Contraseña del sensor de huellas dactilares dada es incorrecta!' ) except Exception as e: print('No se puedo inicializar el sensor de huellas dactilares!') print('Mensaje de exepcion: ' + str(e)) exit(1) ## Tries to enroll new finger while True: try: print('Waiting for finger...') ## Wait that finger is read while (f.readImage() == False): pass ## Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) ## Checks if finger is already enrolled result = f.searchTemplate() positionNumber = result[0] if (positionNumber >= 0): print('Template already exists at position #' + str(positionNumber)) exit(0) time.sleep(2) print('Waiting for same finger again...') ## Wait that finger is read again while (f.readImage() == False): pass ## Converts read image to characteristics and stores it in charbuffer 2 f.convertImage(0x02) ## Compares the charbuffers if (f.compareCharacteristics() == 0): raise Exception('Fingers do not match') print('Fingers do not match', str(positionNumber)) ## Creates a template f.createTemplate() ## Saves template at new position number positionNumber = f.storeTemplate() f.loadTemplate(positionNumber, 0x01) char_store = str(f.downloadCharacteristics(0x01)) char_store1 = char_store.translate("") var = '' for x in char_store1: var += x return positionNumber, var break except Exception as e: print('Error') print('Scanea de Nuevo!') time.sleep(2)
def attendance(): print('\tEdu Attendance v1.0') print('') lcdprint('Esperando su Huella..', 2) print("Esperando su Huella...") try: f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): raise ValueError( 'La Contraseña del sensor de huellas dactilares dada es incorrecta!' ) except Exception as e: print('No se puedo inicializar el sensor de huellas dactilares!') print('Mensaje de exepcion: ' + str(e)) exit(1) while True: try: ## Wait that finger is read prnt = f.readImage() if (prnt != False): ## Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) result = f.searchTemplate() positionNumber = f.storeTemplate() f.loadTemplate(positionNumber, 0x01) positionNumber = result[0] mysqlcursor.execute( "Select nombre FROM empleado WHERE id_huella = ('%i')" % (positionNumber)) nombre = mysqlcursor.fetchone() sname = nombre[0] print("Bienvenido " + sname) while True: menuIS() op = input("Ingrese una Opcion") if op == "1": new_status = 'Ingreso' new_fecha = datetime.datetime.now() sql = """INSERT INTO asistencia(id_empleado,estado,fecha) VALUES ((SELECT id_empleado FROM empleado WHERE id_bio='%i'),'%s','%s')""" % ( positionNumber, new_status, new_fecha) mysqlcursor.execute(sql) db.commit() db.rollback() print("Completado!") db.close() break elif op == "2": new_status = 'Salida' new_fecha = datetime.datetime.now() sql = """INSERT INTO asistencia(id_docente,estado,fecha) VALUES ((SELECT id_docente FROM docente WHERE id_bio='%i'),'%s','%s')""" % ( positionNumber, new_status, new_fecha) mysqlcursor.execute(sql) db.commit() db.rollback() print("Completado!") db.close() break else: print("Ingrese una Opcion Correcta") break break except Exception as e: print('No se Encontraron Coincidencias') print('Scanea de Nuevo!') time.sleep(2)
def enroll(): mylcd.lcd_clear() mylcd.lcd_display_string('Enter Password:'******'4209': mylcd.lcd_clear() mylcd.lcd_display_string('Enter ID Number', 1) r = raw_input("Enter ID Number: ") mylcd.lcd_display_string(r, 2, 2) sleep(2) ## GETTING INFORMATION FROM DATABASE conn = sqlite3.connect('/home/pi/attendance/app.db') curs = conn.cursor() db_val = curs.execute( 'SELECT rollnum from finger_store where rollnum in (values(?))', [r]) coun = (len(list(db_val))) if coun >= 1: mylcd.lcd_clear() mylcd.lcd_display_string('ID Number Already', 1) mylcd.lcd_display_string('Taken', 2, 2) sleep(2) conn.commit() conn.close() else: conn.commit() conn.close() ## Enrolls new finger ## ## Tries to initialize the sensor try: f = PyFingerprint('/dev/serial0', 9600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): mylcd.lcd_clear() mylcd.lcd_display_string('Contact Admin', 1) sleep(2) raise ValueError( 'The given fingerprint sensor password is wrong!') except Exception as e: mylcd.lcd_clear() mylcd.lcd_display_string('Contact Admin', 1) sleep(2) print('The fingerprint sensor could not be initialized!') print('Exception message: ' + str(e)) startChoice() ## Gets some sensor information mylcd.lcd_clear() mylcd.lcd_display_string('Currently used', 1) mylcd.lcd_display_string('templates: ', 2) mylcd.lcd_display_string(str(f.getTemplateCount()), 2, 13) sleep(2) print('Currently used templates: ' + str(f.getTemplateCount())) ## Tries to enroll new finger try: mylcd.lcd_clear() mylcd.lcd_display_string('Waiting for Finger', 2, 2) ## Wait that finger is read while (f.readImage() == False): pass ## Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) ## Checks if finger is already enrolled result = f.searchTemplate() positionNumber = result[0] if (positionNumber >= 0): mylcd.lcd_clear() mylcd.lcd_display_string('Template already', 1) mylcd.lcd_display_string('exists at ', 2) mylcd.lcd_display_string('position # ', 3) mylcd.lcd_display_string(str(positionNumber), 3, 13) sleep(3) print('Template already exists at position #' + str(positionNumber)) startChoice() else: mylcd.lcd_clear() mylcd.lcd_display_string('Remove finger...', 2, 2) print('Remove finger...') time.sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string('Waiting for same', 2) mylcd.lcd_display_string(' finger again', 3) print('Waiting for same finger again...') ## Wait that finger is read again while (f.readImage() == False): pass ## Converts read image to characteristics and stores it in charbuffer 2 f.convertImage(0x02) ## Compares the charbuffers if (f.compareCharacteristics() == 0): mylcd.lcd_clear() mylcd.lcd_display_string('Fingers not matched', 2) sleep(2) raise Exception('Fingers do not match') ## Creates a template f.createTemplate() ## Saves template at new position number positionNumber = f.storeTemplate() ## Loads the found template to charbuffer 1 f.loadTemplate(positionNumber, 0x01) ## Downloads the characteristics of template loaded in charbuffer 1 characterics = str( f.downloadCharacteristics(0x01)).encode('utf-8') ## Hashes characteristics of template cre_hash = hashlib.sha256(characterics).hexdigest() conn = sqlite3.connect('/home/pi/attendance/app.db') curs = conn.cursor() curs.execute( 'INSERT INTO finger_store(rollnum, hashval, id) values(?, ?, ?)', (r, cre_hash, positionNumber)) conn.commit() conn.close() mylcd.lcd_clear() mylcd.lcd_display_string('Finger enrolled', 2) mylcd.lcd_display_string('Successfully!', 3, 2) sleep(2) print('New template position #' + str(positionNumber)) startChoice() except Exception as e: print('Operation failed!') print('Exception message: ' + str(e)) startChoice() else: mylcd.lcd_clear() mylcd.lcd_display_string('Your Not Authorized!', 2) sleep(2)
def finger(): ## Search for a finger ## ## Tries to initialize the sensor try: f = PyFingerprint('/dev/serial0', 9600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): raise ValueError('The given fingerprint sensor password is wrong!') startChoice() except Exception as e: print('The fingerprint sensor could not be initialized!') print('Exception message: ' + str(e)) startChoice() ## Gets some sensor information print('Currently used templates: ' + str(f.getTemplateCount())) ## Tries to search the finger and calculate hash try: mylcd.lcd_clear() mylcd.lcd_display_string('Waiting for finger..', 2) ## Wait that finger is read while (f.readImage() == False): pass ## Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) ## Searchs template result = f.searchTemplate() positionNumber = result[0] accuracyScore = result[1] if (positionNumber == -1): mylcd.lcd_clear() mylcd.lcd_display_string('No match found!') sleep(2) mylcd.lcd_clear() startChoice() else: mylcd.lcd_clear() today_name = datetime.date.today() if calendar.day_name[today_name.weekday()] != ('Sunday' or 'Saturday'): ## Generating TIME VALUES now = datetime.datetime.now() my_time_string_10 = "10:30:00" my_time_string_12 = "12:30:00" my_time_string_13 = "13:29:59" my_time_string_14 = "14:30:00" my_time_string_16 = "16:00:01" time_10 = datetime.datetime.strptime(my_time_string_10, "%H:%M:%S") time_12 = datetime.datetime.strptime(my_time_string_12, "%H:%M:%S") time_13 = datetime.datetime.strptime(my_time_string_13, "%H:%M:%S") time_14 = datetime.datetime.strptime(my_time_string_14, "%H:%M:%S") time_16 = datetime.datetime.strptime(my_time_string_16, "%H:%M:%S") # I am supposing that the date must be the same as now time_10 = now.replace(hour=time_10.time().hour, minute=time_10.time().minute, second=time_10.time().second, microsecond=0) time_12 = now.replace(hour=time_12.time().hour, minute=time_12.time().minute, second=time_12.time().second, microsecond=0) time_13 = now.replace(hour=time_13.time().hour, minute=time_13.time().minute, second=time_13.time().second, microsecond=0) time_14 = now.replace(hour=time_14.time().hour, minute=time_14.time().minute, second=time_14.time().second, microsecond=0) time_16 = now.replace(hour=time_16.time().hour, minute=time_16.time().minute, second=time_16.time().second, microsecond=0) print('Found template at position #' + str(positionNumber)) mylcd.lcd_display_string('PLEASE WAIT', 2, 3) ## Create Hash Value for finger ## ## Loads the found template to charbuffer 1 f.loadTemplate(positionNumber, 0x01) ## Downloads the characteristics of template loaded in charbuffer 1 characterics = str( f.downloadCharacteristics(0x01)).encode('utf-8') val_hash = hashlib.sha256(characterics).hexdigest() ## Hashes characteristics of template print('SHA-2 hash of template: ' + val_hash) ## GETTING INFORMATION FROM DATABASE conn = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) curs = conn.cursor() db_val = curs.execute( 'SELECT rollnum, hashval from finger_store where hashval in (values(?))', [val_hash]) for row in db_val: ext_id = row[0] mylcd.lcd_clear() mylcd.lcd_display_string("YOUR ID NUMBER:", 2, 2) mylcd.lcd_display_string(ext_id, 3, 3) sleep(2) mylcd.lcd_clear() conn.commit() conn.close() con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) curs2 = con.cursor() curs2.execute( 'SELECT date from attendance where (date, rollnum) in (values(?, ?))', (datetime.date.today(), ext_id)) d = curs2.fetchone() con.close() if d == None: con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'INSERT INTO attendance (rollnum,date) values(?, ?)', (ext_id, datetime.date.today())) con.commit() con.close() ## GETTING INFORMATION FROM DATABASE con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) curs2 = con.cursor() curs2.execute( 'SELECT status,statusexit,statusnoon,statusnoonexit from attendance where (date, rollnum) in (values(?, ?))', (datetime.date.today(), ext_id)) row = curs2.fetchall() for all in row: status1 = all[0] status2 = all[1] status3 = all[2] status4 = all[3] con.close() if status1 == 'absent': if now < time_10: con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'UPDATE attendance Set status = ? where (rollnum, date) in (values(?, ?))', ('present', ext_id, datetime.date.today())) con.commit() con.close() mylcd.lcd_display_string("Attendance Success for", 1) mylcd.lcd_display_string(" this Morining", 2) sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string("Dont forgot to ", 1) mylcd.lcd_display_string("comeback after 12:30 PM", 2) sleep(2) mylcd.lcd_clear() elif (now >= time_10) and (now <= time_13): mylcd.lcd_display_string("Sorry, You are Late today", 1) sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string("Come Afternoon ", 2) mylcd.lcd_display_string("or Tomorrow", 3) sleep(2) mylcd.lcd_clear() elif now > time_13: if status3 == 'absent': if now <= time_14: con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'UPDATE attendance Set statusnoon = ? where (rollnum, date) in (values(?, ?))', ('present', ext_id, datetime.date.today())) con.commit() con.close() mylcd.lcd_display_string( "Attendance Success ", 1) mylcd.lcd_display_string( "for this Afternoon", 2) sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string("Dont forgot to ", 1) mylcd.lcd_display_string("comeback after", 2) mylcd.lcd_display_string("04:00 PM ", 3) sleep(3) mylcd.lcd_clear() elif now > time_14: mylcd.lcd_display_string( "Sorry, You are Late", 2) sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string( "Please Come Early ", 1) mylcd.lcd_display_string("Tomorrow", 2, 2) sleep(2) mylcd.lcd_clear() elif status3 == 'present': if now < time_16: mylcd.lcd_display_string( "You're leaving Early", 1) mylcd.lcd_display_string("Please come back", 2) mylcd.lcd_display_string("after 4 PM", 3) sleep(3) mylcd.lcd_clear() elif now >= time_16: if status4 == 'present': mylcd.lcd_display_string( "Thought you were", 1) mylcd.lcd_display_string( "already in your home!", 2) sleep(2) mylcd.lcd_clear() else: con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'UPDATE attendance Set statusnoonexit = ? where (rollnum, date) in (values(?, ?))', ('present', ext_id, datetime.date.today())) con.commit() con.close() mylcd.lcd_display_string( "Attendance Success,", 2) mylcd.lcd_display_string( " Happy Day!", 3, 2) sleep(2) mylcd.lcd_clear() elif status1 == 'present': if now < time_12: mylcd.lcd_display_string("Not the time to", 2) mylcd.lcd_display_string("leave", 3, 2) sleep(2) mylcd.lcd_clear() elif (now >= time_12) and (now <= time_13): con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'UPDATE attendance Set statusexit = ? where (rollnum, date) in (values(?, ?))', ('present', ext_id, datetime.date.today())) con.commit() con.close() mylcd.lcd_display_string("Attendance Success", 1) mylcd.lcd_display_string("Now Go and", 2, 2) mylcd.lcd_display_string("have your LUNCH :)", 3) sleep(3) mylcd.lcd_clear() elif now > time_13: if status3 == 'absent': if now <= time_14: con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'UPDATE attendance Set statusnoon = ? where (rollnum, date) in (values(?, ?))', ('present', ext_id, datetime.date.today())) con.commit() con.close() mylcd.lcd_display_string( "Attendance Success ", 1) mylcd.lcd_display_string( "for this Afternoon", 2) sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string("Dont forgot to ", 1) mylcd.lcd_display_string("comeback after", 2) mylcd.lcd_display_string("04:00 PM ", 3) sleep(3) mylcd.lcd_clear() elif now > time_14: mylcd.lcd_display_string( "Sorry, You are Late", 2) sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string( "Please Come Early ", 1) mylcd.lcd_display_string("Tomorrow", 2, 2) sleep(2) mylcd.lcd_clear() elif status3 == 'present': if now < time_16: mylcd.lcd_display_string( "You're leaving Early", 1) mylcd.lcd_display_string("Please come back", 2) mylcd.lcd_display_string("after 4 PM", 3) sleep(3) mylcd.lcd_clear() elif now >= time_16: if status4 == 'present': mylcd.lcd_display_string( "Thought you were", 1) mylcd.lcd_display_string( "already in your home!", 2) sleep(2) mylcd.lcd_clear() else: con = sqlite3.connect( '/home/pi/Desktop/pro/attendance-20180412T122709Z-001/attendance/app.db' ) c = con.cursor() c.execute( 'UPDATE attendance Set statusnoonexit = ? where (rollnum, date) in (values(?, ?))', ('present', ext_id, datetime.date.today())) con.commit() con.close() mylcd.lcd_display_string( "Attendance Success,", 2) mylcd.lcd_display_string( " Happy Day!", 3, 2) sleep(2) mylcd.lcd_clear() else: while True: mylcd.lcd_clear() mylcd.lcd_display_string('Today is a holiday', 2, 2) mylcd.lcd_clear() mylcd.lcd_display_string('So no ATTENDANCE, Enjoy!', 3, 2) startChoice() except Exception as e: print('Operation failed!') print('Exception message: ' + str(e)) startChoice()
## Searchs template result = f.searchTemplate() positionNumber = result[0] accuracyScore = result[1] if (positionNumber == -1): print('No match found!') exit(0) else: print('Found template at position #' + str(positionNumber)) print('The accuracy score is: ' + str(accuracyScore)) ## OPTIONAL stuff ## ## Loads the found template to charbuffer 1 f.loadTemplate(positionNumber, 0x01) ## Downloads the characteristics of template loaded in charbuffer 1 characterics = str(f.downloadCharacteristics(0x01)).encode('utf-8') ## Hashes characteristics of template print('SHA-2 hash of template: ' + hashlib.sha256(characterics).hexdigest()) except Exception as e: print('Operation failed!') print('Exception message: ' + str(e)) exit(1)
def enroll(): global employee global r global fun print(employee) r = employee print('employee ID:', r) print('') conn = sqlite3.connect('/home/pi/Desktop/beta/employee.db') c = conn.cursor() db_val = c.execute( 'SELECT employ_num FROM finger_store WHERE employ_num IN (VALUES(?))', [r]) coun = (len(list(db_val))) if coun >= 1: mylcd.lcd_clear() mylcd.lcd_display_string(' ID Already Exists', 2) print('ID Already Exists') print('') time.sleep(2) conn.commit() conn.close() main_menu() else: conn.commit() conn.close() try: f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000) if (f.verifyPassword() == False): print('Contact Admin') print('') time.sleep(2) raise ValueError('The given fingerprint sensor password wrong') except Exception as e: mylcd.lcd_clear() mylcd.lcd_display_string(' Contact Admin', 2) print('Contact Admin') print('') time.sleep(2) print('The fingerprint sensor could not be initialized') print('Exception message: ' + str(e)) print('') main_menu() print('Currently used templates: ' + str(f.getTemplateCount())) print('') try: mylcd.lcd_clear() mylcd.lcd_display_string('*Waiting For Finger*', 2) print('*Waiting For Finger*') print('') # Wait for finger to be read while (f.readImage() == False): pass f.convertImage(0x01) result = f.searchTemplate() positionNumber = result[0] if (positionNumber >= 0): mylcd.lcd_clear() mylcd.lcd_display_string('Fingerprint Already', 2) mylcd.lcd_display_string(' Exists', 3) print('Fingerprint Already Exists' + str(positionNumber)) print('') time.sleep(2) main_menu() else: mylcd.lcd_clear() mylcd.lcd_display_string(' *Remove Finger*', 2) print('*Remove Finger*') print('') time.sleep(2) mylcd.lcd_clear() mylcd.lcd_display_string('*Place Finger Again*', 2) print('*Place Finger Again*') print('') # waiting for second read while (f.readImage() == False): pass f.convertImage(0X02) if (f.compareCharacteristics() == 0): mylcd.lcd_clear() mylcd.lcd_display_string('Fingers Do Not Match', 2) print('Fingers Do Not Match') print('') time.sleep(2) f.createTemplate() positionNumber = f.storeTemplate() f.loadTemplate(positionNumber, 0X01) characteristics = str( f.downloadCharacteristics(0x01)).encode('utf-8') cre_hash = hashlib.sha256(characteristics).hexdigest() conn = sqlite3.connect('/home/pi/Desktop/beta/employee.db') c = conn.cursor() c.execute( 'INSERT INTO finger_store (employ_num, hashval, id) ' 'VALUES (?,?,?)', (r, cre_hash, positionNumber)) conn.commit() conn.close() mylcd.lcd_clear() mylcd.lcd_display_string(' Fingerprint', 2) mylcd.lcd_display_string(' Registered', 3) print('Fingerprint Registered In Position' + str(positionNumber)) print('') time.sleep(2) admin_menu() except Exception as e: print('Operation failed- Exception message: ' + str(e)) print('') main_menu()
def print_grab(): global person try: f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000) mylcd.lcd_clear() mylcd.lcd_display_string('*Waiting For Finger*', 2) print('*Waiting For Finger*') print('') ## Wait that finger is read while f.readImage() == False: pass ## Converts read image to characteristics and stores it in charbuffer 1 f.convertImage(0x01) ## Searches template result = f.searchTemplate() positionNumber = result[0] if positionNumber == -1: mylcd.lcd_clear() mylcd.lcd_display_string(' No Match Found', 2) print('No match found') print('') time.sleep(2) main_menu() else: print('Found template at position #' + str(positionNumber)) print('') mylcd.lcd_clear() mylcd.lcd_display_string(' PLEASE WAIT', 2) print('PLEASE WAIT') print('') ## Create Hash Value for finger ## Loads the found template to charbuffer 1 f.loadTemplate(positionNumber, 0x01) ## Downloads the characteristics of template loaded in charbuffer 1 characteristics = str( f.downloadCharacteristics(0x01)).encode('utf-8') hashval = hashlib.sha256(characteristics).hexdigest() ## Hashes characteristics of template print('SHA-2 hash of template: ' + hashval) print('') #GETTING INFORMATION FROM DATABASE conn = sqlite3.connect('/home/pi/Desktop/beta/employee.db') c = conn.cursor() c.execute('SELECT * FROM finger_store WHERE id=?', [positionNumber]) db_val = c.fetchall() for row in db_val: person = row[0] mylcd.lcd_clear() mylcd.lcd_display_string(' ID NUMBER:', 2) mylcd.lcd_display_string(' ' + person, 3) print("YOUR ID NUMBER:" + person) print('') time.sleep(2) conn.commit() conn.close() check_if_in() except Exception as e: print(e)