pHash (image-hash) in objective-c doesn't work
i used brew to create a compiled library from phash i have imported the CImg.h file and everything compiles but it doesn't work.
i want to make a hash from an image but i always get the same output
NSB开发者_开发百科undle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForImageResource:@"branch.png"];
const char *image = [path cStringUsingEncoding:NSASCIIStringEncoding];
ulong64 hash = 0;
int valid = ph_dct_imagehash(image,hash);
NSLog(@"%i",valid);
NSLog(@"%llu",hash);
With this output
sh: convert: command not found
sh: gm: command not found
sh: convert: command not found
sh: gm: command not found
sh: convert: command not found
sh: gm: command not found
2011-10-03 20:10:22.571 pHashi386[2155:60b] -1
2011-10-03 20:10:22.572 pHashi386[2155:60b] 0
cleary something goes wrong but i don't have a clue what the sh commands not found are and neither if i'm on the right track.
It seems i had to add a enviroment variable PATH
i used /usr/local/bin:/usr/local/sbin:/usr/bin:/opt/local/bin:/usr/local/mysql/bin:/opt/local/sbin:/bin:/usr/sbin:/sbin:/usr/X11/bin
as my value
i'm not quite sure if it would work on the iOS platform though.
You also can tell CImg where to find ImageMagic convert, example:
cimg::imagemagick_path("/opt/local/bin/convert");
精彩评论