|
@ -17,7 +17,6 @@ small_image3_path = "test_images/sample_03_small.jpg".encode(encoding="utf-8") |
|
|
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] |
|
|
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] |
|
|
|
|
|
|
|
|
def unsigned64(number): |
|
|
def unsigned64(number): |
|
|
#return c_ulonglong(number).value |
|
|
|
|
|
return c_ulonglong(number).value |
|
|
return c_ulonglong(number).value |
|
|
|
|
|
|
|
|
print("starting ffi test") |
|
|
print("starting ffi test") |
|
@ -25,6 +24,11 @@ print("starting ffi test") |
|
|
# Load the shared library |
|
|
# Load the shared library |
|
|
lib = cdll.LoadLibrary("libpihash.so") |
|
|
lib = cdll.LoadLibrary("libpihash.so") |
|
|
|
|
|
|
|
|
|
|
|
# Setting the ctypes return type references for the foreign functions |
|
|
|
|
|
lib.ext_get_ahash.restype = c_ulonglong |
|
|
|
|
|
lib.ext_get_dhash.restype = c_ulonglong |
|
|
|
|
|
lib.ext_get_phash.restype = c_ulonglong |
|
|
|
|
|
|
|
|
#initialize the library |
|
|
#initialize the library |
|
|
lib.init() |
|
|
lib.init() |
|
|
|
|
|
|
|
@ -34,9 +38,9 @@ lib.init() |
|
|
|
|
|
|
|
|
for image in test_images: |
|
|
for image in test_images: |
|
|
print("Requesting hashes for: %s"% image) |
|
|
print("Requesting hashes for: %s"% image) |
|
|
print("ahash: %i"% lib.ext_get_ahash(image)) |
|
|
|
|
|
print("dhash: %i"% lib.ext_get_dhash(image)) |
|
|
|
|
|
print("phash: %i"% lib.ext_get_phash(image)) |
|
|
|
|
|
|
|
|
print("ahash: %i"% unsigned64(lib.ext_get_ahash(image))) |
|
|
|
|
|
print("dhash: %i"% unsigned64(lib.ext_get_dhash(image))) |
|
|
|
|
|
print("phash: %i"% unsigned64(lib.ext_get_phash(image))) |
|
|
|
|
|
|
|
|
# Do cleanup |
|
|
# Do cleanup |
|
|
#lib.teardown() |
|
|
#lib.teardown() |
|
|