SimpleCV NameError: name 'images' is not defined

烂漫一生 提交于 2019-12-25 06:25:38

问题


I try Library SimpleCV. I have Ubuntu 11.10, Python 2.7 with PIL (python-imaging ver. 1.1.7-3ubuntu1)

According to Install instructions I downloaded SimpleCV_1.1_linux_all.deb package. Then I install: sudo apt-get install python-numpy python-scipy.

Since Ubuntu 11.10 has python-opencv library I don't install any other opencv library (I dont upgrade from OpenCV 2.1 to OpenCV 2.3) library. Then I installed SimpleCV_1.1_linux_all.deb package. It installed to /usr/lib/pymodules/python2.7/SimpleCV. I try test this library and have problem:

#!/usr/bin/python

from SimpleCV import *

my_image = Image(images/redeye.jpg)<br>
my_image.show()

it shows error:

Traceback (most recent call last):
File "./simplecvimg.py", line 6, in
my_image = Image(images/redeye.jpg)
NameError: name 'images' is not defined


回答1:


Pass images/redeye.jpg as a string: Image("images/redeye.jpg").

my_image = Image("images/redeye.jpg")

You are currently passing that literally to the Image() class, hence why python is intepreting it as a variable, and as such, raising a NameError exception because the images local or global name is not found.



来源:https://stackoverflow.com/questions/8482897/simplecv-nameerror-name-images-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!