question

jg555-2716 avatar image
0 Votes"
jg555-2716 asked DanielZhang-MSFT commented

Help with c # programming

Hello, I need help with converting an image to text. I' am using c #.

dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @jg555-2716
In order to understand your requirement more accurately, please explain in detail.
If as cheong00 said, you can refer to the code example provided by techmania in this thread.
Best Regards,
Daniel Zhang


0 Votes 0 ·
cheong00 avatar image
0 Votes"
cheong00 answered cheong00 edited

Unless you're processing images that have original text embedded (say, PS/AI/CDX/etc.), you'll need to employ some OCR technologies to deduce what are the text on the image.

If you're developing for UWP, you may also consider classes from the Windows.Media.Ocr namespace.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AminDodin-1022 avatar image
0 Votes"
AminDodin-1022 answered

In general (Like cheong00 mentioned), the source files could either contain text or contain images of text. There is a solution that can handle both types of source files, which is the LEADTOOLS Document Converter SDK Libraries. (Disclaimer: I am a LEADTOOLS employee).

The following code converts many types of input files and images to text, and automatically invoked OCR if needed:

 private void ConvertToText(string inputFileName)
 {
    var options = new LoadDocumentOptions();
    using (var document = DocumentFactory.LoadFromFile(inputFileName, options))
    {
       using (DocumentConverter documentConverter = new DocumentConverter())
       {
          Leadtools.Ocr.IOcrEngine ocrEngine = Leadtools.Ocr.OcrEngineManager.CreateEngine(Leadtools.Ocr.OcrEngineType.LEAD);
          ocrEngine.Startup(null, null, null, ocrEnginePath);
          documentConverter.SetOcrEngineInstance(ocrEngine, false);
          var outFile = inputFileName + "_converted.txt";
          var format = Leadtools.Document.Writer.DocumentFormat.Text;
          var jobData = DocumentConverterJobs.CreateJobData(document, outFile, format);
          jobData.JobName = "conversion job";
          var job = documentConverter.Jobs.CreateJob(jobData);
          documentConverter.Jobs.RunJob(job);
          MessageBox.Show(job.Errors.Count.ToString() + " " + outFile);
       }
    }
 }

If you would like to try LEADTOOLS, you can download the free evaluation from this page



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.