on site debug
This commit is contained in:
146
TetraParkOCR/Form1.Designer.cs
generated
146
TetraParkOCR/Form1.Designer.cs
generated
@@ -43,6 +43,8 @@
|
|||||||
this.lbl_readOcrResult = new System.Windows.Forms.Label();
|
this.lbl_readOcrResult = new System.Windows.Forms.Label();
|
||||||
this.lbl_ocrResultState = new System.Windows.Forms.Label();
|
this.lbl_ocrResultState = new System.Windows.Forms.Label();
|
||||||
this.tableLayoutPanel_productInformtion = new System.Windows.Forms.TableLayoutPanel();
|
this.tableLayoutPanel_productInformtion = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.lbl_height = new System.Windows.Forms.Label();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.lbl_DistY = new System.Windows.Forms.Label();
|
this.lbl_DistY = new System.Windows.Forms.Label();
|
||||||
this.lbl_DistX = new System.Windows.Forms.Label();
|
this.lbl_DistX = new System.Windows.Forms.Label();
|
||||||
this.lbl_Gradient = new System.Windows.Forms.Label();
|
this.lbl_Gradient = new System.Windows.Forms.Label();
|
||||||
@@ -101,6 +103,9 @@
|
|||||||
this.menuStrip_topmenu = new System.Windows.Forms.MenuStrip();
|
this.menuStrip_topmenu = new System.Windows.Forms.MenuStrip();
|
||||||
this.tableLayoutPanel_mainForm = new System.Windows.Forms.TableLayoutPanel();
|
this.tableLayoutPanel_mainForm = new System.Windows.Forms.TableLayoutPanel();
|
||||||
this.panel_midup = new System.Windows.Forms.Panel();
|
this.panel_midup = new System.Windows.Forms.Panel();
|
||||||
|
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||||
|
this.label12 = new System.Windows.Forms.Label();
|
||||||
|
this.label11 = new System.Windows.Forms.Label();
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||||
this.btn_StarDet_manual = new System.Windows.Forms.Button();
|
this.btn_StarDet_manual = new System.Windows.Forms.Button();
|
||||||
@@ -109,12 +114,7 @@
|
|||||||
this.panel_auto = new System.Windows.Forms.Panel();
|
this.panel_auto = new System.Windows.Forms.Panel();
|
||||||
this.panel_locationDisplay = new System.Windows.Forms.Panel();
|
this.panel_locationDisplay = new System.Windows.Forms.Panel();
|
||||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||||
this.label5 = new System.Windows.Forms.Label();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.lbl_height = new System.Windows.Forms.Label();
|
|
||||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
|
||||||
this.label11 = new System.Windows.Forms.Label();
|
|
||||||
this.label12 = new System.Windows.Forms.Label();
|
|
||||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
|
||||||
this.tableLayoutPanel_productInformtion.SuspendLayout();
|
this.tableLayoutPanel_productInformtion.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.Location_Display)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.Location_Display)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.Ocr_picBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.Ocr_picBox)).BeginInit();
|
||||||
@@ -297,6 +297,29 @@
|
|||||||
this.tableLayoutPanel_productInformtion.Size = new System.Drawing.Size(308, 282);
|
this.tableLayoutPanel_productInformtion.Size = new System.Drawing.Size(308, 282);
|
||||||
this.tableLayoutPanel_productInformtion.TabIndex = 20;
|
this.tableLayoutPanel_productInformtion.TabIndex = 20;
|
||||||
//
|
//
|
||||||
|
// lbl_height
|
||||||
|
//
|
||||||
|
this.lbl_height.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
this.lbl_height.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.lbl_height.Font = new System.Drawing.Font("宋体", 12F);
|
||||||
|
this.lbl_height.Location = new System.Drawing.Point(155, 139);
|
||||||
|
this.lbl_height.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.lbl_height.Name = "lbl_height";
|
||||||
|
this.lbl_height.Size = new System.Drawing.Size(150, 31);
|
||||||
|
this.lbl_height.TabIndex = 29;
|
||||||
|
this.lbl_height.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.label5.Location = new System.Drawing.Point(3, 139);
|
||||||
|
this.label5.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(149, 31);
|
||||||
|
this.label5.TabIndex = 28;
|
||||||
|
this.label5.Text = "包材高度:";
|
||||||
|
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
// lbl_DistY
|
// lbl_DistY
|
||||||
//
|
//
|
||||||
this.lbl_DistY.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
this.lbl_DistY.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
@@ -1014,10 +1037,10 @@
|
|||||||
//
|
//
|
||||||
// panel_midup
|
// panel_midup
|
||||||
//
|
//
|
||||||
|
this.panel_midup.Controls.Add(this.button2);
|
||||||
this.panel_midup.Controls.Add(this.textBox1);
|
this.panel_midup.Controls.Add(this.textBox1);
|
||||||
this.panel_midup.Controls.Add(this.label12);
|
this.panel_midup.Controls.Add(this.label12);
|
||||||
this.panel_midup.Controls.Add(this.label11);
|
this.panel_midup.Controls.Add(this.label11);
|
||||||
this.panel_midup.Controls.Add(this.checkBox1);
|
|
||||||
this.panel_midup.Controls.Add(this.button1);
|
this.panel_midup.Controls.Add(this.button1);
|
||||||
this.panel_midup.Controls.Add(this.listBox1);
|
this.panel_midup.Controls.Add(this.listBox1);
|
||||||
this.panel_midup.Controls.Add(this.btn_StarDet_manual);
|
this.panel_midup.Controls.Add(this.btn_StarDet_manual);
|
||||||
@@ -1039,6 +1062,39 @@
|
|||||||
this.panel_midup.Size = new System.Drawing.Size(801, 388);
|
this.panel_midup.Size = new System.Drawing.Size(801, 388);
|
||||||
this.panel_midup.TabIndex = 33;
|
this.panel_midup.TabIndex = 33;
|
||||||
//
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
this.textBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.textBox1.Location = new System.Drawing.Point(391, 52);
|
||||||
|
this.textBox1.Name = "textBox1";
|
||||||
|
this.textBox1.Size = new System.Drawing.Size(61, 29);
|
||||||
|
this.textBox1.TabIndex = 32;
|
||||||
|
this.textBox1.Text = "19";
|
||||||
|
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
|
this.textBox1.Visible = false;
|
||||||
|
//
|
||||||
|
// label12
|
||||||
|
//
|
||||||
|
this.label12.AutoSize = true;
|
||||||
|
this.label12.Location = new System.Drawing.Point(458, 61);
|
||||||
|
this.label12.Name = "label12";
|
||||||
|
this.label12.Size = new System.Drawing.Size(17, 12);
|
||||||
|
this.label12.TabIndex = 31;
|
||||||
|
this.label12.Text = "mm";
|
||||||
|
this.label12.Visible = false;
|
||||||
|
//
|
||||||
|
// label11
|
||||||
|
//
|
||||||
|
this.label11.AutoSize = true;
|
||||||
|
this.label11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.label11.Location = new System.Drawing.Point(209, 59);
|
||||||
|
this.label11.Name = "label11";
|
||||||
|
this.label11.Size = new System.Drawing.Size(184, 16);
|
||||||
|
this.label11.TabIndex = 29;
|
||||||
|
this.label11.Text = "当前单颜色段字符长度:";
|
||||||
|
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
this.label11.Visible = false;
|
||||||
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
this.button1.BackColor = System.Drawing.Color.LimeGreen;
|
this.button1.BackColor = System.Drawing.Color.LimeGreen;
|
||||||
@@ -1119,68 +1175,20 @@
|
|||||||
this.panel_locationDisplay.Size = new System.Drawing.Size(478, 388);
|
this.panel_locationDisplay.Size = new System.Drawing.Size(478, 388);
|
||||||
this.panel_locationDisplay.TabIndex = 0;
|
this.panel_locationDisplay.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// label5
|
// button2
|
||||||
//
|
//
|
||||||
this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.button2.BackColor = System.Drawing.Color.LimeGreen;
|
||||||
this.label5.Location = new System.Drawing.Point(3, 139);
|
this.button2.Enabled = false;
|
||||||
this.label5.Margin = new System.Windows.Forms.Padding(0);
|
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
this.label5.Name = "label5";
|
this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.label5.Size = new System.Drawing.Size(149, 31);
|
this.button2.Location = new System.Drawing.Point(542, 219);
|
||||||
this.label5.TabIndex = 28;
|
this.button2.Name = "button2";
|
||||||
this.label5.Text = "包材高度:";
|
this.button2.Size = new System.Drawing.Size(149, 46);
|
||||||
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.button2.TabIndex = 33;
|
||||||
//
|
this.button2.Text = "去零点";
|
||||||
// lbl_height
|
this.toolTip.SetToolTip(this.button2, "此操作为当前暂定方式");
|
||||||
//
|
this.button2.UseVisualStyleBackColor = false;
|
||||||
this.lbl_height.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||||
this.lbl_height.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.lbl_height.Font = new System.Drawing.Font("宋体", 12F);
|
|
||||||
this.lbl_height.Location = new System.Drawing.Point(155, 139);
|
|
||||||
this.lbl_height.Margin = new System.Windows.Forms.Padding(0);
|
|
||||||
this.lbl_height.Name = "lbl_height";
|
|
||||||
this.lbl_height.Size = new System.Drawing.Size(150, 31);
|
|
||||||
this.lbl_height.TabIndex = 29;
|
|
||||||
this.lbl_height.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
||||||
//
|
|
||||||
// checkBox1
|
|
||||||
//
|
|
||||||
this.checkBox1.AutoSize = true;
|
|
||||||
this.checkBox1.Location = new System.Drawing.Point(106, 237);
|
|
||||||
this.checkBox1.Name = "checkBox1";
|
|
||||||
this.checkBox1.Size = new System.Drawing.Size(84, 16);
|
|
||||||
this.checkBox1.TabIndex = 28;
|
|
||||||
this.checkBox1.Text = "仅计算坐标";
|
|
||||||
this.checkBox1.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// label11
|
|
||||||
//
|
|
||||||
this.label11.AutoSize = true;
|
|
||||||
this.label11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
||||||
this.label11.Location = new System.Drawing.Point(209, 59);
|
|
||||||
this.label11.Name = "label11";
|
|
||||||
this.label11.Size = new System.Drawing.Size(183, 16);
|
|
||||||
this.label11.TabIndex = 29;
|
|
||||||
this.label11.Text = "当前单颜色段字符长度:";
|
|
||||||
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
|
||||||
//
|
|
||||||
// label12
|
|
||||||
//
|
|
||||||
this.label12.AutoSize = true;
|
|
||||||
this.label12.Location = new System.Drawing.Point(458, 61);
|
|
||||||
this.label12.Name = "label12";
|
|
||||||
this.label12.Size = new System.Drawing.Size(17, 12);
|
|
||||||
this.label12.TabIndex = 31;
|
|
||||||
this.label12.Text = "mm";
|
|
||||||
//
|
|
||||||
// textBox1
|
|
||||||
//
|
|
||||||
this.textBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
||||||
this.textBox1.Location = new System.Drawing.Point(391, 52);
|
|
||||||
this.textBox1.Name = "textBox1";
|
|
||||||
this.textBox1.Size = new System.Drawing.Size(61, 29);
|
|
||||||
this.textBox1.TabIndex = 32;
|
|
||||||
this.textBox1.Text = "19";
|
|
||||||
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
@@ -1301,10 +1309,10 @@
|
|||||||
private System.Windows.Forms.Button button1;
|
private System.Windows.Forms.Button button1;
|
||||||
private System.Windows.Forms.Label lbl_height;
|
private System.Windows.Forms.Label lbl_height;
|
||||||
private System.Windows.Forms.Label label5;
|
private System.Windows.Forms.Label label5;
|
||||||
private System.Windows.Forms.CheckBox checkBox1;
|
|
||||||
private System.Windows.Forms.Label label11;
|
private System.Windows.Forms.Label label11;
|
||||||
private System.Windows.Forms.TextBox textBox1;
|
private System.Windows.Forms.TextBox textBox1;
|
||||||
private System.Windows.Forms.Label label12;
|
private System.Windows.Forms.Label label12;
|
||||||
|
private System.Windows.Forms.Button button2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ namespace TetraPackOCR
|
|||||||
btn_StarDet_manual.Enabled = false;
|
btn_StarDet_manual.Enabled = false;
|
||||||
btn_StarDet_manual.BackColor = Color.LightGray;
|
btn_StarDet_manual.BackColor = Color.LightGray;
|
||||||
button1.BackColor = Color.LightGray;
|
button1.BackColor = Color.LightGray;
|
||||||
|
button2.Enabled = false;
|
||||||
|
button2.BackColor = Color.LightGray;
|
||||||
btn_OrderNum.Enabled = false;
|
btn_OrderNum.Enabled = false;
|
||||||
btn_OrderNum.BackColor = Color.LightGray;
|
btn_OrderNum.BackColor = Color.LightGray;
|
||||||
log.Info("软件正在加载...");
|
log.Info("软件正在加载...");
|
||||||
@@ -213,10 +215,16 @@ namespace TetraPackOCR
|
|||||||
ClossCam();
|
ClossCam();
|
||||||
|
|
||||||
//// 注销结果队列事件
|
//// 注销结果队列事件
|
||||||
myJobManagerDET.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
if (myJobManagerDET != null)
|
||||||
myJobManagerDET.Shutdown();
|
{
|
||||||
|
myJobManagerDET.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
||||||
|
myJobManagerDET.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
CloseCC24();
|
CloseCC24();
|
||||||
|
|
||||||
|
if (myJobManagerDET == null)
|
||||||
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -517,6 +525,8 @@ namespace TetraPackOCR
|
|||||||
}
|
}
|
||||||
btn_StarDet_manual.Enabled = true;
|
btn_StarDet_manual.Enabled = true;
|
||||||
btn_StarDet_manual.BackColor = Color.LimeGreen;
|
btn_StarDet_manual.BackColor = Color.LimeGreen;
|
||||||
|
button2.Enabled = true;
|
||||||
|
button2.BackColor = Color.LimeGreen;
|
||||||
button1.Enabled = false;
|
button1.Enabled = false;
|
||||||
button1.BackColor = Color.LightGray;
|
button1.BackColor = Color.LightGray;
|
||||||
}
|
}
|
||||||
@@ -573,7 +583,7 @@ namespace TetraPackOCR
|
|||||||
OcrParameter.use_angle_cls = true;//是否开启方向检测,用于检测识别180旋转
|
OcrParameter.use_angle_cls = true;//是否开启方向检测,用于检测识别180旋转
|
||||||
OcrParameter.det_db_score_mode = true;//是否使用多段线,即文字区域是用多段线还是用矩形,
|
OcrParameter.det_db_score_mode = true;//是否使用多段线,即文字区域是用多段线还是用矩形,
|
||||||
OcrParameter.det_db_unclip_ratio = 1.6f;
|
OcrParameter.det_db_unclip_ratio = 1.6f;
|
||||||
OcrParameter.max_side_len = 3800;
|
OcrParameter.max_side_len = 4600;
|
||||||
|
|
||||||
//初始化OCR
|
//初始化OCR
|
||||||
Engine = new PaddleOCREngine(config, OcrParameter);
|
Engine = new PaddleOCREngine(config, OcrParameter);
|
||||||
@@ -636,6 +646,8 @@ namespace TetraPackOCR
|
|||||||
orderLoaded = false;
|
orderLoaded = false;
|
||||||
btn_StarDet_manual.Enabled = false;
|
btn_StarDet_manual.Enabled = false;
|
||||||
btn_StarDet_manual.BackColor = Color.LightGray;
|
btn_StarDet_manual.BackColor = Color.LightGray;
|
||||||
|
button2.Enabled = false;
|
||||||
|
button2.BackColor = Color.LightGray;
|
||||||
listBox1.Items.Clear();
|
listBox1.Items.Clear();
|
||||||
ocrTextRequest.Clear();
|
ocrTextRequest.Clear();
|
||||||
ocrTextDesign.Clear();
|
ocrTextDesign.Clear();
|
||||||
@@ -809,6 +821,8 @@ namespace TetraPackOCR
|
|||||||
orderLoaded = true;
|
orderLoaded = true;
|
||||||
btn_StarDet_manual.Enabled = true;
|
btn_StarDet_manual.Enabled = true;
|
||||||
btn_StarDet_manual.BackColor = Color.LimeGreen;
|
btn_StarDet_manual.BackColor = Color.LimeGreen;
|
||||||
|
button2.Enabled = true;
|
||||||
|
button2.BackColor = Color.LimeGreen;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -980,8 +994,8 @@ namespace TetraPackOCR
|
|||||||
log.Info("手动触发定位");
|
log.Info("手动触发定位");
|
||||||
}
|
}
|
||||||
private bool autorunFlag = false;
|
private bool autorunFlag = false;
|
||||||
private bool debugFlag = false;
|
|
||||||
private double m_textWidth = 0;
|
private double m_textWidth = 0;
|
||||||
|
private DateTime m_startTime = DateTime.Now;
|
||||||
private void btn_StarDet_manual_Click(object sender, EventArgs e)
|
private void btn_StarDet_manual_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (camOCROpened == false || camDETOpened == false)
|
if (camOCROpened == false || camDETOpened == false)
|
||||||
@@ -1003,13 +1017,17 @@ namespace TetraPackOCR
|
|||||||
|
|
||||||
InitLableColumn();
|
InitLableColumn();
|
||||||
|
|
||||||
m_textWidth = Convert.ToDouble(textBox1.Text);
|
m_GotoZero = false;
|
||||||
|
m_startTime = DateTime.Now;
|
||||||
|
m_textWidth = 18 - (NumberOfLanes - 5);
|
||||||
|
//m_textWidth = Convert.ToDouble(textBox1.Text);
|
||||||
ocrAcc.Clear();
|
ocrAcc.Clear();
|
||||||
debugFlag = checkBox1.Checked;
|
|
||||||
autorunFlag = check_Autorun.Checked;
|
autorunFlag = check_Autorun.Checked;
|
||||||
btn_StarDet_manual.Enabled = false;
|
btn_StarDet_manual.Enabled = false;
|
||||||
|
button2.Enabled = false;
|
||||||
button1.Enabled = true;
|
button1.Enabled = true;
|
||||||
btn_StarDet_manual.BackColor = Color.LightGray;
|
btn_StarDet_manual.BackColor = Color.LightGray;
|
||||||
|
button2.BackColor = Color.LightGray;
|
||||||
button1.BackColor = Color.LimeGreen;
|
button1.BackColor = Color.LimeGreen;
|
||||||
m_dev_cam_det?.ExecuteSoftwareTrigger();
|
m_dev_cam_det?.ExecuteSoftwareTrigger();
|
||||||
list_Log.Clear();
|
list_Log.Clear();
|
||||||
@@ -1248,6 +1266,14 @@ namespace TetraPackOCR
|
|||||||
Invoke(new OcrResultDelegate(OCRResult), new object[] { bmp });
|
Invoke(new OcrResultDelegate(OCRResult), new object[] { bmp });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_GotoZero)
|
||||||
|
{
|
||||||
|
log.Info("零点拍照");
|
||||||
|
NoticePLCCompleteOCR();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ocrTextResult = new Dictionary<string, bool>();
|
ocrTextResult = new Dictionary<string, bool>();
|
||||||
if (!ocrTextRequest.ContainsKey(mMatchingStr))
|
if (!ocrTextRequest.ContainsKey(mMatchingStr))
|
||||||
{
|
{
|
||||||
@@ -1269,15 +1295,20 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(SaveImageFileOCR + '\\' + strtimef);
|
Directory.CreateDirectory(SaveImageFileOCR + '\\' + strtimef);
|
||||||
}
|
}
|
||||||
|
string savePath = Path.Combine(SaveImageFileOCR + '\\' + strtimef, m_startTime.ToString("HHmmss"));
|
||||||
|
if (!Directory.Exists(savePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(savePath);
|
||||||
|
}
|
||||||
string strTime = System.DateTime.Now.ToString("yyyyMMddHHmmss");
|
string strTime = System.DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
FileStream fs = new FileStream(SaveImageFileOCR + '\\' + strtimef + '\\' + strTime + ".bmp", FileMode.Create);
|
FileStream fs = new FileStream(savePath + '\\' + strTime + ".bmp", FileMode.Create);
|
||||||
BinaryWriter bw = new BinaryWriter(fs);
|
BinaryWriter bw = new BinaryWriter(fs);
|
||||||
bw.Write(bytes, 0, bytes.Length);
|
bw.Write(bytes, 0, bytes.Length);
|
||||||
bw.Close();
|
bw.Close();
|
||||||
fs.Close();
|
fs.Close();
|
||||||
log.Info("OCR存图已完成");
|
log.Info("OCR存图已完成");
|
||||||
|
|
||||||
CutPicture(SaveImageFileOCR + '\\' + strtimef + '\\' + strTime + ".bmp", 1000, 1800, 3800, 1600);
|
CutPicture(savePath + '\\' + strTime + ".bmp", 400 + 200 * (6 - m_ColorMax), 2000, 3400 + 200 * m_ColorMax, 1600);
|
||||||
if (Engine == null)
|
if (Engine == null)
|
||||||
{
|
{
|
||||||
log.Error("Engine未初始化");
|
log.Error("Engine未初始化");
|
||||||
@@ -1286,7 +1317,7 @@ namespace TetraPackOCR
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetOCRImage getOCRImage = new GetOCRImage();
|
GetOCRImage getOCRImage = new GetOCRImage();
|
||||||
GetOCRImage.FileTimeInfo file = getOCRImage.GetLatesFileImageName(SaveImageFileOCR + '\\' + strtimef, ".bmp");
|
GetOCRImage.FileTimeInfo file = getOCRImage.GetLatesFileImageName(savePath, ".bmp");
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
Mat bgr = Cv2.ImRead(file.FileName, ImreadModes.Color); // 读入 BGR
|
Mat bgr = Cv2.ImRead(file.FileName, ImreadModes.Color); // 读入 BGR
|
||||||
@@ -1308,7 +1339,9 @@ namespace TetraPackOCR
|
|||||||
OCRTextResult vResult = null;
|
OCRTextResult vResult = null;
|
||||||
|
|
||||||
bool matchOK = false;
|
bool matchOK = false;
|
||||||
PointF[] pointsTotal = null;
|
List<PointF[]> pointS = null;
|
||||||
|
List<PointF[]> pointH = null;
|
||||||
|
List<PointF[]> pointV = null;
|
||||||
sResult = OCRBytes(s.ImEncode(".png"));
|
sResult = OCRBytes(s.ImEncode(".png"));
|
||||||
if (sResult == null)
|
if (sResult == null)
|
||||||
{
|
{
|
||||||
@@ -1319,7 +1352,7 @@ namespace TetraPackOCR
|
|||||||
txt_readOcrResultShow.Text = sResult.text;
|
txt_readOcrResultShow.Text = sResult.text;
|
||||||
log.Info("s通道字符读取结果:" + sResult.text);
|
log.Info("s通道字符读取结果:" + sResult.text);
|
||||||
matchOK = sResult.match;
|
matchOK = sResult.match;
|
||||||
pointsTotal = sResult.points;
|
pointS = sResult.points;
|
||||||
|
|
||||||
if (!matchOK)
|
if (!matchOK)
|
||||||
{
|
{
|
||||||
@@ -1333,13 +1366,7 @@ namespace TetraPackOCR
|
|||||||
txt_readOcrResultShow.Text += "\n" + hResult.text;
|
txt_readOcrResultShow.Text += "\n" + hResult.text;
|
||||||
log.Info("h通道字符读取结果:" + hResult.text);
|
log.Info("h通道字符读取结果:" + hResult.text);
|
||||||
matchOK = hResult.match;
|
matchOK = hResult.match;
|
||||||
if (hResult.points != null && hResult.points.Length > 0)
|
pointH = hResult.points;
|
||||||
{
|
|
||||||
List<PointF> pp1 = hResult.points.ToList();
|
|
||||||
List<PointF> pp = pointsTotal.ToList();
|
|
||||||
pp.AddRange(pp1);
|
|
||||||
pointsTotal = pp.Distinct().ToArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!matchOK)
|
if (!matchOK)
|
||||||
{
|
{
|
||||||
@@ -1353,30 +1380,37 @@ namespace TetraPackOCR
|
|||||||
txt_readOcrResultShow.Text += "\n" + vResult.text;
|
txt_readOcrResultShow.Text += "\n" + vResult.text;
|
||||||
log.Info("v通道字符读取结果:" + vResult.text);
|
log.Info("v通道字符读取结果:" + vResult.text);
|
||||||
matchOK = vResult.match;
|
matchOK = vResult.match;
|
||||||
if (vResult.points != null && vResult.points.Length > 0)
|
pointV = vResult.points;
|
||||||
{
|
|
||||||
List<PointF> pp1 = vResult.points.ToList();
|
|
||||||
List<PointF> pp = pointsTotal.ToList();
|
|
||||||
pp.AddRange(pp1);
|
|
||||||
pointsTotal = pp.Distinct().ToArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
byte[] ocrimagebyte = File.ReadAllBytes(file.FileName);
|
||||||
if (pointsTotal != null && pointsTotal.Length > 0)
|
Bitmap Bmp = new Bitmap(new MemoryStream(ocrimagebyte));
|
||||||
|
if ((pointS != null && pointS.Count > 0) || (pointH != null && pointH.Count > 0) || (pointV != null && pointV.Count > 0))
|
||||||
{
|
{
|
||||||
byte[] ocrimagebyte = File.ReadAllBytes(file.FileName);
|
|
||||||
Bitmap Bmp = new Bitmap(new MemoryStream(ocrimagebyte));
|
|
||||||
using (Graphics g = Graphics.FromImage(Bmp))
|
using (Graphics g = Graphics.FromImage(Bmp))
|
||||||
{
|
{
|
||||||
g.DrawPolygon(new Pen(Brushes.Red, 2), pointsTotal.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
|
if (pointS != null && pointS.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in pointS)
|
||||||
|
g.DrawPolygon(new Pen(Brushes.Red, 2), item.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
|
||||||
|
}
|
||||||
|
if (pointH != null && pointH.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in pointH)
|
||||||
|
g.DrawPolygon(new Pen(Brushes.Red, 2), item.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
|
||||||
|
}
|
||||||
|
if (pointV != null && pointV.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in pointV)
|
||||||
|
g.DrawPolygon(new Pen(Brushes.Red, 2), item.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ocr_picBox.BackgroundImage = null;
|
|
||||||
Ocr_picBox.BackgroundImage = Bmp;
|
|
||||||
int m1 = ocrTextResult.Count(x => x.Value);
|
int m1 = ocrTextResult.Count(x => x.Value);
|
||||||
log.Info($"OCR识别完成,匹配成功{m1}个字符,匹配失败{ocrTextResult.Count - m1}个字符");
|
log.Info($"OCR识别完成,匹配成功{m1}个字符,匹配失败{ocrTextResult.Count - m1}个字符");
|
||||||
ShowTheLansRs(mMatchingStr, (double)m1 / (double)ocrTextResult.Count);
|
ShowTheLansRs(mMatchingStr, (double)m1 / (double)ocrTextResult.Count);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
log.Info("OCR识别完成,匹配失败");
|
||||||
|
Ocr_picBox.BackgroundImage = Bmp;
|
||||||
NoticePLCCompleteOCR();
|
NoticePLCCompleteOCR();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1416,7 +1450,7 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
if (item.Text.Contains(ocrTextDesign[mMatchingStr]))
|
if (item.Text.Contains(ocrTextDesign[mMatchingStr]))
|
||||||
{
|
{
|
||||||
result.points = item.BoxPoints.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray();
|
result.points.Add(item.BoxPoints.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
|
||||||
pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text));
|
pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1536,8 +1570,11 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
btn_StarDet_manual.Enabled = true;
|
btn_StarDet_manual.Enabled = true;
|
||||||
button1.Enabled = false;
|
button1.Enabled = false;
|
||||||
|
button2.Enabled = true;
|
||||||
btn_StarDet_manual.BackColor = Color.LimeGreen;
|
btn_StarDet_manual.BackColor = Color.LimeGreen;
|
||||||
button1.BackColor = Color.LightGray;
|
button1.BackColor = Color.LightGray;
|
||||||
|
button2.BackColor = Color.LimeGreen;
|
||||||
|
NoticePLCCompleteOCR();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1796,6 +1833,23 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
MessageBox.Show("当前检测中出现可允许误差请注意!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("当前检测中出现可允许误差请注意!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
log.Info("当前检测合格,正常结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private bool m_GotoZero = false;
|
||||||
|
private void button2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
autorunFlag = check_Autorun.Checked;
|
||||||
|
if (check_Autorun.Checked == false)
|
||||||
|
{
|
||||||
|
m_GotoZero = true;
|
||||||
|
List<float> plcXY = new List<float>();
|
||||||
|
plcXY.Add(1);
|
||||||
|
plcXY.Add(0);
|
||||||
|
plcXY.Add(0);
|
||||||
|
NoticePLCCompleteDet(DataConverter.FloatToByte(plcXY, true));
|
||||||
|
log.Info("零点坐标已发送");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -1812,6 +1866,7 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
if (e.CameraIndex == 1)
|
if (e.CameraIndex == 1)
|
||||||
{
|
{
|
||||||
|
Ocr_picBox.BackgroundImage = null;
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
OcrCamTriger();
|
OcrCamTriger();
|
||||||
}
|
}
|
||||||
@@ -1844,12 +1899,16 @@ namespace TetraPackOCR
|
|||||||
PlcContinueFlag = true;
|
PlcContinueFlag = true;
|
||||||
log.Info("PLC已连接PC,可以进行相关操作");
|
log.Info("PLC已连接PC,可以进行相关操作");
|
||||||
ttls_PCLStatusShow.Visible = true;
|
ttls_PCLStatusShow.Visible = true;
|
||||||
|
button2.Enabled = true;
|
||||||
|
button2.BackColor = Color.LimeGreen;
|
||||||
}
|
}
|
||||||
else if (e.ProtocolStatus != CogNdmConnectionStatusConstants.Connecting)
|
else if (e.ProtocolStatus != CogNdmConnectionStatusConstants.Connecting)
|
||||||
{
|
{
|
||||||
PlcContinueFlag = false;
|
PlcContinueFlag = false;
|
||||||
log.Info("PLC已断开PC,请查看相关设备是否连接");
|
log.Info("PLC已断开PC,请查看相关设备是否连接");
|
||||||
ttls_PCLStatusShow.Visible = false;
|
ttls_PCLStatusShow.Visible = false;
|
||||||
|
button2.Enabled = false;
|
||||||
|
button2.BackColor = Color.LightGray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -1858,133 +1917,13 @@ namespace TetraPackOCR
|
|||||||
private void SendToPLC(double x, double y, double r)
|
private void SendToPLC(double x, double y, double r)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double xx = x;
|
|
||||||
double yy = y;
|
|
||||||
double rr = r;
|
|
||||||
|
|
||||||
if (ocrTextRequest[1].Count == 0)
|
if (ocrTextRequest[1].Count == 0)
|
||||||
return;
|
return;
|
||||||
xx = x - (m_textWidth * m_ColorMax) / 2.0;
|
|
||||||
|
|
||||||
//switch (m_ProductStandard)
|
double xx = x - (m_textWidth * m_ColorMax) / 2.0;
|
||||||
// {
|
double yy = y;
|
||||||
// case "TBA1000Slim":
|
double rr = r;
|
||||||
// switch (ocrTextRequest[1].Count)
|
|
||||||
// {
|
|
||||||
// case 1:
|
|
||||||
// xx = (float)x - 9.5f;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// xx = (float)x - 28.5f;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// xx = (float)x - 38f;
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// xx = (float)x - 47.5f;
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// xx = (float)x - 57f;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case "TBA250B":
|
|
||||||
// switch (ocrTextRequest[1].Count)
|
|
||||||
// {
|
|
||||||
// case 1:
|
|
||||||
// xx = (float)x - 9.5f;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// xx = (float)x - 28.5f;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// xx = (float)x - 38f;
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// xx = (float)x - 38f;
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// xx = (float)x - 38f;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case "TBA125Slim":
|
|
||||||
// switch (ocrTextRequest[1].Count)
|
|
||||||
// {
|
|
||||||
// case 1:
|
|
||||||
// xx = (float)x - 9.5f;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// xx = (float)x - 28.5f;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// xx = (float)x - 28.5f;
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// xx = (float)x - 28.5f;
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// xx = (float)x - 28.5f;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case "TPA250SQ":
|
|
||||||
// switch (ocrTextRequest[1].Count)
|
|
||||||
// {
|
|
||||||
// case 1:
|
|
||||||
// xx = (float)x - 9.5f;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// xx = (float)x - 19f;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case "TPA200SQ":
|
|
||||||
// switch (ocrTextRequest[1].Count)
|
|
||||||
// {
|
|
||||||
// case 1:
|
|
||||||
// xx = (float)x - 9.5f;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// xx = (float)x - 9f;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// xx = (float)x - 9f;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// xx = (float)x - 9f;
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// xx = (float)x - 9f;
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// xx = (float)x - 9f;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
List<float> locationXY = new List<float>();
|
List<float> locationXY = new List<float>();
|
||||||
double ocrx = 0, ocry = 0;
|
double ocrx = 0, ocry = 0;
|
||||||
@@ -2009,7 +1948,10 @@ namespace TetraPackOCR
|
|||||||
if (ocrx < 0 || ocrx > 1600)
|
if (ocrx < 0 || ocrx > 1600)
|
||||||
{
|
{
|
||||||
EnableStartDetect();
|
EnableStartDetect();
|
||||||
log.Error("x范围 0,1600!");
|
if (ocrx < 0)
|
||||||
|
log.Error("横向范围 0,1600!纸张向左移动一点");
|
||||||
|
else
|
||||||
|
log.Error("横向范围 0,1600!纸张向右移动一点");
|
||||||
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2030,7 +1972,10 @@ namespace TetraPackOCR
|
|||||||
if (ocry < -50 || ocry > 400)
|
if (ocry < -50 || ocry > 400)
|
||||||
{
|
{
|
||||||
EnableStartDetect();
|
EnableStartDetect();
|
||||||
log.Error("y范围 -50,400!");
|
if (ocry < -50)
|
||||||
|
log.Error("纵向范围 -50,400!纸张向下移动一点");
|
||||||
|
else
|
||||||
|
log.Error("纵向范围 -50,400!纸张向上移动一点");
|
||||||
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2038,7 +1983,7 @@ namespace TetraPackOCR
|
|||||||
locationXY.Add((float)ocry);
|
locationXY.Add((float)ocry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_Autorun.Checked == false && !debugFlag)
|
if (check_Autorun.Checked == false)
|
||||||
{
|
{
|
||||||
List<float> plcXY = new List<float>();
|
List<float> plcXY = new List<float>();
|
||||||
for (int i = 0; i < locationXY.Count; i++)
|
for (int i = 0; i < locationXY.Count; i++)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,6 @@ namespace TetraParkOCR
|
|||||||
{
|
{
|
||||||
public bool match;
|
public bool match;
|
||||||
public string text;
|
public string text;
|
||||||
public PointF[] points;
|
public List<PointF[]> points = new List<PointF[]>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user