PyFingerprint¶
Python 2 and 3 library for ZFM fingerprint sensors.
API Documentation¶
PyFingerprint Copyright (C) 2015 Bastian Raschke <bastian.raschke@posteo.de> All rights reserved.
-
pyfingerprint.pyfingerprint.
FINGERPRINT_CHARBUFFER1
= 1¶ Char buffer 1
-
pyfingerprint.pyfingerprint.
FINGERPRINT_CHARBUFFER2
= 2¶ Char buffer 2
-
class
pyfingerprint.pyfingerprint.
PyFingerprint
(port='/dev/ttyUSB0', baudRate=57600, address=4294967295, password=0)¶ Manages ZhianTec fingerprint sensors.
Constructor
Parameters: - port (str) – The port to use
- baudRate (int) – The baud rate to use. Must be a multiple of 9600!
- address (int) – The sensor address
- password (int) – The sensor password
Raises: ValueError
– if baud rate, address or password are invalid-
clearDatabase
()¶ Deletes all templates from the fingeprint database.
Returns: True if successful or False otherwise. Raises: Exception
– if any error occurs
-
compareCharacteristics
()¶ Compare the finger characteristics of char buffer 1 with char buffer 2 and returns the accuracy score.
Returns: The accuracy score (int). 0 means fingers are not the same. Raises: Exception
– if any error occurs
-
convertImage
(charBufferNumber=1)¶ Converts the image in image buffer to characteristics and stores it in specified char buffer.
Parameters: charBufferNumber (int) – The char buffer. Use FINGERPRINT_CHARBUFFER1 or FINGERPRINT_CHARBUFFER2.
Returns: True if successful or False otherwise.
Raises: ValueError
– if passed char buffer is invalidException
– if any error occurs
-
createTemplate
()¶ Combines the characteristics which are stored in char buffer 1 and char buffer 2 into one template. The created template will be stored again in char buffer 1 and char buffer 2 as the same.
Returns: True if successful or False otherwise. Raises: Exception
– if any error occurs
-
deleteTemplate
(positionNumber, count=1)¶ Deletes templates from fingerprint database. Per default one.
Parameters: - positionNumber (int) – The position
- count (int) – The number of templates to be deleted.
Returns: True if successful or False otherwise.
Raises: ValueError
– if passed position or count is invalidException
– if any error occurs
-
downloadCharacteristics
(charBufferNumber=1)¶ Downloads the finger characteristics from the specified char buffer.
Parameters: - charBufferNumber (int) – The char buffer. Use FINGERPRINT_CHARBUFFER1 or FINGERPRINT_CHARBUFFER2.
- characteristicsData (list) – The characteristics
Returns: The characteristics (list).
Raises: ValueError
– if passed char buffer is invalidException
– if any error occurs
-
downloadImage
(imageDestination)¶ Downloads the image from image buffer.
Parameters: imageDestination (str) – Path to image
Raises: ValueError
– if directory is not writableException
– if any error occurs
-
generateRandomNumber
()¶ Generates a random 32-bit decimal number.
- Author:
- Philipp Meisberger <team@pm-codeworks.de>
Returns: The generated random number (int). Raises: Exception
– if any error occurs
-
getBaudRate
()¶ Gets the baud rate.
Returns: The baud rate (int). Raises: Exception
– if any error occurs
-
getMaxPacketSize
()¶ Gets the maximum allowed size of a single packet.
Returns: Return the max size (int).
Raises: ValueError
– if packet size is invalidException
– if any error occurs
-
getSecurityLevel
()¶ Gets the security level of the sensor.
Returns: The security level (int). Raises: Exception
– if any error occurs
-
getStorageCapacity
()¶ Gets the sensor storage capacity.
Returns: The storage capacity (int). Raises: Exception
– if any error occurs
-
getSystemParameters
()¶ Gets all available system information of the sensor.
Returns: 0: integer(2 bytes) The status register. 1: integer(2 bytes) The system id. 2: integer(2 bytes) The storage capacity. 3: integer(2 bytes) The security level. 4: integer(4 bytes) The sensor address. 5: integer(2 bytes) The packet length. 6: integer(2 bytes) The baud rate. Return type: A tuple that contains the following information Raises: Exception
– if any error occurs
-
getTemplateCount
()¶ Gets the number of stored templates.
Returns: The template count (int). Raises: Exception
– if any error occurs
-
getTemplateIndex
(page)¶ Gets a list of the template positions with usage indicator.
Parameters: page (int) – The page (value between 0 and 3).
Returns: The list.
Raises: ValueError
– if passed page is invalidException
– if any error occurs
-
loadTemplate
(positionNumber, charBufferNumber=1)¶ Loads an existing template specified by position number to specified char buffer.
Parameters: - positionNumber (int) – The position
- charBufferNumber (int) – The char buffer. Use FINGERPRINT_CHARBUFFER1 or FINGERPRINT_CHARBUFFER2.
Returns: True if successful or False otherwise.
Raises: ValueError
– if passed position or char buffer is invalidException
– if any error occurs
-
readImage
()¶ Reads the image of a finger and stores it in image buffer.
Returns: True if image was read successfully or False otherwise. Raises: Exception
– if any error occurs
-
searchTemplate
(charBufferNumber=1, positionStart=0, count=-1)¶ Searches inside the database for the characteristics in char buffer.
Parameters: - charBufferNumber (int) – The char buffer. Use FINGERPRINT_CHARBUFFER1 or FINGERPRINT_CHARBUFFER2.
- positionStart (int) – The position to start the search
- count (int) – The number of templates
Returns: 0: integer(2 bytes) The position number of found template. 1: integer(2 bytes) The accuracy score of found template.
Return type: A tuple that contain the following information
Raises: Exception
– if any error occurs
-
setAddress
(newAddress)¶ Sets the sensor address.
Parameters: newAddress (int) – The new address to use. Returns: True if address was set correctly or False otherwise. Raises: Exception
– if any error occurs
-
setBaudRate
(baudRate)¶ Sets the baud rate.
Parameters: baudRate (int) – The baud rate
Raises: ValueError
– if passed baud rate is no multiple of 9600Exception
– if any error occurs
-
setMaxPacketSize
(packetSize)¶ Sets the maximum packet size of sensor.
Parameters: packetSize (int) – 32, 64, 128 and 256 are supported.
Raises: ValueError
– if passed packet size is invalidException
– if any error occurs
-
setPassword
(newPassword)¶ Sets the password of the sensor.
Parameters: newPassword (int) – The new password to use. Returns: True if password was set correctly or False otherwise. Raises: Exception
– if an error occured
-
setSecurityLevel
(securityLevel)¶ Sets the security level of the sensor.
Parameters: securityLevel (int) – Value between 1 and 5 where 1 is lowest and 5 highest. Raises: Exception
– if any error occurs
-
setSystemParameter
(parameterNumber, parameterValue)¶ Set a system parameter of the sensor.
Parameters: - parameterNumber (int) – The parameter number. Use one of FINGERPRINT_SETSYSTEMPARAMETER_* constants.
- parameterValue (int) – The value
Returns: True if successful or False otherwise.
Raises: ValueError
– if any passed parameter is invalidException
– if any error occurs
-
storeTemplate
(positionNumber=-1, charBufferNumber=1)¶ Stores a template from the specified char buffer at the given position.
Parameters: - positionNumber (int) – The position
- charBufferNumber (int) – The char buffer. Use FINGERPRINT_CHARBUFFER1 or FINGERPRINT_CHARBUFFER2.
Returns: The position number (int) of the stored template.
Raises: ValueError
– if passed position or char buffer is invalidException
– if any error occurs
-
uploadCharacteristics
(charBufferNumber=1, characteristicsData=[0])¶ Uploads finger characteristics to specified char buffer.
- Author:
- David Gilson <davgilson@live.fr>
Parameters: - charBufferNumber (int) – The char buffer. Use FINGERPRINT_CHARBUFFER1 or FINGERPRINT_CHARBUFFER2.
- characteristicsData (list) – The characteristics
Returns: True if everything is right.
Raises: ValueError
– if passed char buffer or characteristics are invalidException
– if any error occurs
-
verifyPassword
()¶ Verifies password of the sensor.
Returns: True if password is correct or False otherwise. Raises: Exception
– if an error occured