【发布时间】:2015-01-12 12:11:52
【问题描述】:
我正在尝试为 simpleCV 程序制作 GUI。我正在使用easyGUI来做到这一点。 这是我的代码:
from easygui import *
from SimpleCV import *
from cv2 import *
from cv import *
from PIL import *
import time
import sys
while True:
msgbox("""Welcome to my program!""", image = "pi.jpg")
msgbox("Select img ")
nam=fileopenbox(filetypes=['*'])
print nam
img=Image(nam)
img1=img.binarize()
time.sleep(1)
img1.save("result.png")
msgbox("This is the result", image = "result.png")
msg = "Do you want to continue?"
title = "Please Confirm"
if ccbox(msg, title): # show continue/cancle dialog
print "okk" # user chose continue
else:
sys.exit(0) # user chose cancle
但我遇到了奇怪的错误.. 它说:
Traceback (most recent call last):
File "C:\Python27\tryyyy", line 13, in <module>
img=Image(nam)
TypeError: 'module' object is not callable
我尝试了打印目录(图像),我得到了:
['ADAPTIVE', 'AFFINE', 'ANTIALIAS', 'BICUBIC', 'BILINEAR', 'CONTAINER', 'CUBIC', 'DEBUG', 'EXTENSION', 'EXTENT', 'FLIP_LEFT_RIGHT', 'FLIP_TOP_BOTTOM ','FLOYDSTEINBERG','ID','Image','ImageMode','ImagePalette','ImagePointHandler','ImageTransformHandler','IntType','LINEAR','MESH','MIME','MODES', “最近”、“无”、“正常”、“打开”、“有序”、“透视”、“四边形”、“光栅化”、“ROTATE_180”、“ROTATE_270”、“ROTATE_90”、“保存”、“序列” '、'StringType'、'TupleType'、'UnicodeStringType'、'VERSION'、'WEB'、'_E'、'_ENDIAN'、'_ImageCrop'、'_MAPMODES'、'_MODEINFO'、'_MODE_CONV'、' builtins', 'doc', 'file', 'name', 'package' ,'_conv_type_shape','_fromarray_typemap','_getdecoder','_getencoder','_getscaleoffset','_imaging_not_installed','_initialized','_show','_showxv','_wedge','blend','byteorder','复合','核心','eval','fromarray','frombuffer','fromstring','getmodebandnames','get modebands','getmodebase','getmodetype','init','isDirectory','isImageType','isNumberType','isSequenceType','isStringType','isTupleType','merge','new','open' , 'os', 'preinit', 'register_extension', 'register_mime', 'register_open', 'register_save', 'string', 'sys', 'warnings']
我导入了 SimpleCV;请你帮我解释一下为什么会出现这个错误? 提前谢谢你。
【问题讨论】:
-
回溯信息很清楚:Image是模块,也就是说Image是你导入的模块的子模块。尝试 print dir(Image) 找到有用的东西。
标签: python-2.7 simplecv easygui