Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrectly detects orientation #4

Closed
reubano opened this issue May 17, 2016 · 12 comments
Closed

incorrectly detects orientation #4

reubano opened this issue May 17, 2016 · 12 comments

Comments

@reubano
Copy link

reubano commented May 17, 2016

I've noticed the orientation example doesn't distinguish between upside down/rightside up and clockwise/counter clockwise orientations.

reubano@tokpro [~]⚡ tesseract -psm 0 up.jpg - 
Orientation: 0
Orientation in degrees: 0
Orientation confidence: 0.23
Script: 1
Script confidence: 0.98

reubano@tokpro [~]⚡ tesseract -psm 0 down.jpg - 
Orientation: 2
Orientation in degrees: 180
Orientation confidence: 0.21
Script: 1
Script confidence: 0.61
with PyTessBaseAPI(psm=PSM.AUTO_OSD) as api:
    for path in ['up.jpg', 'down.jpg']:
        image = Image.open(path)
        api.SetImage(image)
        api.Recognize()
        it = api.AnalyseLayout()    
        print it.Orientation()

(0, 0, 2, 0.0)
(0, 0, 2, 0.0)
@sirfz
Copy link
Owner

sirfz commented May 17, 2016

Strange, just tested it with eurotext.tif (both original and flipped upside-down) and it output correct results:

with tesserocr.PyTessBaseAPI(psm=tesserocr.PSM.AUTO_OSD) as api:
    for image in ['eurotext.tif', 'eurotext_flipped.tif']:
        image = Image.open(image)
        api.SetImage(image)
        api.Recognize()
        it = api.AnalyseLayout()
        print it.Orientation()

Output:

(0, 0, 2, 0.013791237957775593)
(2, 0, 2, 0.013791237957775593)

@reubano
Copy link
Author

reubano commented May 18, 2016

My output

(0, 0, 2, 0.013791237957775593)
(0, 0, 2, 0.01034371554851532)

versions

reubano@tokpro [~]⚡ pip freeze | grep tesserocr
tesserocr==2.0.0

reubano@tokpro [~]⚡ tesseract --version
tesseract 3.04.00
 leptonica-1.73
  libgif 4.2.3 : libjpeg 9a : libpng 1.6.21 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.5.0 : libopenjp2 2.1.0

fyi, tesserocr 2.0.1 isn't on pypi.

@sirfz
Copy link
Owner

sirfz commented May 18, 2016

Could you please share your images so I can properly test this?

@reubano
Copy link
Author

reubano commented May 18, 2016

Same one you linked

@sirfz
Copy link
Owner

sirfz commented May 18, 2016

2.0.1 doesn't have any changes to the source code so it won't differ from v2.0.0, main difference between our environments are the dependencies. Mine are:

$ tesseract --version
tesseract 3.04.00
 leptonica-1.72
  libjpeg 8d (libjpeg-turbo 1.3.0) : libpng 1.2.51 : libtiff 4.0.3 : zlib 1.2.8

Yours are more recent but I don't see why this should affect the output.

The example you're trying is based on the C API example here.

I'm using the packages provided in my default PPAs (Ubuntu 15.10) but I'll try to at least test with an updated compilation of leptonica and see if that changes anything. Would appreciate it if you can test on a different environment as well if possible and see if that gives different results.

@reubano
Copy link
Author

reubano commented May 18, 2016

I use macports which doesn't really let you downgrade a package. If it helps, I have Cython version 0.23.5.

@reubano
Copy link
Author

reubano commented May 18, 2016

I think the issue is with tesseract's (or maybe leptonica's) api. I modified code from nidaba to call the c-api directly and got similar results.

@sirfz
Copy link
Owner

sirfz commented May 18, 2016

Given that using the tesseract executable returns correct results, it's very possible that the problem is with the API interface. Certainly worth investigating.

@reubano
Copy link
Author

reubano commented May 18, 2016

I was able to downgrade to leptonica-1.71 and it appears to now work :).

@sirfz
Copy link
Owner

sirfz commented May 18, 2016

Glad you were able to pin the cause down. Still weird that you got the correct result with the tesseract executable though.

@reubano
Copy link
Author

reubano commented May 18, 2016

Go figure... hopefully someone smarter than me can figure that out.

@reubano reubano closed this as completed May 18, 2016
@reubano
Copy link
Author

reubano commented May 19, 2016

Just a note for anyone else that the (macports) program tesseract-osd may also play a role in this. The downgraded leptonica complained that it was missing, so that could have been the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants