Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone please help me when i execute program i get this exception
my application working well yesterday but today as i run my app i get this exception
here is my code
C#
public image_reader()
{
  InitializeComponent();
  Prepare_OCREngine(Application .StartupPath+"/Text.jpg");
}

void Prepare_OCREngine(string path)
{
  im = (Bitmap)Bitmap.FromFile(path);

  ocr= new Ocr();
  ocr.SetBitmap(im);.....//// i get exception at this point
}

please help me............. :(

[Edit member="Tadit"]
Added pre tags.
[/Edit]
Posted
v2
Comments
George Jonsson 30-Jun-14 3:53am    
Are you sure the variable im is not null?
Member 10393648 30-Jun-14 5:27am    
im = (Bitmap)Bitmap.FromFile(path);
yes im variable equal this
George Jonsson 30-Jun-14 6:29am    
So what is the Ocr class? Where did you get it?
Member 10393648 30-Jun-14 11:00am    
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 iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.Threading;
using System.Speech;
using System.Speech.Synthesis;
using System.Speech.Recognition;
using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
using WebSupergoo.ABCocr3 ;


namespace Eye_Blind
{
public partial class image_reader : Form
{
/* Tesseract ocrz = new Tesseract("tessdata", "eng", Tesseract.OcrEngineMode.OEM_TESSERACT_ONLY);
Bitmap pic = new Bitmap(270, 100);
( Graphics gfx = Graphics.FromImage(pic);*/


public image_reader()
{
InitializeComponent();
Prepare_OCREngine(Application .StartupPath+"/Text.jpg");
}
public void Prepare_OCREngine(string path)
{

im = (Bitmap)Bitmap.FromFile(path);
// pictureBox_image_reader.Image = Resize_IMG(path);
// Bitmap pictureBox_image_reader = new Bitmap(300, 300);
// Graphics gfx = Graphics.FromImage(pictureBox_image_reader);
ocr= new Ocr();
// ocr.SetBitmap(im);
ocr.SetBitmap(im);

}

private System.Drawing.Image Resize_IMG(string path)
{
throw new NotImplementedException();
Bitmap pic = new Bitmap(270, 100);
Graphics gfx = Graphics.FromImage(pic);
}
Bitmap im;
Ocr ocr;
string path;
string txt;
SpeechSynthesizer reader = new SpeechSynthesizer();
SpeechRecognitionEngine srecognize = new SpeechRecognitionEngine();

private void image_reader_Load(object sender, EventArgs e)
{


}
private void button_main_menu_image_reader_Click(object sender, EventArgs e)
{
if (reader != null)
{
reader.Dispose();
}
main f = new main();
f.Show();
this.Hide();
}

private void button_exit_image_reader_Click(object sender, EventArgs e)
{
if (reader != null)
{
reader.Dispose();
}
Application.Exit();
}

private void button_select_a_file_image_reader_Click(object sender, EventArgs e)
{
richTextBox_image_reader.Text ="";
if (reader != null)
{
reader.Dispose();
}

/* OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Image File";
// dlg.Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff|"
// + "All Graphics Types|*.bmp;*.jpg;*.jpeg;*.png;*.tif;*.tiff";
dlg.Filter = "All Graphics Types|*.bmp;*.jpg;*.jpeg;*.png;*.tif;*.tiff";
if (dlg.ShowDialog() == DialogResult.OK)
{
string wait = "!please wait your file is loading";
reader.Dispose();
reader = new SpeechSynthesizer();
reader.SpeakAsync(wait);
this.pictureBox_image_reader.Image = new Bitmap(dlg.OpenFile());
var image = new Image<bgr, byte="">(new Bitmap(pictureBox_image_reader.Image));
ocrz .Recognize (image);
richTextBox_image_reader .Text =ocrz .GetText();
}*/
try
{
openFileDialog_img.InitialDirectory = Convert.ToString(Application.StartupPath);
if (openFileDialog_img.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string wait = "!please wait your file is loading";
reader.Dispose();
reader = new SpeechSynthesizer();
gggustafson 30-Jun-14 12:37pm    
Never place code in a reply. It will be truncated (as you can see). Rather place your code into the original question using the Improve question link. Also make sure to use the pre tag.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900