From 61f169d109c9ba1c01ada06d830973c873d4e634 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 14 Apr 2019 19:52:16 +0200 Subject: record format --- check/app/utils/im_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'check/app/utils/im_utils.py') diff --git a/check/app/utils/im_utils.py b/check/app/utils/im_utils.py index 3002632..eae7bc1 100644 --- a/check/app/utils/im_utils.py +++ b/check/app/utils/im_utils.py @@ -208,6 +208,16 @@ def compute_phash(im): """ return imagehash.phash(ensure_pil(im)) +def compute_phash_int(im): + """Compute perceptual hash using ImageHash library and convert to binary + :param im: Numpy.ndarray + :returns: ImageHash as binary + """ + phash = imagehash.phash(ensure_pil(im)) + phash.hash[-1] = False + phash_as_bigint = struct.unpack('Q', numpy.packbits(phash.hash))[0] + return phash_as_bigint + def compute_dhash(im): """Compute difference hash using ImageHash library :param im: Numpy.ndarray -- cgit v1.2.3-70-g09d2