试用、下载、了解更多产品信息请点击"咨询在线客服"
static void SimpleOCRCalculator(string filePath)
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(filePath);
string[] calculations;
using (IOcrEngine engine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
{
engine.Startup(null, null, null, null);
IOcrPage page = engine.CreatePage(image, OcrImageSharingMode.None);
page.AutoZone(null);
page.Recognize(null);
calculations = new string[page.Zones.Count];
for (int i = 0; i < page.Zones.Count; i++)
{
calculations[i] = page.GetText(i);
}
engine.Shutdown();
}
Dictionary<string, Action<double, double>> operands = new Dictionary<string, Action<double, double>>();
operands.Add("+", new Action<double, double>(delegate(double a, double b) { double ans = a + b; Console.WriteLine("{0} + {1} = {2}", a, b, ans); }));
operands.Add("-", new Action<double, double>(delegate(double a, double b) { double ans = a - b; Console.WriteLine("{0} - {1} = {2}", a, b, ans); }));
operands.Add("x", new Action<double, double>(delegate(double a, double b) { double ans = a * b; Console.WriteLine("{0} * {1} = {2}", a, b, ans); }));
operands.Add("/", new Action<double, double>(delegate(double a, double b) { double ans = a / b; Console.WriteLine("{0} / {1} = {2}", a, b, ans); }));
for (int i = 0; i < calculations.Length; i++)
{
string equation = Regex.Replace(calculations[i], @"\n|\r| ", "");
string[] ops = new string[] { "+", "-", "x", "/" };
for (int j = 0; j < ops.Length; j++)
{
int index = equation.IndexOf(ops[j]);
if (index > 0 && index < equation.Length)
{
string op1 = equation.Substring(0, index);
string op2 = equation.Substring(index + 1);
double arg1 = double.Parse(op1);
double arg2 = double.Parse(op2);
operands[ops[j]](arg1, arg2);
break;
}
}
}
codecs.Dispose();
image.Dispose();
}




CAD.NET是一个在.NET环境中提供解决方案的库, 它支持AutoCAD®DWG,DXF,PLT及其它CAD格式。 | |
CADViewX一款能让应用程序 具有强大CAD图像浏览和打印 功能的图像处理工具。 | ABViewer是一款高质量的2D/3D文档查看器, 可提供专业的浏览、编辑和转换功能, 支持30多种光栅和矢量图形格式。 |
CAD EditorX提供易用 的API和大量的示例方便开发者快速集成。 | CAD VCL Enterprise是一个 高品质多功能且含源码的控件。 |
用于通过Internet、Intranet、 Sharepoint、Office 365 及其他在线 HTML5 启用技术查看DWG和其他CAD文件。 | CAD DLL是一个为开发者打造的 新版本CAD库,可在支持动态链接 库技术的语言中添加CAD功能到应用程序中。 |
