Change to make OCR work on 64 bit Windows, now using a small 32-bit exe to do the OCR'ing. (untested)

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2078 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-21 13:31:08 +00:00
parent 0d40ebe346
commit abaf473d83
8 changed files with 934 additions and 16 deletions

View file

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Text;
using GreenshotOCR;
using Greenshot.Interop;
using System.IO;
namespace GreenshotOCRCommand {
public class Program {
private const string USAGE = "<-c> | <path to image.bmp> [language] [orientimage] [straightenImage]";
public static int Main(string[] args) {
// to test
//args = new string[] { @"C:\localdata\test.bmp"};
if (args.Length == 0) {
Console.WriteLine(USAGE);
return -1;
}
string filename = args[0];
ModiLanguage language = ModiLanguage.ENGLISH;
if (args.Length >= 2) {
language = (ModiLanguage)Enum.Parse(typeof(ModiLanguage), args[1]);
}
bool orientimage = true;
if (args.Length >= 3) {
orientimage = bool.Parse(args[2]);
}
bool straightenImage = true;
if (args.Length >= 4) {
straightenImage = bool.Parse(args[3]);
}
try {
if (File.Exists(filename) || "-c".Equals(filename)) {
using (ModiDocu modiDocument = COMWrapper.GetOrCreateInstance<ModiDocu>()) {
if (modiDocument == null) {
Console.WriteLine("MODI not installed");
return -2;
}
if ("-c".Equals(filename)) {
return 0;
}
modiDocument.Create(args[1]);
modiDocument.OCR(language, orientimage, straightenImage);
IImage modiImage = modiDocument.Images[0];
ILayout layout = modiImage.Layout;
Console.WriteLine(layout.Text);
modiDocument.Close(false);
return 0;
}
}
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
return -1;
}
}
}