diff --git a/ChangeLog b/ChangeLog index 8f809eb..bea150f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ --- GitHub release +0.9.8 +--- +Extend pHash interface with ph_mh_imagehash_from_buffer + 0.9.7 --- JNI code cleanup diff --git a/libpHash.spec b/libpHash.spec index dc869e6..f8639db 100644 --- a/libpHash.spec +++ b/libpHash.spec @@ -1,5 +1,5 @@ Name: pHash -Version: 0.9.7 +Version: 0.9.8 Release: 1%{?dist} Summary: pHash, the open source perceptual hashing library diff --git a/src/pHash.cpp b/src/pHash.cpp old mode 100755 new mode 100644 index 7df0a6e..0a9c92b --- a/src/pHash.cpp +++ b/src/pHash.cpp @@ -615,8 +615,6 @@ uint8_t *ph_mh_imagehash(const char *filename, int &N, float alpha, float lvl) { if (filename == NULL) { return NULL; } - uint8_t *hash = (unsigned char *)malloc(72 * sizeof(uint8_t)); - N = 72; CImg src(filename); CImg img; @@ -635,6 +633,14 @@ uint8_t *ph_mh_imagehash(const char *filename, int &N, float alpha, float lvl) { } src.clear(); + return ph_mh_imagehash_from_buffer(img, N, alpha, lvl); +} + +uint8_t *ph_mh_imagehash_from_buffer(CImg &img, int &N, float alpha, + float lvl) { + uint8_t *hash = (unsigned char *)malloc(72 * sizeof(uint8_t)); + N = 72; + CImg *pkernel = GetMHKernel(alpha, lvl); CImg fresp = img.get_correlate(*pkernel); img.clear(); diff --git a/src/pHash.h.cmake b/src/pHash.h.cmake index 8ab414a..a45d76e 100644 --- a/src/pHash.h.cmake +++ b/src/pHash.h.cmake @@ -254,6 +254,15 @@ int ph_hamming_distance(const ulong64 hash1,const ulong64 hash2); **/ uint8_t* ph_mh_imagehash(const char *filename, int &N, float alpha=2.0f, float lvl = 1.0f); +/** /brief create MH image hash from image buffer +* /param img - image buffer +* /param N - (out) int value for length of image hash returned +* /param alpha - int scale factor for marr wavelet (default=2) +* /param lvl - int level of scale factor (default = 1) +* /return uint8_t array +**/ +uint8_t* ph_mh_imagehash_from_buffer(CImg &img, int &N, float alpha=2.0f, float lvl = 1.0f); + /** /brief count number bits set in given byte * /param val - uint8_t byte value * /return int value for number of bits set