Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Receipts are expected in today's busy world. Whether you purchase groceries or eat out in a restaurant, having a receipt helps inform the amount used and can be used to budget accordingly. Meanwhile, when grocery stores use a receipt scanner to scan receipts, they may gain insight into how their product sells and can be planned according to a sales forecast.
However, receipts are usually hard to read, and sometimes people are unsure what the total adds to. Furthermore, if someone wants to account for their budget, manually entering all data from the receipts is tiresome, considering the amount of items someone can buy. Losing a receipt might mean you are suddenly unsure why the month's budget has been exceeded.
For this problem, budgeting and financial apps have shifted towards utilizing OCR(Optical Character Recognition) to help customers easily track all receipts by scanning them and turning them into digital ones. This, in return, minimizes human error when entering receipts while allowing customers to automate data entry, track expenses, and gain insights into purchasing behavior.
OCR technology extracts data from receipts and digital images by using machine learning algorithms to identify areas of text or numbers. However, it isn't without its faults. If the image has a lot of digital noise, such as blurring and smudging, the returning data often becomes incorrect or muddled. Hence, picking a reliable library that allows developers to debug and optimize methods for reading receipts is essential.
IronOCR is one such library. It offers specialized methods for reading receipts while providing customization for developers who want to filter the image before extracting data. It even allows developers to debug and test whether the data is accurate.
This article will probably discuss real-life examples of how IronOCR processes and filters supermarket receipts to ensure data accuracy.
IronOCR is a C# Library that uses a customized version of the Tesseract OCR engine under the hood. The library offers easy-to-use methods and flexible functionality for all OCR-related needs. In addition to the standard techniques, IronOCR allows developers to fully utilize and customize a customized version of Tesseract to achieve all related tasks. Some of the critical aspects that help with supermarket receipts:
Flexibility and Scalability: The library's flexibility shines through its ability to handle various OCR input formats, including popular image formats like jpg, png, and gif. It also seamlessly integrates with the native "System.Drawings.Objects" from C#, making integration into existing codebases a breeze.
Please remember that IronOCR requires a licensing key for operation. You can get a key as part of a free trial by visiting this link.
//Replace the license key variable with the trial key you obtained
IronOCr.License.LicenseKey = "REPLACE-WITH-YOUR-KEY";
//Replace the license key variable with the trial key you obtained
IronOCr.License.LicenseKey = "REPLACE-WITH-YOUR-KEY";
'Replace the license key variable with the trial key you obtained
IronOCr.License.LicenseKey = "REPLACE-WITH-YOUR-KEY"
After receiving a trial key, set this variable in your project.
Let's assume a scenario in which a developer develops mobile apps that allow customers to scan their receipts with their phones to earn additional points based on total purchases.
The code below showcases how IronOCR takes a stock supermarket receipt and, using the OCR API, extracts all relevant data, such as the product name, line items, prices, and any names.
using IronOcr;
#region
IronOcr.License.LicenseKey = "YOUR-KEY";
#endregion
// Instantiate OCR engine
var ocr = new IronTesseract();
using var inputPhoto = new OcrInput();
inputPhoto.LoadImage("supermarketexample.jpg");
// Perform OCR
OcrResult result = ocr.Read(inputPhoto);
string text = result.Text;
Console.WriteLine(text);
using IronOcr;
#region
IronOcr.License.LicenseKey = "YOUR-KEY";
#endregion
// Instantiate OCR engine
var ocr = new IronTesseract();
using var inputPhoto = new OcrInput();
inputPhoto.LoadImage("supermarketexample.jpg");
// Perform OCR
OcrResult result = ocr.Read(inputPhoto);
string text = result.Text;
Console.WriteLine(text);
Imports IronOcr
#Region ""
IronOcr.License.LicenseKey = "YOUR-KEY"
'#End Region
' Instantiate OCR engine
Dim ocr = New IronTesseract()
Dim inputPhoto = New OcrInput()
inputPhoto.LoadImage("supermarketexample.jpg")
' Perform OCR
Dim result As OcrResult = ocr.Read(inputPhoto)
Dim text As String = result.Text
Console.WriteLine(text)
Note that the console output above prints out the product and line items in a single line. The method operates in page segmentation mode, ignoring the blocks of lines that act as dividers in the receipt.
The receipt above is a refined image and is not typical of a customer just taking a photo of their receipt. When dealing with real-life examples, we would have to verify the extracted data's confidence to ensure a threshold where the data is considered invalid to ensure consistency in your application.
IronOCR has a built-in property called `confidence` that allows developers to verify the accuracy of the extracted data.
OcrResult result = ocr.Read(inputPhoto);
string text = result.Text;
Console.WriteLine(text);
Console.WriteLine(result.Confidence);
OcrResult result = ocr.Read(inputPhoto);
string text = result.Text;
Console.WriteLine(text);
Console.WriteLine(result.Confidence);
Dim result As OcrResult = ocr.Read(inputPhoto)
Dim text As String = result.Text
Console.WriteLine(text)
Console.WriteLine(result.Confidence)
This code is identical to the one above. The main difference is that it also prints out the confidence level.
The `Confidence` property in the `OcrResult` is a crucial floating-point number representing the OCR's statistical accuracy confidence. This value is calculated as an average of every character. A lower value indicates potential issues, such as a blurry passport image or additional information. The highest confidence level is represented by 1, while the lowest is represented by 0. The higher the value, the more we can safely assume the extracted data is accurate and precise.
As you can see, the confidence level, even on a stock image, is only 75. In real-life scenarios, the confidence might even be lower due to digital noise.
As shown above, aside from rejecting data with low confidence, IronOCR also allows developers to clear and filter out the noise before inputting it as an image, ensuring high accuracy in data extraction. Here are some configurations we can do before we use the duplicate supermarket receipts.
inputPhoto.DeNoise();
inputPhoto.ToGrayScale();
inputPhoto.DeNoise();
inputPhoto.ToGrayScale();
inputPhoto.DeNoise()
inputPhoto.ToGrayScale()
The first method, "DeNoise," flattens the alpha channel to white, which might increase the accuracy of the photo as digital photos have a lot of expected noise.
The second method, "ToGrayScale," although not strictly a way to improve accuracy, does help the efficiency of batch processing receipts by turning every pixel shade into a greyscale.
Along with these methods, developers should test and fine-tune the settings available using IronOCR to filter on the desired criteria for extracted data from supermarket receipts.
Along with automation, Receipt OCR is a powerful technology that can help businesses extract valuable insights from receipt data. It is also a powerful tool for individuals to help budget their expenses and identify areas of interest personally. Not only that, but OCR technology can also double as a way to enhance the prevention of tampered or altered receipts by checking the transaction numbers on the receipt.
As such, picking the proper receipt OCR solution is crucial and virtual for accuracy, speed, and scalability. IronOCR incorporates all that and is easy to integrate with existing platforms, giving developers an advantage regarding receipt scanning.
You can use IronOCR's trial license if developers are interested.
9 .NET API products for your office documents