Forums » .NET » Windows »

Extract text from jpeg image file


Posted Date: 05 Jan 2010      Posted By:: Pankaj     Member Level: Bronze    Member Rank: 0     Points: 1   Responses: 2



How to extract a text from jpeg image file,I have already extracted text from jpeg image file using Modi but i did'nt got the 100% accuracy in the text file.How can we acheive 100 % accuracy.



Responses

#460941    Author: Rakesh Sharma      Member Level: Gold      Member Rank: 284     Date: 05/Jan/2010   Rating: 2 out of 52 out of 5     Points: 2

First of show code how you used it. Then i will suggest you

Regard's
Rakesh Sharma, NEPL


 
#460949    Author: Pankaj      Member Level: Bronze      Member Rank: 0     Date: 05/Jan/2010   Rating: 2 out of 52 out of 5     Points: 2

private void btnConvert_Click(object sender, EventArgs e)
{
CheckFileType(txtFolder.Text);
}
public void CheckFileType(string directoryPath)
{

IEnumerator files = Directory.GetFiles(directoryPath).GetEnumerator();
while (files.MoveNext())
{
//get file extension
string fileExtension = Path.GetExtension(Convert.ToString(files.Current));

//get file name without extenstion
string fileName = Convert.ToString(files.Current).Replace(fileExtension, string.Empty);

//Check for JPG File Format
if (fileExtension == ".jpg" || fileExtension == ".JPG") // or // ImageFormat.Jpeg.ToString()
{
try
{
//OCR Operations ...

MODI.Document md = new MODI.Document();
md.Create(Convert.ToString(files.Current));
//md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
MODI.Image image = (MODI.Image)md.Images[0];

//create text file with the same Image file name
FileStream createFile = new FileStream(fileName + ".txt", FileMode.CreateNew);

//save the image text in the text file
StreamWriter writeFile = new StreamWriter(createFile);
writeFile.Write(image.Layout.Text);
writeFile.Close();
}
catch (Exception)
{
//MessageBox.Show("This Image hasn't a text or has a problem",
//"OCR Notifications",
//MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : RTC API v 1.3
Previous : How to get Screen Resolutions?
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John

Online Members

Ram Prasad
More...
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India