Click here to Skip to main content
15,909,566 members
Home / Discussions / C#
   

C#

 
AnswerRe: Avoid space at the Start of the textbox Pin
Eddy Vluggen9-Sep-13 8:15
professionalEddy Vluggen9-Sep-13 8:15 
QuestionHow to check the activated Soundoutput device? Pin
Member 101332676-Sep-13 22:28
Member 101332676-Sep-13 22:28 
AnswerRe: How to check the activated Soundoutput device? Pin
Richard MacCutchan6-Sep-13 23:10
mveRichard MacCutchan6-Sep-13 23:10 
Questionneed online hotel managment project in .net Pin
teena chundavat6-Sep-13 8:34
teena chundavat6-Sep-13 8:34 
AnswerRe: need online hotel managment project in .net Pin
Eddy Vluggen6-Sep-13 8:39
professionalEddy Vluggen6-Sep-13 8:39 
AnswerRe: need online hotel managment project in .net Pin
jschell6-Sep-13 8:40
jschell6-Sep-13 8:40 
AnswerRe: need online hotel managment project in .net Pin
Jason Gleim6-Sep-13 9:06
professionalJason Gleim6-Sep-13 9:06 
GeneralRe: need online hotel managment project in .net Pin
Eddy Vluggen6-Sep-13 13:41
professionalEddy Vluggen6-Sep-13 13:41 
GeneralRe: need online hotel managment project in .net Pin
Mycroft Holmes6-Sep-13 13:56
professionalMycroft Holmes6-Sep-13 13:56 
AnswerRe: need online hotel managment project in .net Pin
Abhinav S6-Sep-13 17:06
Abhinav S6-Sep-13 17:06 
AnswerRe: need online hotel managment project in .net Pin
BillWoodruff6-Sep-13 18:18
professionalBillWoodruff6-Sep-13 18:18 
GeneralRe: need online hotel managment project in .net Pin
Mycroft Holmes6-Sep-13 22:13
professionalMycroft Holmes6-Sep-13 22:13 
GeneralRe: need online hotel managment project in .net Pin
BillWoodruff7-Sep-13 19:31
professionalBillWoodruff7-Sep-13 19:31 
QuestionAt last i got this Tessnet2 ocr to work. Now how do i extract specific text/numbers from an image ? Pin
chocolade6-Sep-13 7:19
chocolade6-Sep-13 7:19 
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 

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.