noob: AttributeError: 'NoneType' object has no attribute 'tostring'

890 views
Skip to first unread message

tom

unread,
Mar 31, 2012, 5:30:10 PM3/31/12
to simp...@googlegroups.com
not sure why im getting the error above. any ideas? thx


code:

fset_blob = image.findBlobs().sortArea()
print type(fset_blob)
print "--------------------"
for b in fset_blob:
  b.draw()
-----------------------------------------------------
output:

Traceback (most recent call last):
  File "test.py", line 48, in <module>
    b.draw()
  File "/usr/local/lib/python2.7/dist-packages/SimpleCV-1.2-py2.7.egg/SimpleCV/Features/Blob.py", line 400, in draw
    masksurface = Image(maskbit).getPGSurface()
  File "/usr/local/lib/python2.7/dist-packages/SimpleCV-1.2-py2.7.egg/SimpleCV/ImageClass.py", line 592, in getPGSurface
    self._pgsurface = pg.image.fromstring(self.getPIL().tostring(), self.size(), "RGB")
AttributeError: 'NoneType' object has no attribute 'tostring'


Jay Rambhia

unread,
Mar 31, 2012, 5:38:47 PM3/31/12
to simp...@googlegroups.com
Hey,
I think you are using an older version of SimpleCV. Could you look it up ?
according to the latest version,
self._pgsurface = pg.image.fromstring(self.toRGB().getBitmap().tostring(), self.size(), "RGB")

I think this could be the problem, but I am not completely sure.
So, if you can, try and upgrade your simpleCV library.
--
Jay Rambhia,
Undergraduate Student,
Mechanical Engineering,
BITS,Pilani Goa Campus
Contact : 09967119686
@jayrambhia
Blog - Paranoid Android
GitHub
gists

tom

unread,
Mar 31, 2012, 5:47:49 PM3/31/12
to simp...@googlegroups.com
thx, i did the a new install of ubuntu 11.1 as desctibed here:

but when i search:
~$ apt-cache search SimpleCV
texlive-latex-extra - TeX Live: LaTeX supplementary packages
python-simplecv - Make Computers See with SimpleCV, the Python Framework for M

not sure what else to install....

any ideas?

thx again

Jay Rambhia

unread,
Mar 31, 2012, 5:49:47 PM3/31/12
to simp...@googlegroups.com
Download complete library from GitHub. https://github.com/ingenuitas/SimpleCV
and install using $ sudo python setup.py install (after changing the directory)
It works for me.

tom

unread,
Mar 31, 2012, 5:52:51 PM3/31/12
to simp...@googlegroups.com
just run into this:
sudo apt-get install libopencv2.3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libopencv2.3
0 upgraded, 1 newly installed, 0 to remove and 83 not upgraded.
Need to get 0 B/11.5 MB of archives.
After this operation, 88.1 MB of additional disk space will be used.
(Reading database ... 94125 files and directories currently installed.)
Unpacking libopencv2.3 (from .../libopencv2.3_2.3.1-3_i386.deb) ...
dpkg: error processing /var/cache/apt/archives/libopencv2.3_2.3.1-3_i386.deb (--unpack):
 trying to overwrite '/usr/lib/libopencv_highgui.so.2.3.1', which is also in package libopencv-highgui2.3 2.3.1-4ppa1
E: Sub-process /usr/bin/dpkg returned an error code (1)

Jay Rambhia

unread,
Mar 31, 2012, 5:56:05 PM3/31/12
to simp...@googlegroups.com
I don't think there's any problem with your opencv library.
And I don't know why you got that error while installing libopencv.
Try installing latest simpleCV from GitHub, and check if you are still getting the same error or not.

tom

unread,
Mar 31, 2012, 5:59:17 PM3/31/12
to simp...@googlegroups.com
will try - thank you

Krishna Mohan

unread,
Mar 31, 2012, 6:25:14 PM3/31/12
to simp...@googlegroups.com
Hi Tom,
  I ran into somewhat similar problem with opencv before (my ubuntu was already a mess with all my experiments at the time)
I did a fresh install of ubuntu 11.10 and used the following to get opencv and subsequently simplecv working

http://thebitbangtheory.wordpress.com/2011/10/23/how-to-install-opencv-2-3-1-in-ubuntu-11-10-oneiric-ocelot-with-python-support/
Reply all
Reply to author
Forward
0 new messages