我試圖從文件夾中讀取文件並運行與.py
文件位於同一目錄中的colorDescriptor.exe
。其實我想,每次它讀取一個文件來計算colorDescriptor。從python腳本中調用exe
我的代碼是下面的:
import os
from os import listdir
from os.path import isfile, join
mypath1 = "/clothes/"
mypath2 = "/i386-win-vc/"
onlyfiles = [ f for f in listdir(mypath1) if isfile(join(mypath1,f)) ]
image = mypath1+f
os.popen("colorDescriptor image --detector harrislaplace --descriptor sift --output
onlyfiles.txt ")
print image
從終端,使用colorDescriptor.exe語法是例如:
colorDescriptor image.jpg --detector harrislaplace --descriptor sift --output onlyfiles.txt
我收到作爲一個錯誤:
Tue04 10:53:30,248 - [Impala.Persistency.FileSystem ] Unable to find image in path
Tue04 10:53:30,248 - [Impala.Core.Array.ReadFile ] Don't know how to read
Tue04 10:53:30,248 - [Sandbox.koen.mainColorDescriptor ] [ERROR] Could not read input
file: is it really a valid image? image
修改後的建議代碼:
import os
from os import listdir
from os.path import isfile, join
mypath1 = "C:/Documents and Settings/Desktop/clothes/"
mypath2 = "C:/Documents and Settings/My
Documents/colordescriptors40/i386-win-vc/"
onlyfiles = [ f for f in listdir(mypath1) if isfile(join(mypath1,f)) ]
image = mypath1+f
print image
pattern = "colorDescriptor %s --detector harrislaplace --descriptor sift --output
onlyfiles.txt"
os.system(pattern % image)
我現在下面的接收:
Tue04 11:06:45,091 ERROR [Impala.Persistency.FileSystem ] Unable to find C:/Documents
in
path
Tue04 11:06:45,091 INFO [Impala.Persistency.FileSystem ]
Tue04 11:06:45,091 ERROR [Impala.Core.Array.ReadFile ] Don't know how to read
Tue04 11:06:45,091 ERROR [Sandbox.koen.mainColorDescriptor ] [ERROR] Could not read input
文件:是不是真的有效的圖像? C:/ Documents [在0.1s內完成]
你有任何錯誤? – Nilesh
不,只有文件包含文件夾中的所有文件。從終端colorDescriptor的作品就像這裏:http://koen.me/research/colordescriptors/readme –
請你詳細說明你期望的輸出? – Nilesh