添添加功能:1、增加采图工具 2、增加拖拽后值传递功能 3、

This commit is contained in:
liu.wenjie
2019-08-09 20:52:17 +08:00
committed by liu.wenjie
parent 9d8944dcc3
commit 4dbab27caf
162 changed files with 225412 additions and 205 deletions

View File

@@ -11,68 +11,84 @@ namespace FindLineTool
[Serializable]
public class FindLine:IToolBase
{
internal bool toolEnable = true;
public bool toolEnable = true;
/// <summary>
/// 输入姿态
/// </summary>
internal PosXYU inputPose = new PosXYU();
public PosXYU inputPose = new PosXYU();
/// <summary>
/// 制作模板时的输入位姿
/// </summary>
internal PosXYU templatePose = new PosXYU();
public PosXYU templatePose = new PosXYU();
/// <summary>
/// 期望线起点行坐标
/// </summary>
internal HTuple expectLineStartRow = 200;
public HTuple expectLineStartRow = 200;
/// <summary>
/// 卡尺
/// </summary>
internal HObject contours;
public HObject contoursDisp = null;
/// <summary>
/// 箭头
/// </summary>
public HObject arrowDisp = null;
/// <summary>
/// 交点
/// </summary>
public HObject crossDisp = null;
/// <summary>
/// 期望线起点列坐标
/// </summary>
internal HTuple expectLineStartCol = 200;
public HTuple expectLineStartCol = 200;
/// <summary>
/// 期望线终点行坐标
/// </summary>
internal HTuple expectLineEndRow = 200;
public HTuple expectLineEndRow = 200;
/// <summary>
/// 期望线终点列坐标
/// </summary>
internal HTuple expectLineEndCol = 600;
public HTuple expectLineEndCol = 600;
/// <summary>
/// 找边极性,从明到暗或从暗到明
/// </summary>
internal string polarity = "negative";
public string polarity = "negative";
/// <summary>
/// 卡尺数量
/// </summary>
internal int cliperNum = 20;
public int cliperNum = 20;
/// <summary>
/// 卡尺高
/// </summary>
internal int length = 80;
public int length = 80;
/// <summary>
/// 卡尺宽
/// </summary>
internal int weidth = 5;
public int weidth = 5;
/// <summary>
/// 边阈值
/// </summary>
internal int threshold = 30;
public int threshold = 30;
/// <summary>
/// 边Sigma
/// </summary>
internal double sigma = 1.0;
public double sigma = 1.0;
/// <summary>
/// 选择所查找到的边
/// </summary>
internal string edgeSelect = "all";
public string edgeSelect = "all";
/// <summary>
/// 分数阈值
/// </summary>
internal double _minScore = 0.5;
internal double minScore
public double _minScore = 0.5;
/// <summary>
/// 矩形框显示
/// </summary>
public bool dispRec = true;
/// <summary>
/// 交点显示
/// </summary>
public bool dispCross = true;
public double minScore
{
get
{
@@ -93,11 +109,15 @@ namespace FindLineTool
_minScore = value;
}
}
}
}
/// <summary>
/// 找到的线段
/// </summary>
internal Line resultLine = new Line();
public Line resultLine = null;
/// <summary>
/// 显示的线
/// </summary>
public HObject LineDisp = null;
/// <summary>
/// 新的跟随姿态变化后的预期线信息
/// </summary>
@@ -168,12 +188,15 @@ namespace FindLineTool
set { _angle = value; }
}
public HObject inputImage { get; set; }
public HObject inputImage { get; set; } = null;
public ToolRunStatu toolRunStatu { get; set; }
public ToolRunStatu toolRunStatu { get; set; } = ToolRunStatu.Not_Run;
public void DispImage()
{
FormFindLine.Instance.myHwindow.HobjectToHimage(inputImage);
if(inputImage != null)
{
FormFindLine.Instance.myHwindow.HobjectToHimage(inputImage);
}
}
public void UpdateImage()
@@ -184,7 +207,11 @@ namespace FindLineTool
public void Run()
{
if(inputImage == null)
HTuple homMat2DArrow = null;
HObject arrow = null, arrowTrans = null;
HObject drawLine = null, imageReducedLine;
if (inputImage == null)
{
FormFindLine.Instance.TextBoxMessageDisp("图像为空", System.Drawing.Color.Red);
toolRunStatu = ToolRunStatu.Not_Input_Image;
@@ -237,61 +264,35 @@ namespace FindLineTool
//显示所有卡尺
HTuple pointRow, pointCol;
HOperatorSet.GetMetrologyObjectMeasures(out contours, handleID, new HTuple("all"), new HTuple("all"), out pointRow, out pointCol);
HOperatorSet.SetColor(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, new HTuple("blue"));
HOperatorSet.DispObj(contours, FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow);
FormFindLine.Instance.myHwindow.DispObj(contours, "blue");
HOperatorSet.GetMetrologyObjectMeasures(out contoursDisp, handleID, new HTuple("all"), new HTuple("all"), out pointRow, out pointCol);
//显示指示找线方向的箭头
HTuple arrowAngle;
HOperatorSet.AngleLx(newExpectLineStartRow, newExpectLineStartCol, newExpectLineEndRow, newExpectLineEndCol, out arrowAngle);
#region
#region
HTuple arrowRow = null, arrowColumn = null;
HOperatorSet.GenRegionLine(out drawLine, newExpectLineStartRow, newExpectLineStartCol, newExpectLineEndRow, newExpectLineEndCol);
HOperatorSet.ReduceDomain(inputImage, drawLine, out imageReducedLine);
HOperatorSet.GetRegionPoints(imageReducedLine, out arrowRow, out arrowColumn);
if(arrowRow.Length < 200)
{
CommonMethods.CommonMethods.gen_arrow_contour_xld(out arrow, arrowRow[0], arrowColumn[0], arrowRow[arrowRow.Length-1], arrowColumn[arrowRow.Length - 1], 20, 20);
}
else
{
CommonMethods.CommonMethods.gen_arrow_contour_xld(out arrow, arrowRow[0], arrowColumn[0], arrowRow[200], arrowColumn[200], 20, 20);
}
HOperatorSet.VectorAngleToRigid(newExpectLineStartRow, newExpectLineStartCol, 0, (newExpectLineStartRow + newExpectLineEndRow) / 2, (newExpectLineStartCol + newExpectLineEndCol) / 2, new HTuple(-90).TupleRad(), out homMat2DArrow);
HOperatorSet.AffineTransContourXld(arrow, out arrowDisp, homMat2DArrow);
#endregion
arrowAngle = arrowAngle + Math.PI / 2;
arrowAngle = arrowAngle.TupleDeg();
HTuple row = (newExpectLineStartRow + newExpectLineEndRow) / 2;
HTuple column = (newExpectLineStartCol + newExpectLineEndCol) / 2;
double drow, dcolumn;
double arrowLength = length + 100;
if (0 <= arrowAngle && arrowAngle <= 90)
{
drow = Math.Abs(arrowLength * Math.Sin(((HTuple)arrowAngle).TupleRad()));
dcolumn = Math.Abs(arrowLength * Math.Cos(((HTuple)arrowAngle).TupleRad()));
HOperatorSet.DispArrow(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, row, column, row - drow, column + dcolumn, 5.0);
}
else if (arrowAngle > 90 && arrowAngle <= 180)
{
drow = arrowLength * Math.Sin(((HTuple)(180 - arrowAngle)).TupleRad());
dcolumn = arrowLength * Math.Cos(((HTuple)(180 - arrowAngle)).TupleRad());
HOperatorSet.DispArrow(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, row, column, row - drow, column - dcolumn, 5.0);
}
else if (arrowAngle < 0 && arrowAngle >= -90)
{
drow = arrowLength * Math.Sin(((HTuple)arrowAngle * -1).TupleRad());
dcolumn = arrowLength * Math.Cos(((HTuple)arrowAngle * -1).TupleRad());
HOperatorSet.DispArrow(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, row, column, row + drow, column + dcolumn, 5.0);
}
else if (arrowAngle < -90 && arrowAngle >= -180)
{
drow = Math.Abs(arrowLength * Math.Sin(((HTuple)arrowAngle + 180).TupleRad()));
dcolumn = Math.Abs(arrowLength * Math.Cos(((HTuple)arrowAngle + 180).TupleRad()));
HOperatorSet.DispArrow(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, row, column, row + drow, column - dcolumn, 5.0);
}
//把点显示出来
HObject cross;
HOperatorSet.GenCrossContourXld(out cross, pointRow, pointCol, new HTuple(12), new HTuple(0));
HOperatorSet.SetColor(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, new HTuple("orange"));
HOperatorSet.DispObj(cross, FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow);
FormFindLine.Instance.myHwindow.DispObj(cross, "orange");
HOperatorSet.GenCrossContourXld(out crossDisp, pointRow, pointCol, new HTuple(12), new HTuple(0));
//得到所找到的线
HTuple parameter;
HObject line;
HOperatorSet.GetMetrologyObjectResult(handleID, new HTuple("all"), new HTuple("all"), new HTuple("result_type"), new HTuple("all_param"), out parameter);
HOperatorSet.GetMetrologyObjectResultContour(out line, handleID, new HTuple("all"), new HTuple("all"), new HTuple(1.5));
HOperatorSet.GetMetrologyObjectResultContour(out LineDisp, handleID, new HTuple("all"), new HTuple("all"), new HTuple(1.5));
if (parameter.Length >= 4)
{
@@ -302,16 +303,12 @@ namespace FindLineTool
Point start = new Point() { Row = ResultLineStartRow, Col = ResultLineStartCol };
Point end = new Point() { Row = ResultLineEndRow, Col = ResultLineEndCol };
resultLine = new Line() { StartPoint = start, EndPoint = end };
//显示找到的线
HOperatorSet.SetColor(FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow, new HTuple("green"));
// HOperatorSet.DispObj(line, GetWindowHandle(jobName));
FormFindLine.Instance.myHwindow.hWindowControl.HalconWindow.SetLineWidth(2);
FormFindLine.Instance.myHwindow.DispObj(line, "green");
}
DispMainWindow(FormFindLine.Instance.myHwindow);
HOperatorSet.AngleLx(ResultLineStartRow, ResultLineStartCol, ResultLineEndRow, ResultLineEndCol, out _angle);
HOperatorSet.ClearMetrologyModel(handleID);
// 参数传递
ParamsTrans();
FormFindLine.Instance.tbx_resultStartRow.Text = ResultLineStartRow.ToString();
FormFindLine.Instance.tbx_resultStartCol.Text = ResultLineEndCol.ToString();
FormFindLine.Instance.tbx_resultEndRow.Text = ResultLineEndRow.ToString();
@@ -323,6 +320,12 @@ namespace FindLineTool
{
FormFindLine.Instance.TextBoxMessageDisp("工具运行异常" + ex.Message, System.Drawing.Color.Red);
}
finally
{
//homMat2DArrow.Dispose();
//arrow.Dispose();
//arrowTrans.Dispose();
}
}
internal void DrawExpectLine(HWindow_Final myHwindow)
@@ -363,6 +366,35 @@ namespace FindLineTool
}
/// <summary>
/// 将数据传递给FindlineToolInterface
/// </summary>
private void ParamsTrans()
{
FormFindLine.Instance.myToolInfo.toolOutput.Clear();
FormFindLine.Instance.myToolInfo.toolOutput.Add(new ToolIO("outputXld", resultLine, DataType.Line));
FormFindLine.Instance.myToolInfo.toolOutput.Add(new ToolIO("StartPoint.Row", ResultLineStartRow, DataType.IntValue));
FormFindLine.Instance.myToolInfo.toolOutput.Add(new ToolIO("StartPoint.Column", ResultLineStartCol, DataType.IntValue));
FormFindLine.Instance.myToolInfo.toolOutput.Add(new ToolIO("EndPoint.Row", ResultLineEndRow, DataType.IntValue));
FormFindLine.Instance.myToolInfo.toolOutput.Add(new ToolIO("EndPoint.Column", ResultLineEndCol, DataType.IntValue));
}
public void DispMainWindow(HWindow_Final window)
{
// 显示矩形
if (dispRec)
{
window.DispObj(contoursDisp, "blue");
}
// 显示交点
if (dispCross)
{
window.DispObj(arrowDisp, "red");
window.DispObj(crossDisp, "orange");
}
//显示找到的线
window.DispObj(LineDisp, "green");
}
}
}

View File

@@ -31,6 +31,9 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormFindLine));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.chBDispCross = new System.Windows.Forms.CheckBox();
this.chBDispRec = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
@@ -52,10 +55,14 @@
this.label9 = new System.Windows.Forms.Label();
this.tbx_minScore = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.tbx_caliperLength2 = new System.Windows.Forms.TextBox();
this.tbx_Sigma = new System.Windows.Forms.TextBox();
this.tbx_caliperLength = new System.Windows.Forms.TextBox();
this.tbx_threshold = new System.Windows.Forms.TextBox();
this.tbx_caliperNum = new System.Windows.Forms.TextBox();
@@ -64,20 +71,13 @@
this.btn_moveCliperRegion = new System.Windows.Forms.Button();
this.cbx_edgeSelect = new System.Windows.Forms.ComboBox();
this.txbLog = new System.Windows.Forms.TextBox();
this.tbx_Sigma = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.tbx_caliperLength2 = new System.Windows.Forms.TextBox();
this.label16 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
@@ -128,6 +128,39 @@
this.panel1.Size = new System.Drawing.Size(563, 479);
this.panel1.TabIndex = 272;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.chBDispCross);
this.groupBox3.Controls.Add(this.chBDispRec);
this.groupBox3.Location = new System.Drawing.Point(296, 200);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(213, 96);
this.groupBox3.TabIndex = 319;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "显示";
//
// chBDispCross
//
this.chBDispCross.AutoSize = true;
this.chBDispCross.Location = new System.Drawing.Point(29, 60);
this.chBDispCross.Name = "chBDispCross";
this.chBDispCross.Size = new System.Drawing.Size(96, 16);
this.chBDispCross.TabIndex = 0;
this.chBDispCross.Text = "结果显示交点";
this.chBDispCross.UseVisualStyleBackColor = true;
this.chBDispCross.CheckedChanged += new System.EventHandler(this.chBDispCross_CheckedChanged);
//
// chBDispRec
//
this.chBDispRec.AutoSize = true;
this.chBDispRec.Location = new System.Drawing.Point(29, 29);
this.chBDispRec.Name = "chBDispRec";
this.chBDispRec.Size = new System.Drawing.Size(108, 16);
this.chBDispRec.TabIndex = 0;
this.chBDispRec.Text = "结果显示矩形框";
this.chBDispRec.UseVisualStyleBackColor = true;
this.chBDispRec.CheckedChanged += new System.EventHandler(this.chBDispRec_CheckedChanged);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label3);
@@ -343,6 +376,17 @@
this.label5.TabIndex = 279;
this.label5.Text = "结果选择:";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label16.Location = new System.Drawing.Point(34, 280);
this.label16.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(65, 20);
this.label16.TabIndex = 302;
this.label16.Text = "卡尺宽:";
//
// label14
//
this.label14.AutoSize = true;
@@ -354,6 +398,17 @@
this.label14.TabIndex = 302;
this.label14.Text = "卡尺长:";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label15.Location = new System.Drawing.Point(36, 347);
this.label15.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(54, 20);
this.label15.TabIndex = 310;
this.label15.Text = "Sigma:";
//
// label13
//
this.label13.AutoSize = true;
@@ -387,6 +442,24 @@
this.label11.TabIndex = 298;
this.label11.Text = "极性:";
//
// tbx_caliperLength2
//
this.tbx_caliperLength2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tbx_caliperLength2.Location = new System.Drawing.Point(124, 277);
this.tbx_caliperLength2.Margin = new System.Windows.Forms.Padding(2);
this.tbx_caliperLength2.Name = "tbx_caliperLength2";
this.tbx_caliperLength2.Size = new System.Drawing.Size(92, 26);
this.tbx_caliperLength2.TabIndex = 301;
//
// tbx_Sigma
//
this.tbx_Sigma.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tbx_Sigma.Location = new System.Drawing.Point(126, 344);
this.tbx_Sigma.Margin = new System.Windows.Forms.Padding(2);
this.tbx_Sigma.Name = "tbx_Sigma";
this.tbx_Sigma.Size = new System.Drawing.Size(92, 26);
this.tbx_Sigma.TabIndex = 309;
//
// tbx_caliperLength
//
this.tbx_caliperLength.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -429,24 +502,26 @@
//
// btn_runFindLineTool
//
this.btn_runFindLineTool.BackColor = System.Drawing.Color.White;
this.btn_runFindLineTool.Location = new System.Drawing.Point(440, 400);
this.btn_runFindLineTool.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btn_runFindLineTool.Name = "btn_runFindLineTool";
this.btn_runFindLineTool.Size = new System.Drawing.Size(90, 48);
this.btn_runFindLineTool.TabIndex = 270;
this.btn_runFindLineTool.Text = "运行";
this.btn_runFindLineTool.UseVisualStyleBackColor = true;
this.btn_runFindLineTool.UseVisualStyleBackColor = false;
this.btn_runFindLineTool.Click += new System.EventHandler(this.btn_runFindLineTool_Click);
//
// btn_moveCliperRegion
//
this.btn_moveCliperRegion.BackColor = System.Drawing.Color.White;
this.btn_moveCliperRegion.Location = new System.Drawing.Point(296, 400);
this.btn_moveCliperRegion.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btn_moveCliperRegion.Name = "btn_moveCliperRegion";
this.btn_moveCliperRegion.Size = new System.Drawing.Size(90, 48);
this.btn_moveCliperRegion.TabIndex = 269;
this.btn_moveCliperRegion.Text = "编辑卡尺";
this.btn_moveCliperRegion.UseVisualStyleBackColor = true;
this.btn_moveCliperRegion.UseVisualStyleBackColor = false;
this.btn_moveCliperRegion.Click += new System.EventHandler(this.btn_moveCliperRegion_Click);
//
// cbx_edgeSelect
@@ -473,77 +548,6 @@
this.txbLog.Size = new System.Drawing.Size(1129, 21);
this.txbLog.TabIndex = 274;
//
// tbx_Sigma
//
this.tbx_Sigma.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tbx_Sigma.Location = new System.Drawing.Point(126, 344);
this.tbx_Sigma.Margin = new System.Windows.Forms.Padding(2);
this.tbx_Sigma.Name = "tbx_Sigma";
this.tbx_Sigma.Size = new System.Drawing.Size(92, 26);
this.tbx_Sigma.TabIndex = 309;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label15.Location = new System.Drawing.Point(36, 347);
this.label15.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(54, 20);
this.label15.TabIndex = 310;
this.label15.Text = "Sigma:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.checkBox2);
this.groupBox3.Controls.Add(this.checkBox1);
this.groupBox3.Location = new System.Drawing.Point(296, 200);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(213, 96);
this.groupBox3.TabIndex = 319;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "显示";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(29, 29);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(108, 16);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "结果显示矩形框";
this.checkBox1.UseVisualStyleBackColor = true;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(29, 60);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(96, 16);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "结果显示交点";
this.checkBox2.UseVisualStyleBackColor = true;
//
// tbx_caliperLength2
//
this.tbx_caliperLength2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tbx_caliperLength2.Location = new System.Drawing.Point(124, 277);
this.tbx_caliperLength2.Margin = new System.Windows.Forms.Padding(2);
this.tbx_caliperLength2.Name = "tbx_caliperLength2";
this.tbx_caliperLength2.Size = new System.Drawing.Size(92, 26);
this.tbx_caliperLength2.TabIndex = 301;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label16.Location = new System.Drawing.Point(34, 280);
this.label16.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(65, 20);
this.label16.TabIndex = 302;
this.label16.Text = "卡尺宽:";
//
// FormFindLine
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -554,18 +558,19 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FormFindLine";
this.Text = "找线工具";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormFindLine_FormClosing);
this.Load += new System.EventHandler(this.FormFindLine_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -611,8 +616,8 @@
private System.Windows.Forms.Label label15;
public System.Windows.Forms.TextBox tbx_Sigma;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox chBDispCross;
private System.Windows.Forms.CheckBox chBDispRec;
private System.Windows.Forms.Label label16;
public System.Windows.Forms.TextBox tbx_caliperLength2;
}

View File

@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -26,15 +27,25 @@ namespace FindLineTool
{
get
{
lock (_instance)
if(_instance != null)
{
if (_instance == null)
lock (_instance)
{
object line = new object();
_instance = new FormFindLine(ref line);
}
if (_instance == null)
{
object line = new object();
_instance = new FormFindLine(ref line);
}
return _instance;
}
}
else
{
object line = new object();
_instance = new FormFindLine(ref line);
return _instance;
}
}
}
@@ -45,9 +56,9 @@ namespace FindLineTool
_instance = this;
myToolInfo = (IToolInfo)findLine;
myFindLine = (FindLine)myToolInfo.tool;
myFindLine.inputImage = ComGlobalParams.inputImageGlobal; // 暂时直接将图像传递给该工具
//myFindLine.inputImage = ComGlobalParams.inputImageGlobal; // 暂时直接将图像传递给该工具
myFindLine.DispImage();
}
private void FormFindLine_Load(object sender, EventArgs e)
@@ -59,9 +70,11 @@ namespace FindLineTool
private void btn_moveCliperRegion_Click(object sender, EventArgs e)
{
myFindLine.UpdateImage();
myFindLine.DrawExpectLine(myHwindow);
}
public void TextBoxMessageDisp(string mes, Color setColor)
{
txbLog.BackColor = setColor;
@@ -84,7 +97,7 @@ namespace FindLineTool
myFindLine.threshold = Convert.ToInt16(tbx_threshold.Text.Trim());
myFindLine.length = Convert.ToInt16(tbx_caliperLength.Text.Trim());
myFindLine.weidth = Convert.ToInt16(tbx_caliperLength2.Text.Trim());
myFindLine.polarity = cbx_polarity.SelectedItem.ToString() == "明到暗" ? "negative":"positive";
myFindLine.polarity = cbx_polarity.SelectedItem.ToString() == "明到暗" ? "negative":"positive";
myFindLine.edgeSelect = cbx_edgeSelect.SelectedItem.ToString();
myFindLine.sigma = Convert.ToDouble(tbx_Sigma.Text.Trim());
// Run
@@ -105,12 +118,14 @@ namespace FindLineTool
tbx_expectLineEndCol.Text = myFindLine.expectLineEndCol.ToString();
cbx_edgeSelect.Text = myFindLine.edgeSelect;
tbx_minScore.Text = myFindLine.minScore.ToString();
cbx_polarity.Text = myFindLine.polarity == "positive" ? "暗到明" : "明到暗";
cbx_polarity.Text = myFindLine.polarity == "positive" ? "暗到明" : "明到暗";
tbx_caliperNum.Text = myFindLine.cliperNum.ToString();
tbx_caliperLength.Text = myFindLine.length.ToString();
tbx_threshold.Text = myFindLine.threshold.ToString();
tbx_Sigma.Text = myFindLine.sigma.ToString();
tbx_caliperLength2.Text = myFindLine.weidth.ToString();
chBDispRec.Checked = myFindLine.dispRec;
chBDispCross.Checked = myFindLine.dispCross;
}
#region
@@ -165,6 +180,40 @@ namespace FindLineTool
tbx_expectLineEndCol.Text = "600";
}
}
private void chBDispRec_CheckedChanged(object sender, EventArgs e)
{
if(chBDispRec.Checked)
{
myFindLine.dispRec = true;
}
else
{
myFindLine.dispRec = false;
}
}
private void chBDispCross_CheckedChanged(object sender, EventArgs e)
{
if(chBDispCross.Checked)
{
myFindLine.dispCross = true;
}
else
{
myFindLine.dispCross = false;
}
}
#endregion
private void FormFindLine_FormClosing(object sender, FormClosingEventArgs e)
{
myHwindow.Dispose();
this.Dispose();
this.Dispose();
GC.Collect();
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.