Commit a291af67 张东亮

OCR识别结果放入条码一起

1 个父辈 01fa4104
...@@ -156,7 +156,7 @@ namespace BLL ...@@ -156,7 +156,7 @@ namespace BLL
//保存需要识别ocr的区域 //保存需要识别ocr的区域
CurrntBitmap?.Save(@"ocr.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); CurrntBitmap?.Save(@"ocr.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
regOcrCodes = OcrRecognize("..\\ocr.jpg"); regOcrCodes = OcrRecognize("..\\ocr.jpg");
LogNet.log.Info($"OCR 识别结果:{string.Join(",", regOcrCodes)}"); LogNet.log.Info($"OCR 识别结果:{regOcrCodes}");
} }
//优先匹配 //优先匹配
...@@ -396,7 +396,7 @@ namespace BLL ...@@ -396,7 +396,7 @@ namespace BLL
isCodeUsed = new bool[code.Count]; isCodeUsed = new bool[code.Count];
int matchCount = 0; int matchCount = 0;
bool isMatch = false; bool isMatch = false;
List<MaterialCodeOCR> ocrlist = new List<MaterialCodeOCR>(); List<MaterialCode> ocrlist = new List<MaterialCode>();
List<BarcodeInfo> ocrcode = new List<BarcodeInfo>(); List<BarcodeInfo> ocrcode = new List<BarcodeInfo>();
//命中规则的条码索引 //命中规则的条码索引
List<int> MatchCodeIndex = new List<int>(); List<int> MatchCodeIndex = new List<int>();
...@@ -424,14 +424,6 @@ namespace BLL ...@@ -424,14 +424,6 @@ namespace BLL
} }
} }
//var ocrmatch = mateTemp[index].Ocr.FindAll(o => o.CodeID == codeMatch[0].CodeID);
//foreach (var o in ocrmatch)
//{
// ocrlist.Add(o);
// ocrcode.Add(code[j]);
//}
//break;
} }
} }
...@@ -442,26 +434,21 @@ namespace BLL ...@@ -442,26 +434,21 @@ namespace BLL
} }
if (Config.Func_EnabledOCR) if (Config.Func_EnabledOCR)
{ {
foreach (var o in mateTemp[index].Ocr) List<MaterialCodeMatch> codeMatch = mateTemp[index].Match.FindAll(match => match.CodeType.Equals(Setting_Str.OCR));
{
ocrlist.Add(o); int ocrCount = codeMatch.Count;
//ocrcode.Add(code[j]); if (ocrCount > 0)
}
int ocrCount = ocrlist.Count;
if (ocrlist.Count > 0)
{ {
LogNet.log.Info($"{mateTemp[index].Name} 开始OCR匹配 [{ocrCount}]"); LogNet.log.Info($"{mateTemp[index].Name} 开始OCR匹配 [{ocrCount}]");
for (int i = 0; i < ocrlist.Count; i++) // for (int i = 0; i < ocrlist.Count; i++)
{ {
List<MaterialCodeMatch> codeMatch = mateTemp[index].Match.FindAll(match => match.CodeID == ocrlist[i].ID);
foreach (string regCode in regOcrCodes.Split(';')) foreach (string regCode in regOcrCodes.Split(';'))
{ {
if (string.IsNullOrEmpty(regCode)) continue; if (string.IsNullOrEmpty(regCode)) continue;
var x = new BarcodeInfo() { Text = regCode, CodeType = "OCR" }; var x = new BarcodeInfo() { Text = regCode, CodeType = Setting_Str.OCR };
Dictionary<string, string> matchKey = CodeMatch(x, codeMatch); Dictionary<string, string> matchKey = CodeMatch(x, codeMatch);
if (matchKey != null) if (matchKey != null)
{ {
foreach (string key in matchKey.Keys) foreach (string key in matchKey.Keys)
{ {
if (!keyword.ContainsKey(key)) if (!keyword.ContainsKey(key))
......
...@@ -9,5 +9,6 @@ namespace BLL ...@@ -9,5 +9,6 @@ namespace BLL
{ {
public class Setting_Str public class Setting_Str
{ {
public const string OCR = "OCR";
} }
} }
...@@ -67,11 +67,12 @@ namespace SmartScan ...@@ -67,11 +67,12 @@ namespace SmartScan
this.facePanel1.Controls.Add(this.BtnAddMate); this.facePanel1.Controls.Add(this.BtnAddMate);
this.facePanel1.Controls.Add(this.LstMate); this.facePanel1.Controls.Add(this.LstMate);
this.facePanel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.facePanel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.facePanel1.Location = new System.Drawing.Point(3, 3); this.facePanel1.Location = new System.Drawing.Point(4, 4);
this.facePanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.facePanel1.Name = "facePanel1"; this.facePanel1.Name = "facePanel1";
this.facePanel1.Padding = new System.Windows.Forms.Padding(3); this.facePanel1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.facePanel1.ShowText = false; this.facePanel1.ShowText = false;
this.facePanel1.Size = new System.Drawing.Size(880, 429); this.facePanel1.Size = new System.Drawing.Size(1173, 536);
this.facePanel1.TabIndex = 1; this.facePanel1.TabIndex = 1;
this.facePanel1.Text = "facePanel1"; this.facePanel1.Text = "facePanel1";
this.facePanel1.TitleFont = new System.Drawing.Font("宋体", 12F); this.facePanel1.TitleFont = new System.Drawing.Font("宋体", 12F);
...@@ -84,10 +85,11 @@ namespace SmartScan ...@@ -84,10 +85,11 @@ namespace SmartScan
this.BtnExtractCode.BorderWidth = 2; this.BtnExtractCode.BorderWidth = 2;
this.BtnExtractCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnExtractCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnExtractCode.HoldPress = false; this.BtnExtractCode.HoldPress = false;
this.BtnExtractCode.Location = new System.Drawing.Point(182, 327); this.BtnExtractCode.Location = new System.Drawing.Point(243, 409);
this.BtnExtractCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnExtractCode.Name = "BtnExtractCode"; this.BtnExtractCode.Name = "BtnExtractCode";
this.BtnExtractCode.Padding = new System.Windows.Forms.Padding(3); this.BtnExtractCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnExtractCode.Size = new System.Drawing.Size(346, 45); this.BtnExtractCode.Size = new System.Drawing.Size(461, 56);
this.BtnExtractCode.TabIndex = 17; this.BtnExtractCode.TabIndex = 17;
this.BtnExtractCode.Text = "条码提取"; this.BtnExtractCode.Text = "条码提取";
this.BtnExtractCode.Click += new System.EventHandler(this.BtnExtractCode_Click); this.BtnExtractCode.Click += new System.EventHandler(this.BtnExtractCode_Click);
...@@ -100,10 +102,11 @@ namespace SmartScan ...@@ -100,10 +102,11 @@ namespace SmartScan
this.BtnOcrCode.BorderWidth = 2; this.BtnOcrCode.BorderWidth = 2;
this.BtnOcrCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnOcrCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOcrCode.HoldPress = false; this.BtnOcrCode.HoldPress = false;
this.BtnOcrCode.Location = new System.Drawing.Point(182, 378); this.BtnOcrCode.Location = new System.Drawing.Point(243, 473);
this.BtnOcrCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOcrCode.Name = "BtnOcrCode"; this.BtnOcrCode.Name = "BtnOcrCode";
this.BtnOcrCode.Padding = new System.Windows.Forms.Padding(3); this.BtnOcrCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOcrCode.Size = new System.Drawing.Size(170, 45); this.BtnOcrCode.Size = new System.Drawing.Size(227, 56);
this.BtnOcrCode.TabIndex = 16; this.BtnOcrCode.TabIndex = 16;
this.BtnOcrCode.Text = "OCR"; this.BtnOcrCode.Text = "OCR";
this.BtnOcrCode.Click += new System.EventHandler(this.BtnOcrCode_Click); this.BtnOcrCode.Click += new System.EventHandler(this.BtnOcrCode_Click);
...@@ -116,10 +119,11 @@ namespace SmartScan ...@@ -116,10 +119,11 @@ namespace SmartScan
this.BtnPrimaryCode.BorderWidth = 2; this.BtnPrimaryCode.BorderWidth = 2;
this.BtnPrimaryCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnPrimaryCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnPrimaryCode.HoldPress = false; this.BtnPrimaryCode.HoldPress = false;
this.BtnPrimaryCode.Location = new System.Drawing.Point(358, 378); this.BtnPrimaryCode.Location = new System.Drawing.Point(477, 472);
this.BtnPrimaryCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnPrimaryCode.Name = "BtnPrimaryCode"; this.BtnPrimaryCode.Name = "BtnPrimaryCode";
this.BtnPrimaryCode.Padding = new System.Windows.Forms.Padding(3); this.BtnPrimaryCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnPrimaryCode.Size = new System.Drawing.Size(170, 45); this.BtnPrimaryCode.Size = new System.Drawing.Size(227, 56);
this.BtnPrimaryCode.TabIndex = 15; this.BtnPrimaryCode.TabIndex = 15;
this.BtnPrimaryCode.Text = "特征码"; this.BtnPrimaryCode.Text = "特征码";
this.BtnPrimaryCode.Click += new System.EventHandler(this.BtnPrimaryCode_Click); this.BtnPrimaryCode.Click += new System.EventHandler(this.BtnPrimaryCode_Click);
...@@ -133,10 +137,11 @@ namespace SmartScan ...@@ -133,10 +137,11 @@ namespace SmartScan
this.ImgShow.BorderStyle = Asa.FaceControl.ControlShape.Rectangle; this.ImgShow.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.ImgShow.BorderWidth = 2; this.ImgShow.BorderWidth = 2;
this.ImgShow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.ImgShow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.ImgShow.Location = new System.Drawing.Point(534, 6); this.ImgShow.Location = new System.Drawing.Point(712, 8);
this.ImgShow.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ImgShow.Name = "ImgShow"; this.ImgShow.Name = "ImgShow";
this.ImgShow.Padding = new System.Windows.Forms.Padding(3); this.ImgShow.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ImgShow.Size = new System.Drawing.Size(340, 417); this.ImgShow.Size = new System.Drawing.Size(453, 521);
this.ImgShow.TabIndex = 14; this.ImgShow.TabIndex = 14;
this.ImgShow.Text = "facePictureBox1"; this.ImgShow.Text = "facePictureBox1";
// //
...@@ -150,14 +155,13 @@ namespace SmartScan ...@@ -150,14 +155,13 @@ namespace SmartScan
this.LstCode.Font = new System.Drawing.Font("宋体", 9F); this.LstCode.Font = new System.Drawing.Font("宋体", 9F);
this.LstCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.LstCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LstCode.ItemHeight = 40; this.LstCode.ItemHeight = 40;
this.LstCode.Location = new System.Drawing.Point(182, 108); this.LstCode.Location = new System.Drawing.Point(243, 135);
this.LstCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstCode.Name = "LstCode"; this.LstCode.Name = "LstCode";
this.LstCode.Padding = new System.Windows.Forms.Padding(3); this.LstCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstCode.SelectedIndex = -1; this.LstCode.SelectedIndex = -1;
this.LstCode.Text = ""; this.LstCode.Size = new System.Drawing.Size(461, 266);
this.LstCode.Size = new System.Drawing.Size(346, 213);
this.LstCode.TabIndex = 13; this.LstCode.TabIndex = 13;
this.LstCode.Text = "faceListBox1";
this.LstCode.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; this.LstCode.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
this.LstCode.SelectedIndexChanged += new System.EventHandler(this.LstCode_SelectedIndexChanged); this.LstCode.SelectedIndexChanged += new System.EventHandler(this.LstCode_SelectedIndexChanged);
// //
...@@ -168,10 +172,11 @@ namespace SmartScan ...@@ -168,10 +172,11 @@ namespace SmartScan
this.BtnScanCode.BorderWidth = 2; this.BtnScanCode.BorderWidth = 2;
this.BtnScanCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnScanCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnScanCode.HoldPress = false; this.BtnScanCode.HoldPress = false;
this.BtnScanCode.Location = new System.Drawing.Point(182, 57); this.BtnScanCode.Location = new System.Drawing.Point(243, 71);
this.BtnScanCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnScanCode.Name = "BtnScanCode"; this.BtnScanCode.Name = "BtnScanCode";
this.BtnScanCode.Padding = new System.Windows.Forms.Padding(3); this.BtnScanCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnScanCode.Size = new System.Drawing.Size(346, 45); this.BtnScanCode.Size = new System.Drawing.Size(461, 56);
this.BtnScanCode.TabIndex = 12; this.BtnScanCode.TabIndex = 12;
this.BtnScanCode.Text = "条码识别"; this.BtnScanCode.Text = "条码识别";
this.BtnScanCode.Click += new System.EventHandler(this.BtnScanCode_Click); this.BtnScanCode.Click += new System.EventHandler(this.BtnScanCode_Click);
...@@ -183,10 +188,11 @@ namespace SmartScan ...@@ -183,10 +188,11 @@ namespace SmartScan
this.BtnLocalImage.BorderWidth = 2; this.BtnLocalImage.BorderWidth = 2;
this.BtnLocalImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnLocalImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnLocalImage.HoldPress = false; this.BtnLocalImage.HoldPress = false;
this.BtnLocalImage.Location = new System.Drawing.Point(358, 6); this.BtnLocalImage.Location = new System.Drawing.Point(477, 8);
this.BtnLocalImage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnLocalImage.Name = "BtnLocalImage"; this.BtnLocalImage.Name = "BtnLocalImage";
this.BtnLocalImage.Padding = new System.Windows.Forms.Padding(3); this.BtnLocalImage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnLocalImage.Size = new System.Drawing.Size(170, 45); this.BtnLocalImage.Size = new System.Drawing.Size(227, 56);
this.BtnLocalImage.TabIndex = 11; this.BtnLocalImage.TabIndex = 11;
this.BtnLocalImage.Text = "本地图像"; this.BtnLocalImage.Text = "本地图像";
this.BtnLocalImage.Click += new System.EventHandler(this.BtnLocalImage_Click); this.BtnLocalImage.Click += new System.EventHandler(this.BtnLocalImage_Click);
...@@ -198,10 +204,11 @@ namespace SmartScan ...@@ -198,10 +204,11 @@ namespace SmartScan
this.BtnCameraImage.BorderWidth = 2; this.BtnCameraImage.BorderWidth = 2;
this.BtnCameraImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnCameraImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnCameraImage.HoldPress = false; this.BtnCameraImage.HoldPress = false;
this.BtnCameraImage.Location = new System.Drawing.Point(182, 6); this.BtnCameraImage.Location = new System.Drawing.Point(243, 8);
this.BtnCameraImage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCameraImage.Name = "BtnCameraImage"; this.BtnCameraImage.Name = "BtnCameraImage";
this.BtnCameraImage.Padding = new System.Windows.Forms.Padding(3); this.BtnCameraImage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCameraImage.Size = new System.Drawing.Size(170, 45); this.BtnCameraImage.Size = new System.Drawing.Size(227, 56);
this.BtnCameraImage.TabIndex = 10; this.BtnCameraImage.TabIndex = 10;
this.BtnCameraImage.Text = "相机图像"; this.BtnCameraImage.Text = "相机图像";
this.BtnCameraImage.Click += new System.EventHandler(this.BtnCameraImage_Click); this.BtnCameraImage.Click += new System.EventHandler(this.BtnCameraImage_Click);
...@@ -213,10 +220,11 @@ namespace SmartScan ...@@ -213,10 +220,11 @@ namespace SmartScan
this.BtnCloseLight.BorderWidth = 2; this.BtnCloseLight.BorderWidth = 2;
this.BtnCloseLight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnCloseLight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnCloseLight.HoldPress = false; this.BtnCloseLight.HoldPress = false;
this.BtnCloseLight.Location = new System.Drawing.Point(6, 363); this.BtnCloseLight.Location = new System.Drawing.Point(8, 454);
this.BtnCloseLight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCloseLight.Name = "BtnCloseLight"; this.BtnCloseLight.Name = "BtnCloseLight";
this.BtnCloseLight.Padding = new System.Windows.Forms.Padding(3); this.BtnCloseLight.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCloseLight.Size = new System.Drawing.Size(170, 45); this.BtnCloseLight.Size = new System.Drawing.Size(227, 56);
this.BtnCloseLight.TabIndex = 9; this.BtnCloseLight.TabIndex = 9;
this.BtnCloseLight.Text = "关闭"; this.BtnCloseLight.Text = "关闭";
this.BtnCloseLight.Click += new System.EventHandler(this.BtnCloseLight_Click); this.BtnCloseLight.Click += new System.EventHandler(this.BtnCloseLight_Click);
...@@ -228,10 +236,11 @@ namespace SmartScan ...@@ -228,10 +236,11 @@ namespace SmartScan
this.BtnOpenLight.BorderWidth = 2; this.BtnOpenLight.BorderWidth = 2;
this.BtnOpenLight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnOpenLight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOpenLight.HoldPress = false; this.BtnOpenLight.HoldPress = false;
this.BtnOpenLight.Location = new System.Drawing.Point(6, 312); this.BtnOpenLight.Location = new System.Drawing.Point(8, 390);
this.BtnOpenLight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOpenLight.Name = "BtnOpenLight"; this.BtnOpenLight.Name = "BtnOpenLight";
this.BtnOpenLight.Padding = new System.Windows.Forms.Padding(3); this.BtnOpenLight.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOpenLight.Size = new System.Drawing.Size(170, 45); this.BtnOpenLight.Size = new System.Drawing.Size(227, 56);
this.BtnOpenLight.TabIndex = 8; this.BtnOpenLight.TabIndex = 8;
this.BtnOpenLight.Text = "打开光源"; this.BtnOpenLight.Text = "打开光源";
this.BtnOpenLight.Click += new System.EventHandler(this.BtnOpenLight_Click); this.BtnOpenLight.Click += new System.EventHandler(this.BtnOpenLight_Click);
...@@ -243,10 +252,11 @@ namespace SmartScan ...@@ -243,10 +252,11 @@ namespace SmartScan
this.BtnRenameMate.BorderWidth = 2; this.BtnRenameMate.BorderWidth = 2;
this.BtnRenameMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnRenameMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnRenameMate.HoldPress = false; this.BtnRenameMate.HoldPress = false;
this.BtnRenameMate.Location = new System.Drawing.Point(6, 261); this.BtnRenameMate.Location = new System.Drawing.Point(8, 326);
this.BtnRenameMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnRenameMate.Name = "BtnRenameMate"; this.BtnRenameMate.Name = "BtnRenameMate";
this.BtnRenameMate.Padding = new System.Windows.Forms.Padding(3); this.BtnRenameMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnRenameMate.Size = new System.Drawing.Size(170, 45); this.BtnRenameMate.Size = new System.Drawing.Size(227, 56);
this.BtnRenameMate.TabIndex = 7; this.BtnRenameMate.TabIndex = 7;
this.BtnRenameMate.Text = "重命名"; this.BtnRenameMate.Text = "重命名";
this.BtnRenameMate.Click += new System.EventHandler(this.BtnRenameMate_Click); this.BtnRenameMate.Click += new System.EventHandler(this.BtnRenameMate_Click);
...@@ -258,10 +268,11 @@ namespace SmartScan ...@@ -258,10 +268,11 @@ namespace SmartScan
this.BtnDelMate.BorderWidth = 2; this.BtnDelMate.BorderWidth = 2;
this.BtnDelMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnDelMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnDelMate.HoldPress = false; this.BtnDelMate.HoldPress = false;
this.BtnDelMate.Location = new System.Drawing.Point(6, 210); this.BtnDelMate.Location = new System.Drawing.Point(8, 262);
this.BtnDelMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnDelMate.Name = "BtnDelMate"; this.BtnDelMate.Name = "BtnDelMate";
this.BtnDelMate.Padding = new System.Windows.Forms.Padding(3); this.BtnDelMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnDelMate.Size = new System.Drawing.Size(170, 45); this.BtnDelMate.Size = new System.Drawing.Size(227, 56);
this.BtnDelMate.TabIndex = 6; this.BtnDelMate.TabIndex = 6;
this.BtnDelMate.Text = "删除标签"; this.BtnDelMate.Text = "删除标签";
this.BtnDelMate.Click += new System.EventHandler(this.BtnDelMate_Click); this.BtnDelMate.Click += new System.EventHandler(this.BtnDelMate_Click);
...@@ -273,10 +284,11 @@ namespace SmartScan ...@@ -273,10 +284,11 @@ namespace SmartScan
this.BtnAddMate.BorderWidth = 2; this.BtnAddMate.BorderWidth = 2;
this.BtnAddMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.BtnAddMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnAddMate.HoldPress = false; this.BtnAddMate.HoldPress = false;
this.BtnAddMate.Location = new System.Drawing.Point(6, 159); this.BtnAddMate.Location = new System.Drawing.Point(8, 199);
this.BtnAddMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnAddMate.Name = "BtnAddMate"; this.BtnAddMate.Name = "BtnAddMate";
this.BtnAddMate.Padding = new System.Windows.Forms.Padding(3); this.BtnAddMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnAddMate.Size = new System.Drawing.Size(170, 45); this.BtnAddMate.Size = new System.Drawing.Size(227, 56);
this.BtnAddMate.TabIndex = 5; this.BtnAddMate.TabIndex = 5;
this.BtnAddMate.Text = "新建标签"; this.BtnAddMate.Text = "新建标签";
this.BtnAddMate.Click += new System.EventHandler(this.BtnAddMate_Click); this.BtnAddMate.Click += new System.EventHandler(this.BtnAddMate_Click);
...@@ -287,23 +299,23 @@ namespace SmartScan ...@@ -287,23 +299,23 @@ namespace SmartScan
this.LstMate.BorderStyle = Asa.FaceControl.ControlShape.Rectangle; this.LstMate.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.LstMate.BorderWidth = 2; this.LstMate.BorderWidth = 2;
this.LstMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.LstMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LstMate.Location = new System.Drawing.Point(6, 6); this.LstMate.Location = new System.Drawing.Point(8, 8);
this.LstMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstMate.Name = "LstMate"; this.LstMate.Name = "LstMate";
this.LstMate.Padding = new System.Windows.Forms.Padding(3); this.LstMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstMate.SelectedIndex = -1; this.LstMate.SelectedIndex = -1;
this.LstMate.Text = ""; this.LstMate.Size = new System.Drawing.Size(227, 184);
this.LstMate.Size = new System.Drawing.Size(170, 147);
this.LstMate.TabIndex = 4; this.LstMate.TabIndex = 4;
this.LstMate.Text = "faceListBox1";
this.LstMate.SelectedIndexChanged += new System.EventHandler(this.LstMate_SelectedIndexChanged); this.LstMate.SelectedIndexChanged += new System.EventHandler(this.LstMate_SelectedIndexChanged);
// //
// UsrMaterialTemplate // UsrMaterialTemplate
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.facePanel1); this.Controls.Add(this.facePanel1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "UsrMaterialTemplate"; this.Name = "UsrMaterialTemplate";
this.Size = new System.Drawing.Size(917, 466); this.Size = new System.Drawing.Size(1223, 582);
this.facePanel1.ResumeLayout(false); this.facePanel1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
......
...@@ -56,10 +56,11 @@ namespace SmartScan ...@@ -56,10 +56,11 @@ namespace SmartScan
{ {
List<string> item = new(); List<string> item = new();
for (int i = 0; i < mateCopy[mateIndex].Code.Count; i++) for (int i = 0; i < mateCopy[mateIndex].Code.Count; i++)
{
item.Add(FormatCode(i)); item.Add(FormatCode(i));
}
return item.ToArray(); return item.ToArray();
} }
private string FormatCode(int index) private string FormatCode(int index)
{ {
MaterialCode code = mateCopy[mateIndex].Code[index]; MaterialCode code = mateCopy[mateIndex].Code[index];
...@@ -70,9 +71,16 @@ namespace SmartScan ...@@ -70,9 +71,16 @@ namespace SmartScan
string s = string.Format("({0}) ", index + 1) + text; string s = string.Format("({0}) ", index + 1) + text;
if (code.ID == mateCopy[mateIndex].PrimaryCode) if (code.ID == mateCopy[mateIndex].PrimaryCode)
s += " <P>"; s += " <P>";
//条码的关键字 //条码的关键字
List<string> arr = new(); List<string> arr = new();
List<MaterialCodeMatch> math = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == mateCopy[mateIndex].Code[index].ID);
for (int j = 0; j < math.Count; j++)
arr.Add(math[j].Keyword);
if (arr.Count > 0)
s += " <OCR>";
arr = new();
for (int i = 0; i < mateCopy[mateIndex].Match.Count; i++) for (int i = 0; i < mateCopy[mateIndex].Match.Count; i++)
{ {
if (code.ID == mateCopy[mateIndex].Match[i].CodeID) if (code.ID == mateCopy[mateIndex].Match[i].CodeID)
...@@ -82,16 +90,27 @@ namespace SmartScan ...@@ -82,16 +90,27 @@ namespace SmartScan
s += " [" + string.Join(",", arr) + "]"; s += " [" + string.Join(",", arr) + "]";
//OCR的关键字 //OCR的关键字
arr = new(); //arr = new();
List<MaterialCodeOCR> codeOcr = mateCopy[mateIndex].Ocr.FindAll(s => s.CodeID == code.ID); //List<MaterialCode> codeOcr = mateCopy[mateIndex].Code.FindAll(s => s.CodeType.Equals(Setting_Str.OCR));
for (int i = 0; i < codeOcr.Count; i++) //for (int i = 0; i < codeOcr.Count; i++)
{ //{
List<MaterialCodeMatch> math = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == codeOcr[i].ID); // List<MaterialCodeMatch> math = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == codeOcr[i].ID);
for (int j = 0; j < math.Count; j++) // for (int j = 0; j < math.Count; j++)
arr.Add(math[j].Keyword); // arr.Add(math[j].Keyword);
} //}
if (arr.Count > 0) //if (arr.Count > 0)
s += " [OCR:" + string.Join(",", arr) + "]"; // s += " [OCR"+ "]";// + string.Join(",", arr) +
//arr = new();
//List<MaterialCodeOCR> codeOcr = mateCopy[mateIndex].Ocr.FindAll(s => s.CodeID == code.ID);
//for (int i = 0; i < codeOcr.Count; i++)
//{
// List<MaterialCodeMatch> math = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == codeOcr[i].ID);
// for (int j = 0; j < math.Count; j++)
// arr.Add(math[j].Keyword);
//}
//if (arr.Count > 0)
// s += " [OCR:" + string.Join(",", arr) + "]";
return s; return s;
} }
...@@ -119,8 +138,8 @@ namespace SmartScan ...@@ -119,8 +138,8 @@ namespace SmartScan
if (dr != DialogResult.OK) return; if (dr != DialogResult.OK) return;
if (string.IsNullOrWhiteSpace(input.InputValue)) return; if (string.IsNullOrWhiteSpace(input.InputValue)) return;
//检查是否有已存在的名称 //检查是否有已存在的名称
var find= mateCopy.Find(s => s.Name.Equals(input.InputValue)); var find = mateCopy.Find(s => s.Name.Equals(input.InputValue));
if(find !=null) if (find != null)
{ {
string hint = Asa.FaceControl.Language.Dialog("KeyExists"); string hint = Asa.FaceControl.Language.Dialog("KeyExists");
hint = hint.Replace("[name]", input.InputValue); hint = hint.Replace("[name]", input.InputValue);
...@@ -226,9 +245,9 @@ namespace SmartScan ...@@ -226,9 +245,9 @@ namespace SmartScan
List<CameraVisionLib.Model.BarcodeInfo> info = Common.cameraVision.GetBarCode(bmp); List<CameraVisionLib.Model.BarcodeInfo> info = Common.cameraVision.GetBarCode(bmp);
LstCode.Items.Clear(); LstCode.Items.Clear();
ImgShow.CodeCenterClear(); ImgShow.CodeCenterClear();
mateCopy[mateIndex].Match.Clear();
mateCopy[mateIndex].Code.Clear(); mateCopy[mateIndex].Code.Clear();
mateCopy[mateIndex].Ocr.Clear(); mateCopy[mateIndex].Ocr.Clear();
mateCopy[mateIndex].Match.Clear();
mateCopy[mateIndex].PrimaryCode = -1; mateCopy[mateIndex].PrimaryCode = -1;
mateCopy[mateIndex].State = TemplateState.Unsaved; mateCopy[mateIndex].State = TemplateState.Unsaved;
Common.mateMaxCodeID = info.Count; Common.mateMaxCodeID = info.Count;
...@@ -271,7 +290,7 @@ namespace SmartScan ...@@ -271,7 +290,7 @@ namespace SmartScan
if (codeIndex == -1) return; if (codeIndex == -1) return;
MaterialCode code = mateCopy[mateIndex].Code[codeIndex]; MaterialCode code = mateCopy[mateIndex].Code[codeIndex];
List <MaterialCodeMatch> match = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == code.ID); List<MaterialCodeMatch> match = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == code.ID);
FrmCodeExtract frm = new(code.Text, code.ID, code.CodeType, match); FrmCodeExtract frm = new(code.Text, code.ID, code.CodeType, match);
DialogResult dr = frm.ShowDialog(); DialogResult dr = frm.ShowDialog();
if (dr == DialogResult.OK) if (dr == DialogResult.OK)
...@@ -288,8 +307,43 @@ namespace SmartScan ...@@ -288,8 +307,43 @@ namespace SmartScan
private void BtnOcrCode_Click(object sender, EventArgs e) private void BtnOcrCode_Click(object sender, EventArgs e)
{ {
if (codeIndex == -1) return; if (bmp == null) return;
//保存需要识别ocr的区域
bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';');
LstCode.Items.Clear();
var ocrs = mateCopy[mateIndex].Code.FindAll(s => s.CodeType.Equals(Setting_Str.OCR));
foreach (var code in ocrs)
{
mateCopy[mateIndex].Code.Remove(code);
}
mateCopy[mateIndex].Match.Clear();
mateCopy[mateIndex].Ocr.Clear();
if (regOcrCodes.Length == 0)
{
string text = Language.Dialog(LanguageDialogKey.CODE_COUNT);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
return;
}
mateCopy[mateIndex].State = TemplateState.Unsaved;
int startidx = Common.mateMaxCodeID + 1;
foreach (var ocr in regOcrCodes)
{
if (string.IsNullOrEmpty(ocr)) continue;
MaterialCode code = new()
{
ID = startidx,
Text = ocr,
CodeType = Setting_Str.OCR
};
mateCopy[mateIndex].Code.Add(code);
startidx++;
}
LstCode.Items.AddRange(FormatCode());
LstCode.SelectedIndex = codeIndex = -1;
//if (codeIndex == -1) return;
//var m = mateCopy[mateIndex].Match.Find(m=>m.CodeID==codeIndex); //var m = mateCopy[mateIndex].Match.Find(m=>m.CodeID==codeIndex);
//if (m == null) //if (m == null)
//{ //{
...@@ -302,21 +356,21 @@ namespace SmartScan ...@@ -302,21 +356,21 @@ namespace SmartScan
// new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog(); // new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
// return; // return;
//} //}
List<MaterialCodeOCR> codeOcr = mateCopy[mateIndex].Ocr.FindAll(s => s.CodeID == mateCopy[mateIndex].Code[codeIndex].ID); //List<MaterialCodeOCR> codeOcr = mateCopy[mateIndex].Ocr.FindAll(s => s.CodeID == mateCopy[mateIndex].Code[codeIndex].ID);
FrmCodeOCR frm = new(mateCopy[mateIndex].Code[codeIndex], codeOcr, mateCopy[mateIndex].Match, mateCopy[mateIndex].Image);
DialogResult dr = frm.ShowDialog();
if (dr == DialogResult.OK)
{
for (int i = 0; i < frm.codeOcr.Count; i++)
mateCopy[mateIndex].Match.RemoveAll(s => s.CodeID == frm.codeOcr[i].ID);
mateCopy[mateIndex].Ocr.RemoveAll(s => s.CodeID == mateCopy[mateIndex].Code[codeIndex].ID);
mateCopy[mateIndex].Ocr.AddRange(frm.codeOcr);
mateCopy[mateIndex].Match.AddRange(frm.codeMatch); //FrmCodeOCR frm = new(mateCopy[mateIndex].Code[codeIndex], codeOcr, mateCopy[mateIndex].Match, mateCopy[mateIndex].Image);
mateCopy[mateIndex].State = TemplateState.Unsaved; //DialogResult dr = frm.ShowDialog();
LstCode.Items[codeIndex] = FormatCode(codeIndex); //if (dr == DialogResult.OK)
} //{
// for (int i = 0; i < frm.codeOcr.Count; i++)
// mateCopy[mateIndex].Match.RemoveAll(s => s.CodeID == frm.codeOcr[i].ID);
// mateCopy[mateIndex].Ocr.RemoveAll(s => s.CodeID == mateCopy[mateIndex].Code[codeIndex].ID);
// mateCopy[mateIndex].Ocr.AddRange(frm.codeOcr);
// mateCopy[mateIndex].Match.AddRange(frm.codeMatch);
// mateCopy[mateIndex].State = TemplateState.Unsaved;
// LstCode.Items[codeIndex] = FormatCode(codeIndex);
//}
} }
private void BtnPrimaryCode_Click(object sender, EventArgs e) private void BtnPrimaryCode_Click(object sender, EventArgs e)
......
...@@ -145,7 +145,7 @@ namespace paddleOCR ...@@ -145,7 +145,7 @@ namespace paddleOCR
var res = engine.DetectText(imagebyte); var res = engine.DetectText(imagebyte);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
res.TextBlocks.ForEach(s => { score += s.Score; sb.AppendLine(s.Text); }); res.TextBlocks.ForEach(s => { score += s.Score; sb.AppendLine(s.Text); });
log.Info($"【{item.FullName}】识别结果:【{score}】【{sb.ToString().Replace("\r", "").Replace("\n", ";")}】"); log.Info($"【{item.FullName}】结果:【{score}】【{sb.ToString().Replace("\r", "").Replace("\n", ";")}】");
if (score > maxScore) if (score > maxScore)
{ {
maxScore = score; maxScore = score;
...@@ -225,7 +225,7 @@ namespace paddleOCR ...@@ -225,7 +225,7 @@ namespace paddleOCR
{ {
result = result.Substring(0, result.Length - 1); result = result.Substring(0, result.Length - 1);
} }
log.Info("识别结果:" + result); log.Info($"识别结果[{strs.Length}]:" + result);
return true; return true;
} }
/// <summary> /// <summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!