Rank: Newbie
Groups: Registered
Joined: 5/30/2018(UTC) Posts: 4 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.
|
|
|
|
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();
}
}
}
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 5/30/2018(UTC) Posts: 4 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.
|
|
|
|
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.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 5/30/2018(UTC) Posts: 4 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
|
|
|
|
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.
|
|
|
|
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close