goncalopp / simple-ocr-opencv

A simple python OCR engine using opencv
GNU Affero General Public License v3.0
525 stars 175 forks source link

ValueError: Input object to FillWithScalar is not a scalar #3

Closed RecklessCoding closed 11 years ago

RecklessCoding commented 11 years ago

Hello,

First of all great project, really educational and thank you for sharing.

When I run the example.py file through my Terminal (OS X 10.7, Python 2.7.3) I get the following error, only after I press ANY key on the screen with the Pi number:

showing after BlurProcessor (waiting for input)
Traceback (most recent call last):
  File "example.py", line 15, in <module>
    test_classes, test_segments= ocr.ocr( test_image, show_steps=True )
  File "/Users/Ath/Source/CW/ocr_simple/ocr.py", line 42, in ocr
    self.segmenter.display()
  File "/Users/Ath/Source/CW/ocr_simple/processor.py", line 143, in display
    p.display( display_before= False )
  File "/Users/Ath/Source/CW/ocr_simple/segmentation.py", line 63, in display
    copy.fill( (255,255,255) )
ValueError: Input object to FillWithScalar is not a scalar

I would appreciate any help, as I am still a Python newbie...

goncalopp commented 11 years ago

That's interesting. Maybe something changed on the numpy library. What's your version?

import numpy
print numpy.version.version

Does it work if you change the referenced line to

copy.fill( 255 )

?

RecklessCoding commented 11 years ago

Hello, thanks for the quick reply.

I am using Numpy with version: 1.8.0.dev-436a28f

Changing the referred results syntax issues in other files. Should I change them too?

Your reference example from Stackoverflow and a few other similar programs work fine.

goncalopp commented 11 years ago

I am using Numpy with version: 1.8.0.dev-436a28f

That is way too recent. It may not be a good idea to use a numpy version that is still in development. I can't commit to support it until a proper release is done.

I'm not sure how python packaging is done on OSX; did you install numpy yourself? If that's the case, I'd try 1.6 or 1.7.

Changing the referred results syntax issues in other files. Should I change them too?

If you absolutely need numpy 1.8, yes. But many other things may be subtly broken

Your reference example from Stackoverflow and a few other similar programs work fine.

It's not actually my program, I just borrowed the code at first since it used a very simple learning algorithm (K-NN) :)

RecklessCoding commented 11 years ago

My Python installation was a "tragical" one, as HomeBrew and pip were downloading OS 10.8 versions, making half the libraries not working. I re-download everything (Numpy, OpenCV, Scipy, scikit, etc) via Easy_install and these versions were downloaded at the end.

I will check up later in case you eventually commit support to this version.

That is what I meant to say -unfortunately I speak "Java" better than English...

Anyway thank you once again for your extremely educational code. :) I may try to edit it, otherwise just reading it and going through it will be useful.

I will check back again, in the future, if you ever update it to support Numpy 1.8.

goncalopp commented 11 years ago

I will check up later in case you eventually commit support to this version.

Note that 1.8 is currently in development. I'm not sure if the bug you encountered will be reproducible on the final numpy 1.8 . The fill function documentation did not change at all. When it gets released, you'll have to upgrade from the development version to the final version, anyway.

In the meantime, you may want to try using easy_install to force a specific version

ghost commented 10 years ago

Great stuff. Is there compatibility with Numpy 1.8 at this point? I seem to be getting the same error message.

goncalopp commented 10 years ago

It seems the code was relying in undocumented behaviour. A change in numpy triggered this issue, but conforms to documentation. This is now fixed on master.