biometry_hash_2.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. def index():
  2. ## Shows the template index table
  3. ##
  4. ## Tries to initialize the sensor
  5. try:
  6. f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000)
  7. if ( f.verifyPassword() == False ):
  8. raise ValueError('The given fingerprint sensor password is wrong!')
  9. except Exception as e:
  10. print('The fingerprint sensor could not be initialized!')
  11. print('Exception message: ' + str(e))
  12. exit(1)
  13. ## Gets some sensor information
  14. print('Currently stored templates: ' + str(f.getTemplateCount()))
  15. ## Tries to show a template index table page
  16. try:
  17. page = raw_input('Please enter the index page (0, 1, 2, 3) you want to see: ')
  18. page = int(page)
  19. tableIndex = f.getTemplateIndex(page)
  20. for i in range(0, len(tableIndex)):
  21. print('Template at position #' + str(i) + ' is used: ' + str(tableIndex[i]))
  22. except Exception as e:
  23. print('Operation failed!')
  24. print('Exception message: ' + str(e))
  25. exit(1)