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

Notification

Icon
Error

Options
Go to last post Go to first unread
Toasterist  
#1 Posted : Saturday, February 11, 2017 11:34:45 AM(UTC)
Toasterist

Rank: Newbie

Groups: Registered
Joined: 2/11/2017(UTC)
Posts: 3
United States

Thanks: 1 times
Like the description says, I'd like to run OcrApi.ProcessPages in a backgroundworker and update a progressbar on the main UI. Should I be running ProcessPage for each page individually, and if so, is there a way to ensure that I get the same output as ProcessPages? I like that I don't have to iterate the file with processpages, but it either runs it UI blocking, or with no way to inform the user that it's still processing other than the classic, crappy, "Please Wait".
Paul Rayman  
#2 Posted : Saturday, February 11, 2017 3:06:56 PM(UTC)
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Hi,

Originally Posted by: Toasterist Go to Quoted Post
Should I be running ProcessPage for each page individually, and if so, is there a way to ensure that I get the same output as ProcessPages?


ProcessPages uses the ProcessPage inside itself.
Toasterist  
#3 Posted : Monday, February 13, 2017 8:39:29 AM(UTC)
Toasterist

Rank: Newbie

Groups: Registered
Joined: 2/11/2017(UTC)
Posts: 3
United States

Thanks: 1 times
So how do I get all of the pages into the Pix format? If I feed it the same multipage tif file, then it only does the first page.
Paul Rayman  
#4 Posted : Monday, February 13, 2017 2:51:37 PM(UTC)
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Please look at following

Code:

            using (var api = OcrApi.Create())
            {
                api.Init(Languages.English);
                using (var renderer = OcrPdfRenderer.Create(@"D:\1\3\file", @"tessdata"))
                {
                    renderer.BeginDocument("Title");
                    var image = Image.FromFile(@"D:\1\3\PropostadeseguroFormigoni.tiff");
                    var pages = image.GetFrameCount(FrameDimension.Page);

                    for (int index = 0; index < pages; 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);
                            }

                            var pix = OcrPix.FromBitmap(bmp);
                            api.ProcessPage(pix, null, 0, renderer);
                        }
                    }
                    renderer.EndDocument();
                }
            }

Edited by user Monday, February 13, 2017 2:56:58 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Paul Rayman for this useful post.
Toasterist on 2/14/2017(UTC)
Toasterist  
#5 Posted : Tuesday, February 14, 2017 9:27:37 AM(UTC)
Toasterist

Rank: Newbie

Groups: Registered
Joined: 2/11/2017(UTC)
Posts: 3
United States

Thanks: 1 times
Oh, I see. I could not have been more confused. I figured there was some imaging class in the OCR API that I was missing. Cheers! Great product.
Users browsing this topic
Guest
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.