Passer au contenu du pied de page
UTILISATION D'IRONOCR

OCR avec vision par ordinateur (Tutoriel d'exemple)

Optical Character Recognition (OCR) with IronOCR

Optical Character Recognition (OCR) is a technology that enables machines to read and interpret text from images, making data processing and automation faster and more efficient. This article provides guidelines on using OCR with the IronOCR library and how it can enhance text recognition, automating this process.

Why OCR is Important?

OCR along with computer vision is an advanced form of Optical Character Recognition (OCR) that leverages the power of artificial intelligence and machine learning algorithms to recognize text characters from images more accurately and efficiently.

Computer vision image processing algorithms allow OCR systems to understand the context and layout of text in an image and recognize characters based on their shape and structure. OCR along with computer vision can extract text from complex images with multiple fonts, styles, and sizes, making it a valuable tool in document digitization, data extraction, and automation.

IronOCR: C# OCR Library

IronOCR is a popular OCR library that uses computer vision techniques for text extraction from images and documents. It is easy to use and integrates with multiple programming languages, including C# and VB.NET. IronOCR is available in both on-premise and cloud versions and offers a range of functionalities to process and extract text from images.

Installing IronOCR

To install IronOCR, use the following command in the NuGet Package Manager Console:

Install-Package IronOcr

OCR System with IronOCR

The following image is used to test the OCR System with Computer Vision using IronOCR.

OCR With Computer Vision (Example Tutorial), Figure 1: Image sample used for OCR detection Image sample used for OCR detection

FindTextRegion Method

The FindTextRegion method is used to identify a single text region within an image. The method takes several optional parameters, including Scale, DilationAmount, Binarize, and Invert:

  • Scale adjusts the size of the image for better text recognition.
  • DilationAmount increases the thickness of the text to enhance visibility.
  • Binarize converts the image into black and white, improving contrast.
  • Invert inverts the colors of the image, which can be useful for certain types of images.
using IronOcr;
using System;

// Initialize the IronTesseract OCR engine
var ocr = new IronTesseract();

// Create an OcrInput object for the image
using (var inputOCR = new OcrInput("test.jpg")) 
{
    // Identify a text region within the image
    inputOCR.FindTextRegion();

    // Perform OCR on the identified text region
    OcrResult result = ocr.Read(inputOCR);

    // Extract and print the recognized text
    string resultText = result.Text;
    Console.WriteLine(resultText);
}
using IronOcr;
using System;

// Initialize the IronTesseract OCR engine
var ocr = new IronTesseract();

// Create an OcrInput object for the image
using (var inputOCR = new OcrInput("test.jpg")) 
{
    // Identify a text region within the image
    inputOCR.FindTextRegion();

    // Perform OCR on the identified text region
    OcrResult result = ocr.Read(inputOCR);

    // Extract and print the recognized text
    string resultText = result.Text;
    Console.WriteLine(resultText);
}
Imports IronOcr
Imports System

' Initialize the IronTesseract OCR engine
Private ocr = New IronTesseract()

' Create an OcrInput object for the image
Using inputOCR = New OcrInput("test.jpg")
	' Identify a text region within the image
	inputOCR.FindTextRegion()

	' Perform OCR on the identified text region
	Dim result As OcrResult = ocr.Read(inputOCR)

	' Extract and print the recognized text
	Dim resultText As String = result.Text
	Console.WriteLine(resultText)
End Using
$vbLabelText   $csharpLabel

Note: After running the code, you'll see that it extracts text from the text region using a machine-learning process. The output result appears in the console with high text recognition accuracy.

OCR With Computer Vision (Example Tutorial), Figure 2: The Console results from the text extraction process The Console results from the text extraction process

FindMultipleTextRegions Method

The FindMultipleTextRegions method is similar to FindTextRegion, but it is used when there are multiple text regions in an image. It returns a list of CropRectangle objects that define the location of each text region. This method is useful when you want to extract text from an image that contains multiple sections of text.

using IronOcr;

// Initialize the IronTesseract OCR engine
var ocr = new IronTesseract();

// Create an OcrInput object for the image
using (var input = new OcrInput("test.jpg"))
{
    // Identify multiple text regions within the image
    input.FindMultipleTextRegions(Scale: 2.0, DilationAmount: -1, Binarize: true, Invert: false);

    // Perform OCR on the pre-processed image
    OcrResult result = ocr.Read(input);

    // Extract and print the recognized text
    string resultText = result.Text;
    Console.WriteLine(resultText);
}
using IronOcr;

// Initialize the IronTesseract OCR engine
var ocr = new IronTesseract();

// Create an OcrInput object for the image
using (var input = new OcrInput("test.jpg"))
{
    // Identify multiple text regions within the image
    input.FindMultipleTextRegions(Scale: 2.0, DilationAmount: -1, Binarize: true, Invert: false);

    // Perform OCR on the pre-processed image
    OcrResult result = ocr.Read(input);

    // Extract and print the recognized text
    string resultText = result.Text;
    Console.WriteLine(resultText);
}
Imports IronOcr

' Initialize the IronTesseract OCR engine
Private ocr = New IronTesseract()

' Create an OcrInput object for the image
Using input = New OcrInput("test.jpg")
	' Identify multiple text regions within the image
	input.FindMultipleTextRegions(Scale:= 2.0, DilationAmount:= -1, Binarize:= True, Invert:= False)

	' Perform OCR on the pre-processed image
	Dim result As OcrResult = ocr.Read(input)

	' Extract and print the recognized text
	Dim resultText As String = result.Text
	Console.WriteLine(resultText)
End Using
$vbLabelText   $csharpLabel

Explanation: The code snippet provided above is an example of how to use the IronOCR library to perform OCR on an image file. It first imports the IronOCR library and creates a new instance of the IronTesseract class. Then, it initializes an OcrInput object with the path of the input image file and applies some pre-processing techniques for image correction using the FindMultipleTextRegions method.

The Output of IronOCR

The output of IronOCR is very accurate, even when dealing with complex images with multiple fonts, sizes, and styles of text.

OCR accuracy is crucial when extracting data from images because the extracted text is often used for further processing, such as data analysis, manual data entry, machine learning, or natural language processing. If the extracted text contains errors, it can cause problems downstream. Additionally, IronOCR allows investigation into result objects to check confidence levels.

Use Cases of OCR Computer Vision

Optical Character Recognition (OCR) technology has revolutionized the way printed text is handled. OCR tools have become an indispensable part of document processing and data extraction. Here are some use cases of Optical Character Recognition software:

OCR License Plate Recognition

License plate recognition plays a significant role in automating traffic management, parking systems, and law enforcement activities. By implementing OCR computer vision in C#, developers can create applications that quickly and accurately identify license plates from images or live video feeds. This technology can be used to:

  • Monitor traffic violations and identify vehicles involved in criminal activities.
  • Automate the parking systems, facilitating entry and exit management and streamlining the billing process.
  • Enhance security measures by tracking and monitoring vehicle movement in restricted areas.

Extracting Text from Invoices

OCR computer vision in C# can be utilized to develop OCR applications that automate the extraction of text from invoices and other financial documents. This process can drastically reduce manual data entry errors and streamline accounting tasks. Key benefits include:

  • Increased productivity by automating the data entry process.
  • Improved accuracy, as OCR reduces the likelihood of human errors.
  • Seamless integration with accounting software and systems for efficient data management.

OCR Subtitles Generation

Creating subtitles for videos can be time-consuming and labor-intensive. OCR computer vision in C# can simplify this process by automatically detecting and transcribing the on-screen text, enabling developers to:

  • Create accurate subtitles for movies, TV shows, and online videos.
  • Enhance accessibility for individuals with hearing impairments or those who speak different languages.
  • Boost SEO efforts by providing searchable, indexable content for the video platform

OCR PDF Processing

PDFs are widely used for sharing and storing documents, but extracting text from them can be challenging. OCR computer vision in C# can help developers build OCR applications that effortlessly process PDF files and extract their content, facilitating:

Digitizing Printed Text

OCR software is widely used to digitize printed text from document images. OCR tools can extract text from scanned digital documents, PDFs, and images in various formats. This is particularly useful in document management, where you can easily search, store, and share text-based documents.

Data Extraction

OCR technology is widely used to extract data from input data such as invoices, receipts, and forms. OCR models can recognize and extract key data fields such as names, addresses, dates, and amounts. This eliminates the need for manual data entry and reduces errors in the data processing.

OCR technology is also used for image search, where you can search for images based on the text contained within them. This is particularly useful for large image libraries, where manual searching would be time-consuming.

Translation

OCR software can be used to extract text from documents in one language and translate it into another language. This is particularly useful for international businesses, where documents need to be translated quickly and accurately.

Summary

Optical character recognition (OCR) is a technology that enables computers to read text from images. OCR along with computer vision is important because it allows machines to understand and interpret the visual world, which is essential for applications such as self-driving cars, robotics, and automated document processing.

IronOCR is a powerful OCR engine that can be used to apply OCR with computer vision to accurately recognize text and perform text extraction from images. It provides a range of methods for finding and extracting text regions, including FindTextRegion, FindMultipleTextRegions, and GetTextRegions. Each method has its own set of parameters that can be used to fine-tune the OCR process and provide high OCR accuracy.

By using IronOCR, you can extract the scanned text from input images quickly and accurately using concurrency and customized configuration, which can save you time and effort when dealing with large volumes of input image data. Whether you are working with scanned documents, photographs, or screenshots, IronOCR can help you unlock the text contained within.

IronOCR offers a free trial to users who want to test the software before making a purchase decision. The license for IronOCR starts from $799 and includes support and updates for one year. With its robust features and reasonable pricing, IronOCR is a great option for anyone looking for a reliable OCR solution with high OCR accuracy.

Questions Fréquemment Posées

Comment puis-je convertir une image en texte avec C# ?

Vous pouvez utiliser les fonctionnalités OCR d'IronOCR pour convertir des images en texte avec C#. En utilisant des méthodes comme Read et ReadAsync, vous pouvez traiter les images pour extraire le texte efficacement.

Quels sont les avantages d'utiliser l'OCR avec la vision par ordinateur?

L'utilisation de l'OCR avec la vision par ordinateur permet une reconnaissance de texte plus précise à partir de mises en page d'images, de polices et de styles complexes. IronOCR utilise l'intelligence artificielle et l'apprentissage automatique pour améliorer l'extraction de texte et automatiser le traitement des données.

Comment améliorer la précision de l'OCR en C# ?

IronOCR offre diverses méthodes pour améliorer la précision de l'OCR, notamment en ajustant les paramètres de configuration, en utilisant la concurrence et en inspectant les objets de résultat pour les niveaux de confiance. Cela aide à affiner le processus d'OCR pour de meilleurs résultats.

Quel est le processus pour extraire du texte de plusieurs régions dans une image ?

Pour extraire du texte de plusieurs régions dans une image avec IronOCR, vous pouvez utiliser la méthode FindMultipleTextRegions. Cette méthode renvoie une liste d'objets CropRectangle indiquant l'emplacement de chaque région de texte.

La technologie OCR peut-elle être utilisée pour la reconnaissance de plaques d'immatriculation ?

Oui, la technologie OCR, telle que celle fournie par IronOCR, peut être appliquée à la reconnaissance de plaques d'immatriculation. En traitant des images de plaques d'immatriculation, IronOCR peut extraire le texte pour diverses applications.

Comment installer IronOCR dans un projet C# ?

Vous pouvez installer IronOCR dans votre projet C# en utilisant la console du gestionnaire de packages NuGet. Exécutez la commande Install-Package IronOcr pour ajouter la bibliothèque à votre projet.

Y a-t-il une version d'essai pour tester une bibliothèque OCR en C# ?

Oui, IronOCR propose une version d'essai gratuite, permettant aux utilisateurs de tester les capacités de la bibliothèque avant de s'engager à acheter une licence.

Quelles options de licence sont disponibles pour une bibliothèque OCR en C# ?

IronOCR propose diverses options de licence à partir de $liteLicense, qui incluent un support et des mises à jour pendant un an, répondant aux différents besoins et budgets des projets.

Kannaopat Udonpant
Ingénieur logiciel
Avant de devenir ingénieur logiciel, Kannapat a obtenu un doctorat en ressources environnementales à l'université d'Hokkaido au Japon. Pendant qu'il poursuivait son diplôme, Kannapat est également devenu membre du laboratoire de robotique de véhicules, qui fait partie du département de bioproduction. En 2022, il a utilisé ses compé...
Lire la suite