RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

Optical Character Recognition using Winsoft’s component

  1. Introduction

OCR (Optical Character recognition) is a VCL type component (Windows platform only). Its main purpose is to decode text from a picture into plain text. Take a look at the video below to get the installation instructions.

2. Components in the Demo and what they do

There are two main panels – one on the left and one on the right witch keep all the other visual components inside. On the left is the TPanel, containing TImage. In this case the Image loads the chosen picture. At the top is the ‘Select Picture’ button. The OnClick event executes TOpenPictureDialog window, in which you can load the image from file. The  chosen file is shown with the TImage component into the left panel. A short video shows the Demo in action, see it below.

There are more options on the right. When an image with text is loaded from file on the right you can press the ‘Recognize’ button which starts exaction of text in image recognizing. While the process is ACTIVE the button Recognize changes to Cancel and the process could be stopped before it is already finished. The process of text recognition itself uses the TOcr component which its main purpose is exactly text recognition in an image.

    As you can see from the above code the image with text is already assigned by the OCR component, which means the text can be gotten with the .Text property of the OCR component. This is mainly done on the Recognize button click, containing also different image settings with Canvas, etc.

All these settings can be checked, using the TPageControl component. It reacts as a tab control, which changes the content on the right depending on the chosen page. First page shows the text in its simple variant. Next there is an html format of the text, then UNLV, followed by Regions, which puts the paragraphs in a frame. ‘The Paragraph’ Tab Sheet divides the recognized text on paragraphs (if there is more than one). The ‘Text Lines’ tab sheet count the lines of the hall text. Next to it is ‘Words’, which frames each word in the recognized text. The ‘Components’ sheet tab divides the text to separate components.  

You can see all them in the code below:

If Button ’Cancel’ is pressed while text recognition is in progress the flag ‘CancelRequest’ will become true, which will cause the code above to be NOT executed and no result will  be shown on the right.

The code for this OBR demo can be downloaded here.

Like what you see? You can get OCR for Windows and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4.1 today!


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
CodeDelphiRAD Studio

Optical Character Recognition Component for FireMonkey by Winsoft

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES