我正在使用 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 实现也使用同一行将结果保存到文件中。