update algo for position
This commit is contained in:
47
TetraParkOCR/Form1.Designer.cs
generated
47
TetraParkOCR/Form1.Designer.cs
generated
@@ -112,6 +112,9 @@
|
|||||||
this.label5 = new System.Windows.Forms.Label();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.lbl_height = new System.Windows.Forms.Label();
|
this.lbl_height = new System.Windows.Forms.Label();
|
||||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
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();
|
||||||
@@ -133,7 +136,7 @@
|
|||||||
this.btn_OrderNum.BackColor = System.Drawing.Color.DeepSkyBlue;
|
this.btn_OrderNum.BackColor = System.Drawing.Color.DeepSkyBlue;
|
||||||
this.btn_OrderNum.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
this.btn_OrderNum.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||||
this.btn_OrderNum.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.btn_OrderNum.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.btn_OrderNum.Location = new System.Drawing.Point(519, 26);
|
this.btn_OrderNum.Location = new System.Drawing.Point(520, 19);
|
||||||
this.btn_OrderNum.Name = "btn_OrderNum";
|
this.btn_OrderNum.Name = "btn_OrderNum";
|
||||||
this.btn_OrderNum.Size = new System.Drawing.Size(116, 29);
|
this.btn_OrderNum.Size = new System.Drawing.Size(116, 29);
|
||||||
this.btn_OrderNum.TabIndex = 2;
|
this.btn_OrderNum.TabIndex = 2;
|
||||||
@@ -145,7 +148,7 @@
|
|||||||
// txt_OrderNum
|
// txt_OrderNum
|
||||||
//
|
//
|
||||||
this.txt_OrderNum.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.txt_OrderNum.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.txt_OrderNum.Location = new System.Drawing.Point(328, 26);
|
this.txt_OrderNum.Location = new System.Drawing.Point(329, 19);
|
||||||
this.txt_OrderNum.Name = "txt_OrderNum";
|
this.txt_OrderNum.Name = "txt_OrderNum";
|
||||||
this.txt_OrderNum.Size = new System.Drawing.Size(176, 29);
|
this.txt_OrderNum.Size = new System.Drawing.Size(176, 29);
|
||||||
this.txt_OrderNum.TabIndex = 3;
|
this.txt_OrderNum.TabIndex = 3;
|
||||||
@@ -154,7 +157,7 @@
|
|||||||
// lbl_OrderNum
|
// lbl_OrderNum
|
||||||
//
|
//
|
||||||
this.lbl_OrderNum.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.lbl_OrderNum.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.lbl_OrderNum.Location = new System.Drawing.Point(231, 26);
|
this.lbl_OrderNum.Location = new System.Drawing.Point(232, 19);
|
||||||
this.lbl_OrderNum.Name = "lbl_OrderNum";
|
this.lbl_OrderNum.Name = "lbl_OrderNum";
|
||||||
this.lbl_OrderNum.Size = new System.Drawing.Size(95, 29);
|
this.lbl_OrderNum.Size = new System.Drawing.Size(95, 29);
|
||||||
this.lbl_OrderNum.TabIndex = 4;
|
this.lbl_OrderNum.TabIndex = 4;
|
||||||
@@ -194,7 +197,7 @@
|
|||||||
// lbl_verOcr
|
// lbl_verOcr
|
||||||
//
|
//
|
||||||
this.lbl_verOcr.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.lbl_verOcr.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.lbl_verOcr.Location = new System.Drawing.Point(25, 46);
|
this.lbl_verOcr.Location = new System.Drawing.Point(14, 53);
|
||||||
this.lbl_verOcr.Name = "lbl_verOcr";
|
this.lbl_verOcr.Name = "lbl_verOcr";
|
||||||
this.lbl_verOcr.Size = new System.Drawing.Size(99, 29);
|
this.lbl_verOcr.Size = new System.Drawing.Size(99, 29);
|
||||||
this.lbl_verOcr.TabIndex = 9;
|
this.lbl_verOcr.TabIndex = 9;
|
||||||
@@ -1011,6 +1014,9 @@
|
|||||||
//
|
//
|
||||||
// panel_midup
|
// panel_midup
|
||||||
//
|
//
|
||||||
|
this.panel_midup.Controls.Add(this.textBox1);
|
||||||
|
this.panel_midup.Controls.Add(this.label12);
|
||||||
|
this.panel_midup.Controls.Add(this.label11);
|
||||||
this.panel_midup.Controls.Add(this.checkBox1);
|
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);
|
||||||
@@ -1146,6 +1152,36 @@
|
|||||||
this.checkBox1.Text = "仅计算坐标";
|
this.checkBox1.Text = "仅计算坐标";
|
||||||
this.checkBox1.UseVisualStyleBackColor = true;
|
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
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
@@ -1266,6 +1302,9 @@
|
|||||||
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.CheckBox checkBox1;
|
||||||
|
private System.Windows.Forms.Label label11;
|
||||||
|
private System.Windows.Forms.TextBox textBox1;
|
||||||
|
private System.Windows.Forms.Label label12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace TetraPackOCR
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
int NumberOfLanes;
|
int NumberOfLanes;
|
||||||
double m_width, m_Gradient, m_DistX, m_DistY, m_height;
|
double m_width, m_Gradient, m_DistX, m_DistY, m_height;
|
||||||
|
int m_ColorMax = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 定位Vpp文件
|
/// 定位Vpp文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -105,7 +106,7 @@ namespace TetraPackOCR
|
|||||||
bool PlcContinueFlag = false; //PLC状态旗帜
|
bool PlcContinueFlag = false; //PLC状态旗帜
|
||||||
int mMatchingStr = 0;//接收当前OCR拍照位置
|
int mMatchingStr = 0;//接收当前OCR拍照位置
|
||||||
|
|
||||||
List<float> ocrAcc = new List<float>();
|
List<double> ocrAcc = new List<double>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 相机对象 1和2
|
/// 相机对象 1和2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -142,6 +143,7 @@ namespace TetraPackOCR
|
|||||||
InitializeCamerDET();
|
InitializeCamerDET();
|
||||||
InitializePaddleOCR();
|
InitializePaddleOCR();
|
||||||
|
|
||||||
|
log.Info("VPP文件加载中...");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myJobManagerDET = CogSerializer.LoadObjectFromFile(vppdetFile) as CogJobManager;
|
myJobManagerDET = CogSerializer.LoadObjectFromFile(vppdetFile) as CogJobManager;
|
||||||
@@ -169,16 +171,11 @@ namespace TetraPackOCR
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Task myTask = new Task(action);
|
Task myTask = new Task(action);
|
||||||
|
|
||||||
//实例化一个线程列表
|
//实例化一个线程列表
|
||||||
List<Task> tsk = new List<Task>();
|
List<Task> tsk = new List<Task>();
|
||||||
|
|
||||||
//将上面的加载vpp工作加入线程列表中
|
//将上面的加载vpp工作加入线程列表中
|
||||||
tsk.Add(myTask);
|
tsk.Add(myTask);
|
||||||
|
|
||||||
//读取线程列表内的工作让cpu为其开辟线程空间并执行程序
|
//读取线程列表内的工作让cpu为其开辟线程空间并执行程序
|
||||||
foreach (var iteam in tsk)
|
foreach (var iteam in tsk)
|
||||||
{
|
{
|
||||||
@@ -305,7 +302,6 @@ namespace TetraPackOCR
|
|||||||
m_dev_cam_ocr.StreamGrabber.ImageGrabbed += StreamGrabber_ImageGrabbed_OCR;
|
m_dev_cam_ocr.StreamGrabber.ImageGrabbed += StreamGrabber_ImageGrabbed_OCR;
|
||||||
m_dev_cam_ocr.StreamGrabber.GrabStarted += StreamGrabber_GrabStarted_OCR;
|
m_dev_cam_ocr.StreamGrabber.GrabStarted += StreamGrabber_GrabStarted_OCR;
|
||||||
// 打开Software Trigger
|
// 打开Software Trigger
|
||||||
// Set Software Trigger
|
|
||||||
m_dev_cam_ocr.TriggerSet.Open(TriggerSourceEnum.Software);
|
m_dev_cam_ocr.TriggerSet.Open(TriggerSourceEnum.Software);
|
||||||
if (!m_dev_cam_ocr.GrabUsingGrabLoopThread())
|
if (!m_dev_cam_ocr.GrabUsingGrabLoopThread())
|
||||||
{
|
{
|
||||||
@@ -775,6 +771,14 @@ namespace TetraPackOCR
|
|||||||
m_DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
|
m_DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
|
||||||
lbl_DistY.Text = Y[1].Replace("mm", "");
|
lbl_DistY.Text = Y[1].Replace("mm", "");
|
||||||
log.Info("当前订单Y偏移:" + m_DistY);
|
log.Info("当前订单Y偏移:" + m_DistY);
|
||||||
|
|
||||||
|
string alignColor = sheet3.Cells[n + ocrTextRequest[1].Count - 1, 3].Value.ToString();
|
||||||
|
if (alignColor.Contains("单排"))
|
||||||
|
m_ColorMax = ocrTextRequest.Values.Select(x => x.Count).Max();// ocrTextRequest[1].Count;
|
||||||
|
else
|
||||||
|
m_ColorMax = alignColor.Replace("排布", "").Split(',').ToList().Select(int.Parse).Max();
|
||||||
|
log.Info("当前排布方式:" + alignColor);
|
||||||
|
log.Info("单行最大数量:" + m_ColorMax.ToString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -977,6 +981,7 @@ namespace TetraPackOCR
|
|||||||
}
|
}
|
||||||
private bool autorunFlag = false;
|
private bool autorunFlag = false;
|
||||||
private bool debugFlag = false;
|
private bool debugFlag = false;
|
||||||
|
private double m_textWidth = 0;
|
||||||
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)
|
||||||
@@ -998,6 +1003,7 @@ namespace TetraPackOCR
|
|||||||
|
|
||||||
InitLableColumn();
|
InitLableColumn();
|
||||||
|
|
||||||
|
m_textWidth = Convert.ToDouble(textBox1.Text);
|
||||||
ocrAcc.Clear();
|
ocrAcc.Clear();
|
||||||
debugFlag = checkBox1.Checked;
|
debugFlag = checkBox1.Checked;
|
||||||
autorunFlag = check_Autorun.Checked;
|
autorunFlag = check_Autorun.Checked;
|
||||||
@@ -1122,7 +1128,7 @@ namespace TetraPackOCR
|
|||||||
//画定位的十字点
|
//画定位的十字点
|
||||||
CPMARunStatus.DrawPointMarker(xx, yy, CogMisc.DegToRad(rr), CogColorConstants.Orange, Location_Display, ".");
|
CPMARunStatus.DrawPointMarker(xx, yy, CogMisc.DegToRad(rr), CogColorConstants.Orange, Location_Display, ".");
|
||||||
log.Info("定位计算已完成。");
|
log.Info("定位计算已完成。");
|
||||||
sendToPLC(xx, yy, rr);
|
SendToPLC(xx, yy, rr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1368,7 +1374,7 @@ namespace TetraPackOCR
|
|||||||
Ocr_picBox.BackgroundImage = Bmp;
|
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, (float)m1 / (float)ocrTextResult.Count);
|
ShowTheLansRs(mMatchingStr, (double)m1 / (double)ocrTextResult.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
NoticePLCCompleteOCR();
|
NoticePLCCompleteOCR();
|
||||||
@@ -1539,7 +1545,7 @@ namespace TetraPackOCR
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mM">PLC给的当前在第几道拍照</param>
|
/// <param name="mM">PLC给的当前在第几道拍照</param>
|
||||||
/// <param name="s">OCR字符相似度结果</param>
|
/// <param name="s">OCR字符相似度结果</param>
|
||||||
void ShowTheLansRs(float mM, float s)
|
void ShowTheLansRs(int mM, double s)
|
||||||
{
|
{
|
||||||
int mMnum = Convert.ToInt32(mM);
|
int mMnum = Convert.ToInt32(mM);
|
||||||
switch (mMnum)
|
switch (mMnum)
|
||||||
@@ -1849,194 +1855,205 @@ namespace TetraPackOCR
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 通讯发送坐标
|
#region 通讯发送坐标
|
||||||
private void sendToPLC(double x, double y, double r)
|
private void SendToPLC(double x, double y, double r)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
float xx = (float)x;
|
double xx = x;
|
||||||
float yy = (float)y;
|
double yy = y;
|
||||||
float rr = (float)r;
|
double rr = r;
|
||||||
List<float> ocrxx = new List<float>();
|
|
||||||
List<float> ocryy = new List<float>();
|
|
||||||
|
|
||||||
switch (m_ProductStandard)
|
if (ocrTextRequest[1].Count == 0)
|
||||||
{
|
return;
|
||||||
case "TBA1000Slim":
|
xx = x - (m_textWidth * m_ColorMax) / 2.0;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ocrx = 0, ocry = 0;
|
//switch (m_ProductStandard)
|
||||||
List<float> l = new List<float>();
|
// {
|
||||||
l.Add((float)NumberOfLanes);
|
// case "TBA1000Slim":
|
||||||
|
// 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>();
|
||||||
|
double ocrx = 0, ocry = 0;
|
||||||
|
locationXY.Add((float)NumberOfLanes);
|
||||||
int nol = Convert.ToInt32(NumberOfLanes);
|
int nol = Convert.ToInt32(NumberOfLanes);
|
||||||
log.Info("当前订单OCR区域共" + nol + "组:");
|
log.Info("当前订单OCR区域共" + nol + "组:");
|
||||||
|
double degree = (rr * Math.PI) / 180;
|
||||||
for (int item = 0; item < nol; item++)
|
for (int item = 0; item < nol; item++)
|
||||||
{
|
{
|
||||||
if (item == 0)
|
if (item == 0)
|
||||||
{
|
{
|
||||||
ocrx = xx - ((float)m_DistX) * ((float)Math.Cos((rr * Math.PI) / 180)) - ((float)m_DistY) * ((float)Math.Sin((rr * Math.PI) / 180));
|
ocrx = xx - m_DistX * Math.Cos(degree) - m_DistY * Math.Sin(degree);
|
||||||
l.Add(ocrx);
|
ocry = yy + m_DistY * Math.Cos(degree) - m_DistX * Math.Sin(degree);
|
||||||
ocry = yy + ((float)m_DistY) * ((float)Math.Cos((rr * Math.PI) / 180)) - ((float)m_DistX) * ((float)Math.Sin((rr * Math.PI) / 180));
|
|
||||||
l.Add(ocry);
|
|
||||||
ocrxx.Add(ocrx);
|
|
||||||
ocryy.Add(ocry);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ocrx = ocrx + ((float)m_width * ((float)Math.Cos((rr * Math.PI) / 180))) + ((float)m_Gradient * ((float)Math.Sin((rr * Math.PI) / 180)));
|
ocrx = ocrx + m_width * Math.Cos(degree) + m_Gradient * Math.Sin(degree);
|
||||||
l.Add(ocrx);
|
ocry = ocry - m_Gradient * Math.Cos(degree) + m_width * Math.Sin(degree);
|
||||||
ocry = ocry - ((float)m_Gradient * ((float)Math.Cos((rr * Math.PI) / 180))) + ((float)m_width * ((float)Math.Sin((rr * Math.PI) / 180)));
|
|
||||||
l.Add(ocry);
|
|
||||||
ocrxx.Add(ocrx);
|
|
||||||
ocryy.Add(ocry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("第" + (item + 1) + "组坐标为:X:" + ocrxx[item] + ",Y:" + ocryy[item] + "。");
|
log.Info("第" + (item + 1) + "组坐标为:X:" + ocrx + ",Y:" + ocry + "。");
|
||||||
if (ocrxx[item] < 0 || ocrxx[item] > 1600)
|
if (ocrx < 0 || ocrx > 1600)
|
||||||
{
|
{
|
||||||
EnableStartDetect();
|
EnableStartDetect();
|
||||||
log.Error("x范围 0,1600!");
|
log.Error("x范围 0,1600!");
|
||||||
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ocryy[item] < -50 || ocryy[item] > 400)
|
|
||||||
|
if (ocry < - 50)
|
||||||
|
{
|
||||||
|
ocrx = ocrx - m_height * Math.Sin(degree);
|
||||||
|
ocry = ocry + m_height * Math.Cos(degree);
|
||||||
|
log.Info("更新第" + (item + 1) + "组坐标为:X:" + ocrx + ",Y:" + ocry + "。");
|
||||||
|
}
|
||||||
|
else if (ocry > 400)
|
||||||
|
{
|
||||||
|
ocrx = ocrx + m_height * Math.Sin(degree);
|
||||||
|
ocry = ocry - m_height * Math.Cos(degree);
|
||||||
|
log.Info("更新第" + (item + 1) + "组坐标为:X:" + ocrx + ",Y:" + ocry + "。");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ocry < -50 || ocry > 400)
|
||||||
{
|
{
|
||||||
EnableStartDetect();
|
EnableStartDetect();
|
||||||
log.Error("y范围 -50,400!");
|
log.Error("y范围 -50,400!");
|
||||||
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
locationXY.Add((float)ocrx);
|
||||||
|
locationXY.Add((float)ocry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_Autorun.Checked == false && !debugFlag)
|
if (check_Autorun.Checked == false && !debugFlag)
|
||||||
{
|
{
|
||||||
List<float> d = new List<float>();
|
List<float> plcXY = new List<float>();
|
||||||
for (int i = 0; i < l.Count; i++)
|
for (int i = 0; i < locationXY.Count; i++)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
d.Add(l[i]);
|
plcXY.Add(locationXY[i]);
|
||||||
}
|
}
|
||||||
else if (i % 2 == 1)
|
else if (i % 2 == 1)
|
||||||
{
|
{
|
||||||
d.Add(l[l.Count - i - 1]);
|
plcXY.Add(locationXY[locationXY.Count - i - 1]);
|
||||||
d.Add(l[l.Count - i]);
|
plcXY.Add(locationXY[locationXY.Count - i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NoticePLCCompleteDet(DataConverter.FloatToByte(d, true));
|
NoticePLCCompleteDet(DataConverter.FloatToByte(plcXY, true));
|
||||||
log.Info("坐标已发送完成。");
|
log.Info("坐标已发送完成。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user