python调用本地exe,从python脚本调用exe

作者尝试通过Python读取clothes文件夹中的colorDescriptor.exe,并在处理文件路径和执行命令时遇到问题。最初代码报错提示找不到文件,修改路径后仍遇到类似错误,询问如何正确指定输入图像。文章探讨了路径设置、文件操作和命令执行的最佳实践。
摘要由CSDN通过智能技术生成

我试图从文件夹中读取文件并运行colorDescriptor.exe,它与.py文件在同一目录中。实际上我想要,每次它读一个文件来计算colorDescriptor。在

我的代码如下: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

从终端,要使用的语法颜色描述符.exe例如:

^{pr2}$

我收到的是一个错误: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: /文件

[0.1s内完成]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值