Question

How can i upload a simple image to www.newocr.com, select a language from the combobox below , click the 'Upload' button and after the 'OCR' button and finnaly getting the string from the source code which stores the string into a id

All programatically. Any help?

Était-ce utile?

La solution

follow this link :

This Can Help You::

OCR reading using C#

http://www.codeproject.com/Questions/157546/C-OCR-How-to-Read-a-single-character-from-image Try This:

Bitmap BWImage = new Bitmap(fileName);
// Lock destination bitmap in memory
System.Drawing.Imaging.BitmapData BWLockImage = BWImage.LockBits(new Rectangle(0, 0, BWImage.Width, BWImage.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, PixelFormat.Format1bppIndexed);

// Copy image data to binary array
int imageSize = BWLockImage.Stride * BWLockImage.Height;
byte[] BWImageBuffer = new byte[imageSize];
Marshal.Copy(BWLockImage.Scan0, BWImageBuffer, 0, imageSize);
DoOCR(BWLockImage, BWImageBuffer, tmpPosRect, false);



// Do the OCR with this function
public string DoOCR(System.Drawing.Imaging.BitmapData BWLockImage, byte[] BWImageBuffer, Rectangle iAusschnitt, bool isNumber)
{
    Bitmap tmpImage = Bildausschnitt1bpp(BWLockImage, BWImageBuffer, iAusschnitt);
    string file = Path.GetTempFileName();
    string tmpResult = "";
    try
    {
        tmpImage.Save(file, ImageFormat.Tiff);
        _MODIDocument.Create(file);
        // Modi parameter erstellen
        _MODIDocument.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, false, false);

        MODI.IImage myImage = (MODI.IImage)_MODIDocument.Images[0]; //first page in file
        MODI.ILayout myLayout = (MODI.ILayout)myImage.Layout;
        tmpResult = myLayout.Text;
    }
    catch
    {
        if (_MODIDocument != null)
        {
            _MODIDocument.Close(false); //Closes the document and deallocates the memory.
            _MODIDocument = null;
        }
        // Bild freigeben
        tmpImage.Dispose();
        tmpImage = null;
        // Garbage Collector ausführen
        GC.Collect();
        // Bilddatei löschen
        File.Delete(file);
    }
    return tmpResult;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top