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

PageSegMode.OsdOnly orientation always PageUp #156

Closed
boddy33 opened this issue Feb 22, 2015 · 11 comments
Closed

PageSegMode.OsdOnly orientation always PageUp #156

boddy33 opened this issue Feb 22, 2015 · 11 comments

Comments

@boddy33
Copy link

boddy33 commented Feb 22, 2015

Hi,

I need to detect page orientation only (no OCR).

If I process image with PageSegMode.OsdOnly, detected Orientation is always PageUp:

using (Bitmap src = Image.FromStream(imageStream) as Bitmap)
{
using (TesseractEngine tesseractEngine = new TesseractEngine(_tessdataPath, "eng", EngineMode.Default))
{
tesseractEngine.DefaultPageSegMode = PageSegMode.OsdOnly;

                        using (var page = tesseractEngine.Process(src))
                        {
                            using (var iter = page.AnalyseLayout())
                            {
                                iter.Begin();
                                var pageProps = iter.GetProperties();
                                Orientation orient = pageProps.Orientation;

...
}}}}

this code seems to work only if DefaultPageSegMode = PageSegMode.AutoOsd;

Any idea why?

Thanks
Bogdan

@charlesw
Copy link
Owner

Do you have the orientation scripts installed in your tessdata directory, check out Issue #109.

@boddy33
Copy link
Author

boddy33 commented Feb 25, 2015

Yes, osd.traineddata is included and PageSegMode.AutoOsd works correctly. PageSegMode.OsdOnly always brings PageUp

I am trying to get PageSegMode.OsdOnly work because I think it will work faster than PageSegMode.AutoOsd: In our system we firstly detect orientation, rotate file and then process page with PageSegMode.SingleBlock. We do processing with multiple threads and trying to reduce processing times.

Regards
Bogdan

@charlesw
Copy link
Owner

Thanks, I've had a look into this and apparently your supposed to use the
DetectOS function if you're just after orientation information OsdOnly).
Unfortunately that functionality hasn't yet been exposed via the CAPI that
this wrapper uses. I'll see if I can get it added in the upcoming tesseract
3.04 release but no promises :)
On 26 Feb 2015 06:27, "boddy33" notifications@github.com wrote:

Yes, osd.traineddata is included and PageSegMode.AutoOsd works correctly.
PageSegMode.OsdOnly always brings PageUp

I am trying to get PageSegMode.OsdOnly work because I think it will work
faster than PageSegMode.AutoOsd: In our system we firstly detect
orientation, rotate file and then process page with
PageSegMode.SingleBlock. We do processing with multiple threads and trying
to reduce processing times.

Regards
Bogdan


Reply to this email directly or view it on GitHub
#156 (comment).

@charlesw
Copy link
Owner

I've had another look into this and I was wrong when I mentioned that this functionality was not exposed via the CAPI 3.02. I should be able to expose this functionality however it should be noted that it only returns the orientation (e.g. Page UP, Page Down, etc) and script. I'm not sure I can expose the script information as this generally requires access to some C++ classes which I don't have access to from .NET. Note the deskew angle is NOT exposed\available. If you need that information you'll need to use AutoOSD with AnalyseLayout.

@boddy33
Copy link
Author

boddy33 commented Mar 20, 2015

Hi Charles,

thank you for information.
We are also running some tests with 3.04 and noted that OSD quality is much higher than in 3.02 (especially for low quality faxed documents) so we have upcoming in focus.

Can we contribute somehow in speeding up 3.04 release?

charlesw added a commit that referenced this issue Mar 23, 2015
@charlesw
Copy link
Owner

I've implemented this support in the current dev branch (targets 3.02) and it will be in the next release, probably latter this week. Can you also test it to see if it's working for you? Note that it only exposes the orientation and corresponding confidence not the script information as I couldn't get hold of that easily.

In regards to supporting 3.04 the main blocker here is that this has to wait until after 3.04 has been officially released. After that it shouldn't take to long to release an updated version of this wrapper that uses this version of Tesseract though it probably won't expose ALL of the new functionality right away (I tend to weight until someone explicitly requests something, ideally with a particular use case in mind).

Usage Example:

using (var img = Pix.LoadFromFile(@".\phototest.tif")) {
    using (var page = engine.Process(img, pageSegMode)) {
        Orientation orientation;
        float confidence;
        page.DetectBestOrientation(out orientation, out confidence);

        Assert.That(orientation, Is.EqualTo(Orientation.PageDown));
    }
}

@boddy33
Copy link
Author

boddy33 commented Mar 26, 2015

Hi Charles,

thanks a lot for this improvement, it works. I will test a bit more and let you know results.

@ghost
Copy link

ghost commented Mar 27, 2015

Hi,

It will be very helpful in a specific project that I´m working. Congratulations!

Carlos Flávio Barreto Ferreira de Souza

@boddy33
Copy link
Author

boddy33 commented Mar 28, 2015

Hi,

so according to our tests accuracy of orientation is about 95% with DetectBestOrientation in 3.02 comparing to 98% with custom 3.04 build. But 3.04 is 35% slower than 3.02.

Still cant understand though why OCR with AutoOSD brings such a poor results comparing to DetectBestOrientation in same 3.02 build.

Waiting for official release of wrapper, thanks again Charles.

@charlesw
Copy link
Owner

Okay, thanks for the extra testing. I'll do an official release later today.
On Mar 29, 2015 7:00 AM, "boddy33" notifications@github.com wrote:

Hi,

so according to our tests accuracy of orientation is about 95% with
DetectBestOrientation in 3.02 comparing to 98% with custom 3.04 build. But
3.04 is 35% slower than 3.02.

Still cant understand though why OCR with AutoOSD brings such a poor
results comparing to DetectBestOrientation in same 3.02 build.

Waiting for official release of wrapper, thanks again Charles.


Reply to this email directly or view it on GitHub
#156 (comment).

@charlesw
Copy link
Owner

The new release 2.3.0 is out.

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