Click here to Skip to main content
15,888,461 members
Home / Discussions / C#
   

C#

 
AnswerRe: At last i got this Tessnet2 ocr to work. Now how do i extract specific text/numbers from an image ? Pin
Eddy Vluggen6-Sep-13 8:42
professionalEddy Vluggen6-Sep-13 8:42 
QuestionWindows Azure or Microsoft Sync Framework Pin
msr_codeproject5-Sep-13 22:30
msr_codeproject5-Sep-13 22:30 
AnswerRe: Windows Azure or Microsoft Sync Framework Pin
Richard MacCutchan5-Sep-13 23:44
mveRichard MacCutchan5-Sep-13 23:44 
AnswerRe: Windows Azure or Microsoft Sync Framework Pin
Jason Gleim6-Sep-13 5:06
professionalJason Gleim6-Sep-13 5:06 
Questionhow can i discover winodws server model manufacturer and serial number details using SNMP Pin
superselector5-Sep-13 18:20
superselector5-Sep-13 18:20 
AnswerRe: how can i discover winodws server model manufacturer and serial number details using SNMP Pin
jschell6-Sep-13 8:42
jschell6-Sep-13 8:42 
AnswerRe: how can i discover winodws server model manufacturer and serial number details using SNMP Pin
Dave Kreskowiak6-Sep-13 14:34
mveDave Kreskowiak6-Sep-13 14:34 
QuestionI cant make this ocr of microsoft to work in c# why ? please help me Pin
chocolade5-Sep-13 13:48
chocolade5-Sep-13 13:48 
Im using the modi lib code and cant make it work.
This is my code:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;

namespace SearchLiveCameras
{
    public partial class Form1 : Form
    {
        StreamWriter w;

        public Form1()
        {
            InitializeComponent();

            w = new StreamWriter(@"d:\ocrErrors.txt");

            // Load Image from File
            Bitmap BWImage = new Bitmap(@"d:\timessquare1.bmp");
            // 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)
        {
            MODI.Document _MODIDocument = new MODI.Document();
            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;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}



First i dont know what are the variables:

tmpPosRect and Bildausschnitt1bpp

Second problem is that im getting an OCR error exception on any image from my over 600 images i have on the hard disk some with chars inside like numbers and text .

The exception is on the line:

_MODIDocument.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, false, false);

Can't figure out why im getting this error.


This is the first method i did yesterday when i first tried the ocr:

C#
private void test()
        {
            MODI.Document md = new MODI.Document();
            md.Create("D:\\trying1.tif");
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, false, false);
            md.Close(false);
            MODI.Image image = (MODI.Image)md.Images[0];
            MODI.Layout layout = image.Layout;
            f = layout.Text;
        }


When trying to use this test() method im getting an error on the line:

md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, false, false);

The exception im getting is: COMException

OCR running error

System.Runtime.InteropServices.COMException was unhandled
HResult=-959967087
Message=OCR running error
Source=""
ErrorCode=-959967087
StackTrace:
at MODI.IDocument.OCR(MiLANGUAGES LangId, Boolean OCROrientImage, Boolean OCRStraightenImage)
at SearchLiveCameras.Form1.test() in d:\C-Sharp\SearchliveCameras\SearchLiveCameras\SearchLiveCameras\Form1.cs:line 33
at SearchLiveCameras.Form1..ctor() in d:\C-Sharp\SearchliveCameras\SearchLiveCameras\SearchLiveCameras\Form1.cs:line 26
at SearchLiveCameras.Program.Main() in d:\C-Sharp\SearchliveCameras\SearchLiveCameras\SearchLiveCameras\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:




Please help me i can't figure out why im getting this exception on any of the images i have.
AnswerRe: I cant make this ocr of microsoft to work in c# why ? please help me Pin
Brisingr Aerowing5-Sep-13 15:18
professionalBrisingr Aerowing5-Sep-13 15:18 
GeneralRe: I cant make this ocr of microsoft to work in c# why ? please help me Pin
chocolade5-Sep-13 16:48
chocolade5-Sep-13 16:48 
GeneralRe: I cant make this ocr of microsoft to work in c# why ? please help me Pin
Mycroft Holmes5-Sep-13 17:57
professionalMycroft Holmes5-Sep-13 17:57 
GeneralRe: I cant make this ocr of microsoft to work in c# why ? please help me Pin
Bernhard Hiller5-Sep-13 21:27
Bernhard Hiller5-Sep-13 21:27 
QuestionEFCaching Provider error "The provider did not return a DbSpatialServices instance." Pin
rafaelcn5-Sep-13 13:41
rafaelcn5-Sep-13 13:41 
SuggestionPeekyPokey - a USB board for h/w programming in .NET Pin
hanzibal25-Sep-13 6:54
hanzibal25-Sep-13 6:54 
GeneralRe: PeekyPokey - a USB board for h/w programming in .NET Pin
Thomas Daniels5-Sep-13 7:12
mentorThomas Daniels5-Sep-13 7:12 
GeneralRe: PeekyPokey - a USB board for h/w programming in .NET Pin
hanzibal25-Sep-13 7:29
hanzibal25-Sep-13 7:29 
Questionupdate a formview that allows paging (dynamic data website)‏ Pin
marounmm5-Sep-13 3:25
marounmm5-Sep-13 3:25 
Questionhow can i start a shell and execute a command and capture output using ganymed-ssh2 c# library Pin
superselector5-Sep-13 1:23
superselector5-Sep-13 1:23 
AnswerRe: how can i start a shell and execute a command and capture output using ganymed-ssh2 c# library Pin
Dave Kreskowiak5-Sep-13 3:05
mveDave Kreskowiak5-Sep-13 3:05 
AnswerRe: how can i start a shell and execute a command and capture output using ganymed-ssh2 c# library Pin
TnTinMn5-Sep-13 3:33
TnTinMn5-Sep-13 3:33 
Questionc# - Windows Services: accessing a network resource Pin
Jeffrey Jefferson4-Sep-13 20:28
Jeffrey Jefferson4-Sep-13 20:28 
AnswerRe: c# - Windows Services: accessing a network resource Pin
Bernhard Hiller4-Sep-13 20:50
Bernhard Hiller4-Sep-13 20:50 
AnswerRe: c# - Windows Services: accessing a network resource Pin
AmitGajjar4-Sep-13 20:56
professionalAmitGajjar4-Sep-13 20:56 
AnswerRe: c# - Windows Services: accessing a network resource Pin
jschell5-Sep-13 9:27
jschell5-Sep-13 9:27 
AnswerRe: c# - Windows Services: accessing a network resource Pin
Jason Gleim6-Sep-13 5:19
professionalJason Gleim6-Sep-13 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.