LEADTOOLS Support
Document
Document SDK FAQ
Can I extract text from my screen using your OCR?
#1
Posted
:
Friday, April 7, 2017 3:56:44 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 163
Was thanked: 9 time(s) in 9 post(s)
It is possible to do this using LEADTOOLS, by using the Multimedia Screen Capture filter in conjunction with LEADTOOLS OCR. Once the screen capture is made, an event is raised which contains a RasterImage containing the current screen contents. This information can then be passed to the OcrEngine and recognized accordingly.
Here's how this can be done by wiring in the OCR engine to process a screenshot raised from the event and save it to disk.
Code:
void scEngine_CaptureInformation(object sender, ScreenCaptureInformationEventArgs e)
{
// Define codecs class object to save the image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false))
{
// Start the engine using default parameters
ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLeadRuntimeDir);
// Create an OCR document
using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())
{
// Add a page to the document
IOcrPage ocrPage = ocrDocument.Pages.AddPage(e.Image, null);
ocrPage.AutoZone(null);
ocrPage.Recognize(null);
// Save the document we have as PDF
ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);
}
// Shutdown the engine
// Note: calling Dispose will also automatically shutdown the engine if it has been started
ocrEngine.Shutdown();
}
}
For more information on creating, configuring and using the screenshot engine, and about OCR, see our documentation pages.
https://www.leadtools.com/help/sdk/dh/sc/screencaptureengine.htmlhttps://www.leadtools.com/help/sdk/dh/fo/iocrengine.htmlFurthermore, we have a demo application which showcases this functionality created by a LEADTOOLS support agent. More information as well as source code is available on its info page.
https://www.leadtools.com/blog/document-imaging/ocr/ocr-screen-capture-25-projects-25-days/Edited by moderator Wednesday, December 27, 2023 3:36:09 PM(UTC)
| Reason: Updated
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK FAQ
Can I extract text from my screen using your OCR?
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.