Browse our Products

Aspose.OCR for .NET 21.9 - Release Notes

All Features

KeySummaryCategory
OCRNET-392Multithreading supportEnhancement
OCRNET-398Recognize list of imagesEnhancement
OCRNET-397Optimization filtersEnhancement

Enhancements

  • added multithreading support
  • added customer image correction using preprocessing filters
  • added ability for batch recognition for images from the list

Public API and Backwards Incompatible Changes

New API

  • added new property in the RecognitionSettings class: ThreadsCount
  • added new property in the RecognitionSettings class: PreprocessingFilters
  • added new API methods: - PreprocessImage(MemoryStream stream, PreprocessingFilter filters) - PreprocessImage(string fullPath, PreprocessingFilter filters)

Removed APIs

Will be deprecated

Usage Example

using Aspose.OCR;

namespace ProgramOCR
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get API
            AsposeOcr api = new AsposeOcr();

            // Create license
            License lic = new License();

            // Set license 
            lic.SetLicense("Aspose.Total.lic");

            // Get image file for recognize
            string imgage = "img.png";

            // set filters as you need
            PreprocessingFilter filters = new PreprocessingFilter
            {
                 PreprocessingFilter.Binarize(),
                 PreprocessingFilter.Threshold(220),
                 PreprocessingFilter.ToGrayScale(),
                 PreprocessingFilter.Invert(),
                 PreprocessingFilter.Rotate(20),
                 PreprocessingFilter.Resize(3000,3000, Aspose.OCR.Filters.InterpolationFilterType.Box),
                 PreprocessingFilter.Scale(0.5f),
                 PreprocessingFilter.Dilate(),
            };

            // case 1
            // preprocess input image and get the MemoryStream with output image after preprocessing. Then use RecognizeImage.
            MemoryStream ms = api.PreprocessImage("imgs/portug2.png", filters);

            // save image into file system as you need
            using (FileStream file = new FileStream("result.png", FileMode.Create, System.IO.FileAccess.Write))
            {
                ms.WriteTo(file);
            }

            // recognize process
            var res = api.RecognizeImage(ms, new RecognitionSettings());
            Console.WriteLine(res.RecognitionText);

            // case 2 
            // use filters as settings in recognition process
            var res2 = api.RecognizeImage("imgs/portug2.png", new RecognitionSettings { PreprocessingFilters = filters });
            Console.WriteLine(res2.RecognitionText);
			
			// Recognize list of images  
			RecognitionResult[] resultList = api.RecognizeMultipleImages(
                    new List<string>
                    {
                        "imageFirst.png",
                        "imageSecond.jpg"
                    },
                    new RecognitionSettings
                    {
                        DetectAreas = true,
                        LinesFiltration = false,
                        ThreadsCount = 0
                    });
					
			// Set threads number
			 RecognitionResult result = api.RecognizeImage(image, new RecognitionSettings { ThreadsCount = 2 });
        }
    }
}