GdPictureImaging.OCRTesseractGetOrientation Issues

Discussions about machine vision support in GdPicture.
Post Reply
storygroup
Posts: 3
Joined: Tue Jul 28, 2009 10:52 am

GdPictureImaging.OCRTesseractGetOrientation Issues

Post by storygroup » Tue Jul 28, 2009 11:18 am

Hi,

When calling GdPictureImaging.OCRTesseractGetOrientation I am getting inaccurate results.

Attached is an example MultiPage TIFF that does not rotate correctly. It does not rotate at all - the function come back with RotateNoneFlipNone. I can reproduce similar behavior with other text documents like that one too. In some cases it flips the document 270 rather that 90, resulting in the document being landscape, but upside down. I can dig out an example of that if need be too.

Also, when do you think we will be getting support for PDFs in the GdPictureImaging library like we do in GdViewer? I'm using GDPicture in a windows service, and so I can't use a user control (drag and drop error, etc).

Cheers,

Tom
Attachments
Example.tif

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: GdPictureImaging.OCRTesseractGetOrientation Issues

Post by Loïc » Tue Jul 28, 2009 5:19 pm

Hi Tom,

No problem for me:

Code: Select all

Dim Rotation As RotateFlipType = oGdPictureImaging.OCRTesseractGetOrientationImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\OCR\")
Rotation is 270° which is OK.

Kind regards,

Loïc

storygroup
Posts: 3
Joined: Tue Jul 28, 2009 10:52 am

Re: GdPictureImaging.OCRTesseractGetOrientation Issues

Post by storygroup » Tue Jul 28, 2009 6:15 pm

Hi Loïc,

Wouldn't 270 degrees clockwise end up with the document upside down? That is the behavior I'm getting on this one now as well.

After taking the section of code out of my large project and into a standalone app (as I assume you did), I still cannot get it to work...

Code in question with the above Example.tif in .NET 3.5:

Code: Select all

    Sub Main()
        Dim GDImaging As New GdPicture.GdPictureImaging
        GDImaging.SetLicenseNumber("")
        GDImaging.SetLicenseNumberOCRTesseract("")
        GDImaging.OCRTesseractSetPassCount(1)
        GDImaging.TiffOpenMultiPageForWrite(False)

        Dim TIFFID As Integer = GDImaging.TiffCreateMultiPageFromFile("C:\Example.tif")
        Dim PageCount As Integer = GDImaging.TiffGetPageCount(TIFFID)
        Dim PDFID = GDImaging.PdfOCRStart("C:\Example.pdf", True, "", "", "", "", "")

        For i As Integer = 1 To PageCount
            GDImaging.TiffSelectPage(TIFFID, i)
            Dim ImageID As Integer = GDImaging.CreateClonedGdPictureImageI(TIFFID)
            GDImaging.Rotate(ImageID, GDImaging.OCRTesseractGetOrientation(ImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\OCR\"))
            Console.Write(GDImaging.PdfAddGdPictureImageToPdfOCR(PDFID, ImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\OCR\", ""))
            GDImaging.ReleaseGdPictureImage(ImageID)
        Next

        GDImaging.PdfOCRStop(PDFID)
        GDImaging.ReleaseGdPictureImage(TIFFID)
    End Sub
I use this to process multiple exported TIFF's from a main process simultaneously depending on the number of processors on the machine. The above is almost a copy and paste. (On a side note - is it correct that the GDImaging OCR component cannot be used from multiple threads? I got MsgBox's popping up everywhere when I tried... Hence the spin off processes that isolate everything.)

Hope that helps.

Cheers,

Tom

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: GdPictureImaging.OCRTesseractGetOrientation Issues

Post by Loïc » Thu Jul 30, 2009 12:02 am

Hi TOM,

Here you have a problem:

Code: Select all

GDImaging.Rotate(ImageID, GDImaging.OCRTesseractGetOrientation(ImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\OCR\"))
If the document have a rotation of 270° you should rotate it to 90° to get it in the correct orientation. Therefore, for 90° oriented documents you should apply a rotation of 270°

Kind regards,

Loïc

storygroup
Posts: 3
Joined: Tue Jul 28, 2009 10:52 am

Re: GdPictureImaging.OCRTesseractGetOrientation Issues

Post by storygroup » Thu Jul 30, 2009 3:31 pm

Hi,

Now it all makes sense!

Do you think a GDPictureImaging.FixOrientation(ImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\OCR\") added for a future release to make it clearer?

Thanks for helping me out on this one.

Cheers,

Tom

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest