2014-11-01 89 views
0

我正在使用Vlfeat.org的Sift实现。它具有应该将特征保存到文件的下面的功能。在Vlfeat中筛选实现

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机器上,如果我在终端执行“筛选”命令,我得到的结果为“未找到”。在linux上,这个命令试图调用哪个进程?我需要将这些Sift特征保存到一个文件中,以便稍后我可以使用它来为群集创建Bag of Words描述符。

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

回答

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 download page(参见bin/glnxa64/sift用于Linux 64位),或直接克隆repo并从源代码进行编译。

确保使用cmmd = str("/path/to/sift " ...)调整路径,或者在/usr/local/bin这样的公共路径下安装(=复制它)。

+0

谢谢......!这工作。我添加了筛选路径到系统路径,以便我不必在代码中调整路径。然而,这是在终端工作,但Pydev没有采取这种路径变化,我不得不改变代码中的路径。 – Erdnase 2014-11-04 13:26:59