logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
JWPHRIJK  
#1 Posted : Friday, June 8, 2018 5:16:57 PM(UTC)
JWPHRIJK

Rank: Newbie

Groups: Registered
Joined: 5/30/2018(UTC)
Posts: 4
Netherlands

Thanks: 1 times
Hello,

I'm working om a application to OCRen check the orientation from a multipage Tiff file en then create a PDF. For checking the orientation I need to call OcrApi.recognise() and for the OCR I need to call OcrApi.ProcessPage() to render the found text into a pdf. This seems redundant while both methodes seem to proces the tekst from the image.

Is there a way to combine the orientation check and the ProcessPage proces to speed up the proces.

Thanks in advance for the reply.
Paul Rayman  
#2 Posted : Sunday, June 10, 2018 7:48:26 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,102

Thanks: 7 times
Was thanked: 128 time(s) in 125 post(s)
Hi,

Try the following

Code:

    using (var api = OcrApi.Create())
    {
        api.Init(Languages.English);
        using (var renderer = OcrPdfRenderer.Create(@"d:\0\multipage", @"tessdata"))
        {
            renderer.BeginDocument("Title");
            var image = Image.FromFile(@"d:\0\multipage.tif");
            int pageCnt = image.GetFrameCount(FrameDimension.Page);

            for (int index = 0; index < pageCnt; index++)
            {
                image.SelectActiveFrame(FrameDimension.Page, index);
                using (var bmp = new Bitmap(image.Width, image.Height))
                {
                    using (var g = Graphics.FromImage(bmp))
                    {
                        g.DrawImage(image, 0, 0, image.Width, image.Height);
                    }
                    using (var pix = OcrPix.FromBitmap(bmp))
                    {
                        api.InputName = @"multipage.tif";
                        api.InputImage = pix;
                        api.SetImage(pix);
                        api.SourceResolution = 95;
                        api.Recognize();

                        var b = renderer.AddImage(api);
                    }
                }
            }
            renderer.EndDocument();
        }
    }
}
JWPHRIJK  
#3 Posted : Monday, June 11, 2018 2:58:12 PM(UTC)
JWPHRIJK

Rank: Newbie

Groups: Registered
Joined: 5/30/2018(UTC)
Posts: 4
Netherlands

Thanks: 1 times
Thanks for the reply,

This gets me further but I still have to edit the picture. Is it possible to deskey and set the orientation of the OcrPix format Or do I first have to convert it to a bitmap.
Paul Rayman  
#4 Posted : Thursday, June 14, 2018 2:38:59 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,102

Thanks: 7 times
Was thanked: 128 time(s) in 125 post(s)
You can convert it to an Image since after that you will have to make a new recognition in any case.
JWPHRIJK  
#5 Posted : Tuesday, June 19, 2018 4:08:45 PM(UTC)
JWPHRIJK

Rank: Newbie

Groups: Registered
Joined: 5/30/2018(UTC)
Posts: 4
Netherlands

Thanks: 1 times
Thanks for your response,

This is just what I wanted to prevent! isn't there a way to change the rotation and orientation of the image in the api object before calling renderer.EndDocument() and not having to call Recognize() again
Paul Rayman  
#6 Posted : Thursday, June 21, 2018 4:09:17 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,102

Thanks: 7 times
Was thanked: 128 time(s) in 125 post(s)
In this case you should not to rotate the image even if it turned
You may try to use AUTO_ROTATE or remember the angle of rotation and rotate the page in the finished PDF.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.