예제 #1
0
def authenticate_from_disk():
    """
    Authenticate single user from data stored in his home directory
    :return: Boolean
    """

    # Initialize things
    pyfprint.fp_init()
    devs = pyfprint.discover_devices()
    dev = devs[0]
    dev.open()
    fprint = dev.load_print_from_disk(pyfprint.Fingers['RIGHT_INDEX'])

    print("Verifying...\nSwipe your finger across the sensor to proceed")
    verified, img = dev.verify_finger(fprint)

    if verified:
        print("Authenticated!")
    else:
        print("Authentication failed")
    if img is not None:
        img.save_to_file('verify.pgm')
        print("Wrote scanned image to verify.pgm")

    # Closing formalities
    dev.close()
    pyfprint.fp_exit()
예제 #2
0
def capture():
    """
    Takes care of enrolment of individual fingerprints. The right index finger is used here.
    The biometrics data is stored in the database along with the username of the person
    """

    print("To proceed with your fingerprint enrolment\n")
    username = input(
        "Please enter your username: "******"Enrolling...\n\n")
    print("Please swipe your RIGHT INDEX finger on the sensor 5 times")
    fprint, img = dev.enroll_finger(
    )  # Fingerprint data is retried along with the image which can be used to update a GUI

    fprint.save_to_disk(pyfprint.Fingers['RIGHT_INDEX'])
    if img is not None:
        img.save_to_file('enrolled.pgm')
        print("Wrote scanned image to enrolled.pgm")

    # Connect database
    fdb = sqlite3.connect(DB_FILE)

    # Work on the database object
    with fdb:
        cur = fdb.cursor(
        )  # The cursor is used by python to address a table in the database
        cur.execute(
            "CREATE TABLE IF NOT EXISTS biometric (username, finger_p BLOB)")
        if fprint is not None:
            b_fp = fprint.data().encode(
                'utf8', 'surrogateescape'
            )  # Convert to binary data for onward storage in db
            cur.execute(
                "INSERT INTO biometric(username, finger_p) VALUES(?, ?)", (
                    username,
                    sqlite3.Binary(b_fp),
                ))
            print("Fingerprint Successfully enrolled! Thank you!")
        else:
            print("finger print not properly captured!")

    # Closing formalities
    dev.close()
    pyfprint.fp_exit()
예제 #3
0
def capture_to_disk():
    """
    Enrolls a single user and saves his data in his home directory
    :return: None
    """
    # Intialize things
    pyfprint.fp_init()
    devs = pyfprint.discover_devices()
    dev = devs[0]  # Select the first device found
    dev.open()
    print("Enrolling...\n")
    print("Please swipe your RIGHT INDEX finger 5 times on the sensor\n")
    fprint, img = dev.enroll_finger()
    if fprint is not None:
        fprint.save_to_disk(pyfprint.Fingers['RIGHT_INDEX'])
        print("Successfully enrolled!")
    if img is not None:
        img.save_to_file('enrolled.pgm')
        print("Wrote scanned image to enrolled.pgm")
    dev.close()
    pyfprint.fp_exit()
 def destroy(self, widget, data=None):
     try:
         if self.dev != None:            
             self.dev.close()
         pyfprint.fp_exit()
         self.__user_section.close()    
     except:
         pass
     try:
         self.__attendance_section.close()
     except:
         pass
     try:
         self.__cursor.close()
         self.__db.close()
     except:
         pass
     try:
         os.remove(TMP_USER_IMAGE_FILE_NAME)    
     except:
         pass
     gtk.main_quit()
예제 #5
0
 def destroy(self, widget, data=None):
     try:
         if self.dev != None:
             self.dev.close()
         pyfprint.fp_exit()
         self.__user_section.close()
     except:
         pass
     try:
         self.__attendance_section.close()
     except:
         pass
     try:
         self.__cursor.close()
         self.__db.close()
     except:
         pass
     try:
         os.remove(TMP_USER_IMAGE_FILE_NAME)
     except:
         pass
     gtk.main_quit()
예제 #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
import pyfprint

pyfprint.fp_init()
devs = pyfprint.discover_devices()
dev = devs[0]
dev.open()
if dev.supports_imaging():
    img = dev.capture_image(True)
    img.save_to_file('finger.pgm')
    img.standardize()
    img.save_to_file('finger_standardized.pgm')
else:
    print("this device does not have imaging capabilities.")
dev.close()

pyfprint.fp_exit()
예제 #7
0
def authenticate():
    pyfprint.fp_init()  # Initialize the fingerprint library
    devs = pyfprint.discover_devices()
    dev = devs[0]  # Select the first device detected
    dev.open()

    # Connect to the database database
    fdb = sqlite3.connect(DB_FILE)
    users = []
    gallery = []

    print(
        "To gain access, we have to verify you are authorized using the biometric system\n"
    )

    with fdb:
        cur = fdb.cursor()

        # Check that the table is already created. if not, it means no enrolment has been made so far
        # The function will return immediately
        cur.execute(
            "SELECT name FROM sqlite_master WHERE type='table' AND name='biometric'"
        )
        if not cur.fetchone():
            print("No data in database yet. Please enroll first")
            return

        # Query the database for all entries, storing them in a vector list (users and gallery)
        cur.execute("SELECT username, finger_p FROM biometric")
        for row in cur.fetchall():
            fp_str = row[1].decode(
                'utf8', 'surrogateescape')  # Decode binary data from db
            data = pyfprint.pyf.fp_print_data_from_data(fp_str)
            gallery.append(pyfprint.Fprint(data_ptr=data))
            users.append(row[0])

        # After querying the database, proceed to ask for users finger swipe
        print(
            "To proceed, please swipe your RIGHT INDEX finger on the sensor...\n"
        )

        # Verification is done here
        # Checks to see if the users fingerprint match any of those retrieved from database
        n, fprint, img = dev.identify_finger(gallery)
        print("Authenticating...")

    if fprint:
        print("Authenticated! {0}".format(users[n]))  # User is authenticated
        result = True
    else:
        print("Authentication Failed")  # User not authenticated
        result = False

    # verified, img = dev.verify_finger(fprint)
    # if verified:
    #     print("Welcome, {0}".format(username))
    # else:
    #     print("Sorry! You are not allowed here!")

    # if img is not None:
    dev.close()
    pyfprint.fp_exit()
    return result
예제 #8
0
 def _exitFprint(self):
     """Exit the fprint class."""
     self._closeDevice()
     pyfprint.fp_exit()
	def exit_pyfprint(self, x = None):
		try:
			self.dev.close()
		except(AttributeError):
			pass
		pyfprint.fp_exit()
 def exit_pyfprint(self, x=None):
     try:
         self.dev.close()
     except (AttributeError):
         pass
     pyfprint.fp_exit()
예제 #11
0
 def _exitFprint(self):
     """Exit the fprint class."""
     self._closeDevice()
     pyfprint.fp_exit()