biometry_hash_3.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. def fp_download():
  2. ## Reads image and download it
  3. ## Tries to initialize the sensor
  4. try:
  5. f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000)
  6. if ( f.verifyPassword() == False ):
  7. raise ValueError('The given fingerprint sensor password is wrong!')
  8. except Exception as e:
  9. print('The fingerprint sensor could not be initialized!')
  10. print('Exception message: ' + str(e))
  11. exit(1)
  12. ## Gets some sensor information
  13. print('Currently stored templates: ' + str(f.getTemplateCount()))
  14. ## Tries to read image and download it
  15. try:
  16. print('Waiting for finger...')
  17. ## Wait that finger is read
  18. while ( f.readImage() == False ):
  19. pass
  20. print('Downloading image (this take a while)...')
  21. imageDestination = tempfile.gettempdir() + '/fingerprint.bmp'
  22. f.downloadImage(imageDestination)
  23. print('The image was saved to "' + imageDestination + '".')
  24. except Exception as e:
  25. print('Operation failed!')
  26. print('Exception message: ' + str(e))
  27. exit(1)