You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB

9 years ago
9 years ago
  1. #!/usr/bin/env python3
  2. from ctypes import *
  3. large_image1_path = "test_images/sample_01_large.jpg".encode(encoding="utf-8")
  4. medium_image1_path = "test_images/sample_01_medium.jpg".encode(encoding="utf-8")
  5. small_image1_path = "test_images/sample_01_small.jpg".encode(encoding="utf-8")
  6. large_image2_path = "test_images/sample_02_large.jpg".encode(encoding="utf-8")
  7. medium_image2_path = "test_images/sample_02_medium.jpg".encode(encoding="utf-8")
  8. small_image2_path = "test_images/sample_02_small.jpg".encode(encoding="utf-8")
  9. large_image3_path = "test_images/sample_03_large.jpg".encode(encoding="utf-8")
  10. medium_image3_path = "test_images/sample_03_medium.jpg".encode(encoding="utf-8")
  11. small_image3_path = "test_images/sample_03_small.jpg".encode(encoding="utf-8")
  12. test_images=[large_image1_path, medium_image1_path, small_image1_path,large_image2_path, medium_image2_path, small_image2_path,large_image3_path, medium_image3_path, small_image3_path]
  13. def unsigned64(number):
  14. #return c_ulonglong(number).value
  15. return c_ulonglong(number).value
  16. print("starting ffi test")
  17. # Load the shared library
  18. lib = cdll.LoadLibrary("libpihash.so")
  19. #initialize the library
  20. lib.init()
  21. # Print the path and the bytes as hex for debugging
  22. #print(large_image_path)
  23. #print('\\x'+'\\x'.join('{:02x}'.format(x) for x in large_image_path))
  24. for image in test_images:
  25. print("Requesting hashes for: %s"% image)
  26. print("ahash: %i"% lib.ext_get_ahash(image))
  27. print("dhash: %i"% lib.ext_get_dhash(image))
  28. print("phash: %i"% lib.ext_get_phash(image))
  29. # Do cleanup
  30. #lib.teardown()
  31. print("ffi test finished")