【问题标题】:pHash (image-hash) in objective-c doesn't work目标c中的pHash(图像哈希)不起作用
【发布时间】:2011-11-30 03:20:06
【问题描述】:

我使用 brew 从 phash 创建一个编译库 我已经导入了 CImg.h 文件,一切都编译了,但它不起作用。

我想从图像中生成哈希,但我总是得到相同的输出

NSBundle *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); 

有了这个输出

 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

很明显出了点问题,但我不知道找不到的 sh 命令是什么,如果我在正确的轨道上也不知道。

【问题讨论】:

  • 你知道它要运行什么脚本吗?转换可能是 ImageMagick 中的转换。
  • 是的,它来自 ImageMagick,GM 是 graphicsmagick,我都用 brew 安装了它们。如果我执行“sh”和终端,然后输入转换它可以工作.. 但是如果我在 xcode 中编译我的项目,它会一直唠叨找不到命令.. CImg.h 使用 convert 和 gm 命令

标签: objective-c macos phash


【解决方案1】:

你也可以告诉 CImg 在哪里可以找到 ImageMagic 转换,例如:

cimg::imagemagick_path("/opt/local/bin/convert");

【讨论】:

    【解决方案2】:

    看来我必须添加一个环境变量 PATH

    我使用 /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

    作为我的价值

    我不太确定它是否可以在 iOS 平台上运行。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    • 2012-04-29
    • 2016-05-31
    相关资源
    最近更新 更多