-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
95 lines (86 loc) · 3.06 KB
/
Copy pathMainForm.cs
File metadata and controls
95 lines (86 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using CommonLibrary.FormAndUser;
using EmguCVLibrary;
using Newtonsoft.Json;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace PresentForm
{
public partial class MainForm : Form
{
TestClass testClass;
ImgDataStruct Imgdata = new ImgDataStruct();
public MainForm()
{
InitializeComponent();
testClass = new TestClass();
propertyGrid1.SelectedObject = para;
propertyGrid2.SelectedObject = Ocr_Para;
}
//定义图像处理参数
EmguCVLibrary.Theories.Initialization_Para para = new EmguCVLibrary.Theories.Initialization_Para()
{
ColorConversion = Emgu.CV.CvEnum.ColorConversion.Bgra2Gray,
Threshold = 100,
ThresholdMaxValue = 255,
ThresholdType = Emgu.CV.CvEnum.ThresholdType.BinaryInv
};
//定义OCR识别参数
EmguCVLibrary.Theories.Ocr_Para Ocr_Para = new EmguCVLibrary.Theories.Ocr_Para()
{
DataPath = Application.StartupPath + @"\OcrData\",
Language = EmguCVLibrary.Theories.LanguageType.英文,
EngineMode = Emgu.CV.OCR.OcrEngineMode.Default,
WhiteList = null,
EnforceLocale = false
};
private void Button1_Click(object sender, EventArgs e)
{
picShow1.FocusPic(new Point(-2948, -566), 2.5f);
}
private void Button2_Click(object sender, EventArgs e)
{
//testClass.IniMapper();
string filepath = "";
// 获取文件名
OpenFileDialog openfile = new OpenFileDialog
{
Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;*.bmp"
};
if (openfile.ShowDialog() == DialogResult.OK)
{
filepath = openfile.FileName;
}
else
{
return;
}
if (Imgdata.SrcImage != null) Imgdata.SrcImage.Dispose();
Imgdata.ReadSrcImg(filepath);//读取Src图像
picShow1.LoadPic(new Bitmap(Imgdata.SrcImage.Bitmap));
}
private void Button3_Click(object sender, EventArgs e)
{
//初始化参数
commonMethod1.Params = JsonConvert.SerializeObject(propertyGrid1.SelectedObject);
commonMethod1.InitialParameter();
//处理图像
commonMethod1.ProcessImge(ref Imgdata);
picShow2.LoadPic(new Bitmap(Imgdata.DstImage.Bitmap));
}
private void Button4_Click(object sender, EventArgs e)
{
//初始化参数
ocR_Recognition1.Params = JsonConvert.SerializeObject(propertyGrid2.SelectedObject);
ocR_Recognition1.InitialParameter();
//OCR识别
string textStr = ocR_Recognition1.GetOCR(ref Imgdata);
MessageBox.Show(textStr);
}
private void Button5_Click(object sender, EventArgs e)
{
ConfigForm Test = new ConfigForm();
Test.ShowDialog();
}
}
}