2014-11-01 95 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