c++ - Perceptual hashing using Insight library -
for project working on make use of insight perceptual hash library. after reading interesting blog post (http://bertolami.com/index.php?engine=blog&content=posts&detail=perceptual-hashing) have tried make work myself, have little experience working image files in c++.
the code have far:
#include "stdafx.h" #include "vninsight.h" #include <string> #include <iostream> int _tmain(int argc, _tchar* argv[]) { cvimage ** a, ** b; // declare image objects uint32 statusa = vncreateimage(vn_image_format_r8g8b8, 960, 960, a); // not initialise a? uint32 statusb = vncreateimage(vn_image_format_r8g8b8, 960, 960, b); uint8 * addressa = (*a)->querydata(); // documentation says have retrieve address function vncompareimages(** a, ** b); // 'a not initialised error' return 0; } the mess above conjured following documentation library, small enough can copy/paste here:
the primary interface insight compareimages function:
float32 vncompareimages( const cvimage & pa, const cvimage & pb ); function return value in interval of [0,1] indicates percentage of similarity between 2 input images.
cvimage objects simple wrappers around formatted memory buffer. create new image, call vncreateimage(), passing in dimensions , desired image format (currently vn_image_format_r8g8b8 supported insight).
once call completes, image object allocated , ready filled image data. can supply data copying address indicated cvimage::querydata(). don't forget call vndestroyimage() when you've finished image object.
my question is; how can simple image similarity check? moreover, cvimage object exactly? ("simple wrappers around formatted memory buffer" not entirely clear me)
i've used insight university project , had pretty decent results. code close, needs fixed in few areas:
cvimage *a, *b; // declare image object pointers vncreateimage(vn_image_format_r8g8b8, 960, 960, &a); // allocate space image vncreateimage(vn_image_format_r8g8b8, 960, 960, &b); // allocate space image b at point, , b each point allocated uninitialized images.
next need populate , b valid image data (otherwise comparing 2 black images). in project loaded data bitmap files , copied images.
once you've filled out images, call vncompareimages result.
float32 fpercentagematch = vncompareimages(*a, *b); don't forget deallocate images once you're finished them:
vndestroyimage(a); vndestroyimage(b);
Comments
Post a Comment