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

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, October 24, 2008 3:16:09 AM(UTC)

papyrum  
papyrum

Groups: Registered
Posts: 32


Hi,

I am using LeadTools v16. and the .NET class library.
I would like to know if it is possible with LeadTools to auto-detect image's orientation while scanning, and auto-rotate it.
I am showing (adding) in a RasterThumbnailBrowser each image (thumbnail) while it is being scanned; my purpose is to detect if the scanned image is upside down and then auto-rotate it to be correct.

I hope you could understand my "problem".

Thanks in advance,

Pablo L.G.
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, October 26, 2008 5:17:34 AM(UTC)

Yasir Alani  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

This can be achieved in one case, in which the image contains mainly text in lines.

If this is the case, then it is possible using the auto orientation feature of the OCR engine.
 
#3 Posted : Monday, October 27, 2008 12:01:00 AM(UTC)

papyrum  
papyrum

Groups: Registered
Posts: 32


Thanks for your quick reply,

The images ontains mainly text in lines.
Then, is neccesary to do an OCR page recognition to do the auto orientation? Is there any other method to get it? I think that doing an OCR page recoginition would take too much time because we would process a big amount of documents.

Thanks,

Pablo L.G.
 
#4 Posted : Monday, October 27, 2008 2:06:54 AM(UTC)

Yasir Alani  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

I'm afraid that this is the only way.

You need to start the OCR engine, load the image, then you can process auto-orient to it. Here is some sample code for illustration:
Code:
private void btnOCR_Click(object sender, EventArgs e)
{
    try
    {
        string inputFileName  = @"C:\Users\Public\Documents\LEADTOOLS Images\OCR1-4_skewed.tif",
               outputFileName = @"D:\junk folder\OcrDeskewTest.pdf";

        using (RasterCodecs codecs = new RasterCodecs())
        using (RasterImage image = codecs.Load(inputFileName))
        using (IOcrEngine _ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
        {
            _ocrEngine.Startup(codecs, null, null, null);
            IOcrDocument _ocrDocument = _ocrEngine.DocumentManager.CreateDocument();
            _ocrDocument.Pages.AddPages(image, 1, image.PageCount, null);
            _ocrDocument.Pages.AutoPreprocess(OcrAutoPreprocessPageCommand.Deskew, null);
            _ocrDocument.Pages.Recognize(null);
            _ocrDocument.Save(outputFileName, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, null);
            _ocrEngine.Shutdown();
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}


You can try this out within the C# OCR Multi-Engine Demo, and try the AutoPreprocess() method. This can be applied per page, a page range, or all pages in the document.

So you can start out with something like this:

SampleScannedDocument.PNG


But end up with this:

Output_PDF.PNG


File Attachment(s):
OCR1-4_skewed.tif (229kb) downloaded 61 time(s).

Edited by moderator Wednesday, April 26, 2017 7:18:08 AM(UTC)  | Reason: Added code example

 
#5 Posted : Tuesday, October 28, 2008 4:11:07 AM(UTC)

papyrum  
papyrum

Groups: Registered
Posts: 32


Ok Thanks :)
 
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.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.159 seconds.