0

我正在使用 Vlfeat.org 的 Sift 实现。它具有以下功能,可以将特征保存到文件中。

def process_image(imagename,resultname,params="--edge-thresh 10 --peak-thresh 5"):
""" process an image and save the results in a file"""

if imagename[-3:] != 'pgm':
    #create a pgm file
    im = Image.open(imagename).convert('L')
    im.save('tmp.pgm')
    imagename = 'tmp.pgm'

cmmd = str("sift "+imagename+" --output="+resultname+
            " "+params)
os.system(cmmd)
print 'processed', imagename, 'to', resultname

在这里,“os.system(cmmd)”行应该如何将结果写入文件?

我在 ubuntu 机器上,如果我在终端中执行“sift”作为命令,我得到的结果是“未找到”。在 linux 上,这个命令试图调用哪个进程?我需要将这些 Sift 特征保存到一个文件中,以便稍后我可以使用它来创建用于聚类的 Bag of Words 描述符。

https://github.com/jesolem/PCV/blob/master/PCV/localdescriptors/sift.py上的类似 sift 实现也使用同一行将结果保存到文件中。

4

1 回答 1

0

在 linux 上,这个命令试图调用哪个进程?

这指的是vlfeat提供的命令行工具(参见vlfeat/src/sift.c):

$ ./sift
Usage: ./sift [options] files ...

Options include:
 --verbose -v    Be verbose
 --help -h       Print this help message
 --output -o     Specify output file
...

您可以使用来自vlfeat 下载页面的二进制分发(参见bin/glnxa64/siftLinux 64 位),或者直接克隆repo并从源代码编译它。

确保cmmd = str("/path/to/sift " ...)使用通用路径(如/usr/local/bin.

于 2014-11-02T10:31:21.833 回答