Sure. After you call SetImage to provide the bitmap, just do this:

                OSResults *orientationStruct = new OSResults();

                bool gotOrientation = myTess->DetectOS(orientationStruct);

                int bestOrientation = -1;
                float bestOrientationScore = 0;
                if ((gotOrientation) && (orientationStruct->orientations != 
NULL)) {
                        for (int i=0; i<4; i++) {
                                if (orientationStruct->orientations[i] > 
bestOrientationScore) {
                                        bestOrientation = i;
                                        bestOrientationScore = 
orientationStruct->orientations[i];
                                }
                        }
                }

                // This is the result we were asked for
                results.textOrientation = bestOrientation;

"bestOrientation" will be the index of the entry in the length 4 array
of orientation tests which got the highest score and indicates the
text orientation (I'll leave it as an exercise to the reader to figure
out how to map 0,1,2,3 to pointing up, right, down and left ...). You
can get a sense of Tess confidence in the result by examining the
value of the score that won.

Patrick

On Feb 28, 1:50 pm, "Giuseppe Menga" <[email protected]> wrote:
> Patrick
> just a hint of how to use the orientation functionality of Tesseract
> Giuseppe
>
> -----Messaggio originale-----
> From: patrickq
> Sent: Monday, February 28, 2011 7:44 PM
> To: tesseract-ocr
> Subject: Re: text rotated upside down or of 90
>
> ScanBizCards (iPhone version) is using the Tesseract 3.0 orientation
> detection, works quite well - accurate in 95%+ of cases and the 5%
> failure cases are oftentimes because we scan business cards where
> there isn't a lot of text to go by + there is a lot of non-text
> confusing the detection.
>
> Patrick
>
> On Feb 28, 1:35 pm, "Jimmy O'Regan" <[email protected]> wrote:
>
>
>
> > On 28 February 2011 15:17, Giuseppe Menga <[email protected]> wrote:
>
> > > at Politecnico di Torino we are using the release 3.0.0 of tesseract,
> > > with
> > > the standard english training.
> > > Obviously the software doesn t recognize pages of text rotated upside
> > > down
> > > and we would not expect it does, however with surprise, it recognizes
> > > with a
> > > little worse performance text rotated of 90 counter clockwise, but not
> > > clockwise.
> > > How that is possible?
>
> > It's a side-effect of support for Japanese, Chinese, etc.
>
> > > We have to recognize text we don t know in advance the orientation, and
> > > I
> > > know that Leptonica should be used for page layout analysis.
> > > However, does tesseract offers internal facilities to recognize text
> > > orientation?
> > > And if so, how to activate these facilities or at least to return
> > > tentative
> > > baselines?
>
> > There's an orientation/script detection module in the 3.01 code, but I
> > haven't even tried to use it, so I couldn't say.
>
> > --
> > <Leftmost> jimregan, that's because deep inside you, you are evil.
> > <Leftmost> Also not-so-deep inside you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "tesseract-ocr" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/tesseract-ocr?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tesseract-ocr?hl=en.

Reply via email to