def getFingerprintID():
    p = False
    while(not p):
        p = Fingerprint.getImage()
        if(p):
            print ("Image Taken")
            break
        elif(not p):
            print ("No finger detected")
        else:
            print ("Unknown Error")
    
    p = Fingerprint.image2Tz(1)
    
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p
    
    p = Fingerprint.fingerSearch()
    
    if(p):
        print ("Found fingerprint")
    elif(not p):
        print ("No fingerprint found")
        return p
    else:
        print ("Unknown Error")
        return p
def getFingerprintID():
    p = False
    while(not p):
        p = Fingerprint.getImage()
        if(p):
            print ("Image Taken")
            break
        elif(not p):
            print ("No finger detected")
        else:
            print ("Unknown Error")
    
    p = Fingerprint.image2Tz(1)
    
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p
    
    p = Fingerprint.fingerSearch()
    
    if(p):
        print ("Found fingerprint")
    elif(not p):
        print ("No fingerprint found")
        return p
    else:
        print ("Unknown Error")
        return p
def getFingerprintIDez():

    p = Fingerprint.getImage()
    if (not p):
        return 0

    p = Fingerprint.image2Tz(1)
    if (not p):
        return -1

    p = Fingerprint.fingerSearch()
    if (not p):
        return -1

    #print ("Found fingerprint")
    return (True)
def getFingerprintIDez():
    
    p = Fingerprint.getImage()
    if(not p):
        return 0
    
    p = Fingerprint.image2Tz(1)
    if(not p):
        return -1
    
    p = Fingerprint.fingerSearch()
    if(not p):
        return -1
    
    #print ("Found fingerprint")
    return (True)
def getFingerprintIDez():
    
    p = Fingerprint.getImage()
    if(not p):
        return 0
    
    p = Fingerprint.image2Tz(1)
    if(not p):
        return -1

    #No Match Finger Print
    p = Fingerprint.fingerSearch()
    if(not p):
        return 2
    
    #print ("Found fingerprint")
    return (1)
def imageUpload():
    #userInput = input("ID # to store the finger as:")
    while(True):
        userID = input("ID # to store the finger or Q to quit:")
        
        if(userID.isdigit()):
            break
        elif((userID == 'q') or (userID == 'Q')):
            userID = ''
            main()
        else:
            print ("Must enter digit only")
    
    print ("Enrolling ID #" + userID)
    
    print ("Waiting for valid finger to enroll")
    time.sleep(0.5)
    
    p = False
    while (not p):
        p = Fingerprint.getImage()
        if(p):
            print ("Image taken")
            break
        elif(not p):
            print (".")
        else:
            print ("Unknown Error")
    
    #time.sleep(0.5)
    p = Fingerprint.uploadImage(userID)
    
    if(p):
        print ("Image downloaded and saved")
        return p
    elif(not p):
        print ("Image not downloaded or saved")
        return p
    else:
        print ("Unknown Error")
        return p
def imageUpload():
    #userInput = input("ID # to store the finger as:")
    while (True):
        userID = input("ID # to store the finger or Q to quit:")

        if (userID.isdigit()):
            break
        elif ((userID == 'q') or (userID == 'Q')):
            userID = ''
            main()
        else:
            print("Must enter digit only")

    print("Enrolling ID #" + userID)

    print("Waiting for valid finger to enroll")
    time.sleep(0.5)

    p = False
    while (not p):
        p = Fingerprint.getImage()
        if (p):
            print("Image taken")
            break
        elif (not p):
            print(".")
        else:
            print("Unknown Error")

    #time.sleep(0.5)
    p = Fingerprint.uploadImage(userID)

    if (p):
        print("Image downloaded and saved")
        return p
    elif (not p):
        print("Image not downloaded or saved")
        return p
    else:
        print("Unknown Error")
        return p
예제 #8
0
def generateFingerprint(molecule, numInts=32, pathLength=7):
    """(molecule, numInts=32)->Fingerprint
    given a molecule and the number of integers to use to generate
    the fingerprint, return the fingerprint of the molecule)"""

    paths = LinearPaths.generatePaths(molecule, maxdepth=pathLength)
    fp = Fingerprint.Fingerprint(numIntegers=numInts)

    for path in paths:
        fp.addPath(path)

    return fp
예제 #9
0
    def add_scales(self):
        for scale in Scale.all():
            #if fingerprint exists, get current fingerprint to modify
            #print(scale.stamp)
            if self.fingerprint(scale.id):
                fingerprint = self.fingerprints[scale.id]
                fingerprint.add_scale(scale)

            #else create new fingerprint
            else:
                self.fingerprints[scale.id] = Fingerprint(scale.stamp)
                self.fingerprints[scale.id].add_scale(scale)
예제 #10
0
    def add_chords(self):
        for chord in Chord.all():

            #if fingerprint exists, get current fingerprint to modify
            if self.fingerprint(chord.id):
                fingerprint = self.fingerprints[chord.id]
                fingerprint.add_chord(chord)

            #else create new fingerprint
            else:
                self.fingerprints[chord.id] = Fingerprint(chord.stamp)
                self.fingerprints[chord.id].add_chord(chord)
def enrollFingerprint(enrollID):
    print ("Waiting for valid finger to enroll")
    time.sleep(0.5)
    
    p = False
    while (not p):
        p = Fingerprint.getImage()
        if(p):
            print ("Image taken")
            break
        elif(not p):
            print (".")
        else:
            print ("Unknown Error")
    
    time.sleep(0.5)
    p = Fingerprint.image2Tz(1)
    
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p
    
    print ("Remove Finger")
    time.sleep(2.0)
    
    p = False
    print ("Place same finger again")
    time.sleep(1.0)
    while(not p):
        p = Fingerprint.getImage()
        
        if(p):
            print ("Image taken")
            break
        elif(not p):
            print (".")
        else:
            print ("Unknown Error")

    time.sleep(0.5)
    p = Fingerprint.image2Tz(2)
    
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p

    #Converted
    time.sleep(0.5)
    p = Fingerprint.createModel()
    
    if(p):
        print ("Fingerprints match")
    elif(not p):
        print ("Fingerprints did not match")
        return p
    else:
        print ("Unknown Error")
        return p
    
    time.sleep(0.5)
    enrollIDbytes = int(enrollID, 16)
    p = Fingerprint.storeModel(enrollIDbytes, 1)
    
    if(p):
        print ("Stored fingerprint template")
        enrollIDLoop()
    elif(not p):
        print ("Store Fingerprint Error")
        return p
    else:
        print ("Unknown Error")
        return p
def main():
    lockOnTime = 1
    #set-up output pin
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    GPIO.setup(outputPin, GPIO.OUT, initial=GPIO.LOW)
    GPIO.setup(inputPinExit, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    
    #Set serial port and baudrate
    Fingerprint.begin()
    
    if(Fingerprint.checkFPComms()):
        print ("Found Fingerprint Sensor")
    else:
        print ("Did not find Fingerprint Sensor")
        main()
    while(True):
        print("1 - Enroll Fingerprints")
        print("2 - Run Fingerprint Sensor")
        print("3 - Save Notepad to File")
        print("4 - Load Notepad from File")
        print("5 - Erase Library")
        print("6 - Upload Fingerprint Image to Computer")
        print("7 - Download Fingerprint Image to Sensor")
        print("E - Exit")
        menuInput = input ("Please select option ")
        
        if((menuInput.isdigit()) and (menuInput == '1')):
            enrollIDLoop()
            break
        elif((menuInput.isdigit()) and (menuInput == '2')):
            lockOnTime = 8
            runLoop(lockOnTime)
            break
        elif((menuInput.isdigit()) and (menuInput == '3')):
            totalCount = Fingerprint.getTemplateCount()
            print ("Template count is " + str(totalCount))
            for i in range(1, totalCount + 1):
                if(Fingerprint.getNotepad(i) == True):
                    print("Success Writing ID File for " + str(i))
                else:
                    print("Error Writing ID File")
                    break
        elif((menuInput.isdigit()) and (menuInput == '4')):
            #run Fingerprint.writeNotepad(ID) until False (returns false when no ID found)
            writeID = 1
            while((Fingerprint.writeNotepad(writeID)) == True):
                writeID += 1
            print("Total ID's entered " + str(writeID - 1))
        elif((menuInput.isdigit()) and (menuInput == '5')):
            if(Fingerprint.emptyDatabase() == True):
                pass
            else:
                print("Error erasing library")
        elif((menuInput.isdigit()) and (menuInput == '6')):
            if(imageUpload() == True):
                pass
            else:
                print("Error uploading image and saving to file")
        elif((menuInput.isdigit()) and (menuInput == '7')):
            if(imageDownload() == True):
                pass
            else:
                print("Error opening file and downloading to sensor")
        elif((menuInput == 'E') or (menuInput == 'e')):
            menuInput = ''
            GPIO.cleanup()
            sys.exit()
        else:
            print ("Must select from the menu")
    
    GPIO.cleanup()    
    return 0
def imageDownload():
    #userInput = input("ID # to store the finger as:")
    while(True):
        userID = input("ID # to download the finger or Q to quit:")
        
        if(userID.isdigit()):
            break
        elif((userID == 'q') or (userID == 'Q')):
            userID = ''
            main()
        else:
            print ("Must enter digit only")
    
    print ("Downloading ID #" + userID)
    
    p = Fingerprint.downloadImage(userID)
    time.sleep(.05)
    
    if(p):
        print ("Image downloaded to sensor")
    elif(not p):
        print ("Image not downloaded to sensor")
        return p
    else:
        print ("Unknown Error")
        return p

    p = Fingerprint.image2Tz(1)
    time.sleep(.05)
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p

    p = Fingerprint.downloadImage(userID)
    time.sleep(.05)
    if(p):
        print ("Image downloaded to sensor")
    elif(not p):
        print ("Image not downloaded to sensor")
        return p
    else:
        print ("Unknown Error")
        return p

    p = Fingerprint.image2Tz(2)
    time.sleep(.05)
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p

    #Converted
    p = Fingerprint.createModel()
    if(p):
        print ("Fingerprints match")
    elif(not p):
        print ("Fingerprints did not match")
        return p
    else:
        print ("Unknown Error")
        return p
    
    enrollIDbytes = int(userID, 16)
    p = Fingerprint.storeModel(enrollIDbytes, 1)
    if(p):
        print ("Stored fingerprint template")
        return p
    elif(not p):
        print ("Store Fingerprint Error")
        return p
    else:
        print ("Unknown Error")
        return p
def imageDownload():
    #userInput = input("ID # to store the finger as:")
    while (True):
        userID = input("ID # to download the finger or Q to quit:")

        if (userID.isdigit()):
            break
        elif ((userID == 'q') or (userID == 'Q')):
            userID = ''
            main()
        else:
            print("Must enter digit only")

    print("Downloading ID #" + userID)

    p = Fingerprint.downloadImage(userID)
    time.sleep(.05)

    if (p):
        print("Image downloaded to sensor")
    elif (not p):
        print("Image not downloaded to sensor")
        return p
    else:
        print("Unknown Error")
        return p

    p = Fingerprint.image2Tz(1)
    time.sleep(.05)
    if (p):
        print("Image converted")
    elif (not p):
        print("Image not converted")
        return p
    else:
        print("Unknown Error")
        return p

    p = Fingerprint.downloadImage(userID)
    time.sleep(.05)
    if (p):
        print("Image downloaded to sensor")
    elif (not p):
        print("Image not downloaded to sensor")
        return p
    else:
        print("Unknown Error")
        return p

    p = Fingerprint.image2Tz(2)
    time.sleep(.05)
    if (p):
        print("Image converted")
    elif (not p):
        print("Image not converted")
        return p
    else:
        print("Unknown Error")
        return p

    #Converted
    p = Fingerprint.createModel()
    if (p):
        print("Fingerprints match")
    elif (not p):
        print("Fingerprints did not match")
        return p
    else:
        print("Unknown Error")
        return p

    enrollIDbytes = int(userID, 16)
    p = Fingerprint.storeModel(enrollIDbytes, 1)
    if (p):
        print("Stored fingerprint template")
        return p
    elif (not p):
        print("Store Fingerprint Error")
        return p
    else:
        print("Unknown Error")
        return p
def main():
    
    #Time wait after Finger Print confirmed
    lockOnTime = 1
    #set-up output pin
    '''GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    GPIO.setup(outputPin, GPIO.OUT, initial=GPIO.LOW)
    GPIO.setup(redpin, GPIO.OUT, initial = GPIO.HIGH)
    GPIO.setup(inputPinExit, GPIO.IN, pull_up_down=GPIO.PUD_UP)'''
    # They are moved in the front
    
    #Set serial port and baudrate
    Fingerprint.begin()
    
    if(Fingerprint.checkFPComms()):
        print ("Found Fingerprint Sensor")
    else:
        print ("Did not find Fingerprint Sensor")
        main()
    while(True):
        print("1 - Enroll Fingerprints")
        print("2 - Run Fingerprint Sensor")
        print("3 - Save Notepad to File")
        print("4 - Load Notepad from File")
        print("5 - Erase Library")

        print("E - Exit")
        menuInput = input ("Please select option ")
        
        if((menuInput.isdigit()) and (menuInput == '1')):
            enrollIDLoop()
            break
        elif((menuInput.isdigit()) and (menuInput == '2')):
            lockOnTime = 3
            runLoop(lockOnTime)
            break
        elif((menuInput.isdigit()) and (menuInput == '3')):
            totalCount = Fingerprint.getTemplateCount()
            print ("Template count is " + str(totalCount))
            for i in range(1, totalCount + 1):
                if(Fingerprint.getNotepad(i) == True):
                    print("Success Writing ID File for " + str(i))
                else:
                    print("Error Writing ID File")
                    break
        elif((menuInput.isdigit()) and (menuInput == '4')):
            #run Fingerprint.writeNotepad(ID) until False (returns false when no ID found)
            writeID = 1
            while((Fingerprint.writeNotepad(writeID)) == True):
                writeID += 1
            print("Total ID's entered " + str(writeID - 1))
        elif((menuInput.isdigit()) and (menuInput == '5')):
            if(Fingerprint.emptyDatabase() == True):
                pass
            else:
                print("Error erasing library")
        elif((menuInput.isdigit()) and (menuInput == '6')):
            if(imageUpload() == True):
                pass
            else:
                print("Error uploading image and saving to file")
        elif((menuInput.isdigit()) and (menuInput == '7')):
            if(imageDownload() == True):
                pass
            else:
                print("Error opening file and downloading to sensor")
        elif((menuInput == 'E') or (menuInput == 'e')):
            menuInput = ''
            GPIO.cleanup()
            sys.exit()
        else:
            print ("Must select from the menu")
    
    GPIO.cleanup()    
    return 0
def enrollFingerprint(enrollID):
    print ("Waiting for valid finger to enroll")
    time.sleep(0.5)
    
    p = False
    while (not p):
        p = Fingerprint.getImage()
        if(p):
            print ("Image taken")
            break
        elif(not p):
            print (".")
        else:
            print ("Unknown Error")
    
    time.sleep(0.5)
    p = Fingerprint.image2Tz(1)
    
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p
    
    print ("Remove Finger")
    time.sleep(2.0)
    
    p = False
    print ("Place same finger again")
    time.sleep(1.0)
    while(not p):
        p = Fingerprint.getImage()
        
        if(p):
            print ("Image taken")
            break
        elif(not p):
            print (".")
        else:
            print ("Unknown Error")

    time.sleep(0.5)
    p = Fingerprint.image2Tz(2)
    
    if(p):
        print ("Image converted")
    elif(not p):
        print ("Image not converted")
        return p
    else:
        print ("Unknown Error")
        return p

    #Converted
    time.sleep(0.5)
    p = Fingerprint.createModel()
    
    if(p):
        print ("Fingerprints match")
    elif(not p):
        print ("Fingerprints did not match")
        return p
    else:
        print ("Unknown Error")
        return p
    
    time.sleep(0.5)
    enrollIDbytes = int(enrollID, 16)
    p = Fingerprint.storeModel(enrollIDbytes, 1)
    
    if(p):
        print ("Stored fingerprint template")
        enrollIDLoop()
    elif(not p):
        print ("Store Fingerprint Error")
        return p
    else:
        print ("Unknown Error")
        return p
예제 #17
0
        tampil.progress_bar(i + 1,
                            len(listAlamat),
                            text='%s' % localhost.ambilversion())
        tampil.disp.image(tampil.image)
        tampil.disp.display()
        if connect(alamat):
            useAlamat.append(alamat)


if __name__ == "__main__":
    checkAlamat()
    if len(useAlamat) is 0:
        while True:
            tampil.teks(text1='TIDAK ADA',
                        text2='FINGERPRINT',
                        text3='YANG TERHUBUNG')
            time.sleep(1.2)
            tampil.teks(text1='HARAP HUBUNGKAN',
                        text2='RASPBERRY',
                        text3='KE FINGERPRINT')
            time.sleep(1.2)
            tampil.teks(text1='KEMUDIAN', text2='RESTART', text3='RASPBERRY')
            time.sleep(1.2)

    else:
        tampil.teks(text1='RASPBERRY MENGGUNAKAN',
                    text2='%s BUAH FINGERPRINT' % len(useAlamat))
        while True:
            for alamat in useAlamat:
                Fingerprint.main_Program(alamat)
예제 #18
0
# RunTests.py
# Run the Fingerprint program on the test cases.

import os
import csv
import Fingerprint

# Instantiate the Fingerprint class.
f = Fingerprint.Fingerprint()

# Loop over all the test cases in the test directory.
test_directory = '../tests'
for test_file in os.listdir(test_directory):
    if (test_file.endswith('.dat')):
        #print (test_file)

        # Evaluate the full path to the file.
        test_file_path = test_directory + '/' + test_file
        #print(test_file_path)

        # Open the test file
        with open(test_file_path, 'r') as tf:
            reader = csv.reader(tf)
            fp_data = list(reader)

            # Process the input and identify the grouping.
            #print(fp_data[0])
            #print(fp_data[1])

            # Get the expected result.
            exp_result = [int(x) for x in fp_data[1]]