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.

42 lines
1.5 KiB

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