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.

38 lines
1.5 KiB

  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. print("starting ffi test")
  15. #initialize the library
  16. lib.init()
  17. # Print the path and the bytes as hex for debugging
  18. #print(large_image_path)
  19. #print('\\x'+'\\x'.join('{:02x}'.format(x) for x in large_image_path))
  20. for image in test_images:
  21. print("Get hashes for {}", image)
  22. print("AHash: {}",lib.ext_get_ahash(image) & 0xffffffffffffffff)
  23. print("DHash: {}",lib.ext_get_dhash(image) & 0xffffffffffffffff)
  24. print("PHash: {}",lib.ext_get_phash(image) & 0xffffffffffffffff)
  25. # Do cleanup
  26. #lib.teardown()
  27. print("ffi test finished")