mirror of
https://github.com/eggplantlwj/VisionEdit.git
synced 2026-04-15 08:26:36 +08:00
1、修复找线工具的selectObject无法实时跟随的问题
2、可以重定义找线工具的初始位置 3、在工具初始化时加入防止其他事件更改UI参数的逻辑,以解决工具参数无法保存的bug
This commit is contained in:
Binary file not shown.
@@ -16,10 +16,53 @@ namespace FindLineTool
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PosXYU inputPose = new PosXYU();
|
public PosXYU inputPose = new PosXYU();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 输入姿态
|
||||||
|
/// </summary>
|
||||||
|
public HTuple inputPoseHomMat2D = new HTuple();
|
||||||
|
/// <summary>
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> 751e985 (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> 8c64a4f (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> 751e985 (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
/// 位置修正姿态
|
||||||
|
/// </summary>
|
||||||
|
public HTuple changePoseHomMat2D = new HTuple();
|
||||||
|
/// <summary>
|
||||||
|
/// 制作模板时的位姿
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
=======
|
||||||
|
>>>>>>> fa76389 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> b070592 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> fa76389 (修正FindLine工具无法位置跟随的问题)
|
||||||
/// 制作模板时的输入位姿
|
/// 制作模板时的输入位姿
|
||||||
|
>>>>>>> b070592 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> 751e985 (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> 8c64a4f (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> 751e985 (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PosXYU templatePose = new PosXYU();
|
public PosXYU templatePose = new PosXYU();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 修改的位姿
|
||||||
|
/// </summary>
|
||||||
|
public HTuple changedPose = new HTuple();
|
||||||
|
/// <summary>
|
||||||
/// 卡尺
|
/// 卡尺
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HObject contoursDisp = null;
|
public HObject contoursDisp = null;
|
||||||
@@ -50,7 +93,11 @@ namespace FindLineTool
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新的跟随姿态变化后的预期线信息
|
/// 新的跟随姿态变化后的预期线信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
HTuple newExpectLineStartRow = new HTuple(200), newExpectLineStartCol = new HTuple(200), newExpectLineEndRow = new HTuple(200), newExpectLineEndCol = new HTuple(600);
|
public HTuple modelStartRow = new HTuple(200), modelStartCol = new HTuple(200), modelEndRow = new HTuple(200), modelEndCol = new HTuple(600);
|
||||||
|
/// <summary>
|
||||||
|
/// 新的跟随姿态变化后的预期线信息
|
||||||
|
/// </summary>
|
||||||
|
public HTuple newExpectLineStartRow = new HTuple(200), newExpectLineStartCol = new HTuple(200), newExpectLineEndRow = new HTuple(200), newExpectLineEndCol = new HTuple(600);
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 区域中心行坐标
|
///// 区域中心行坐标
|
||||||
///// </summary>
|
///// </summary>
|
||||||
@@ -214,7 +261,16 @@ namespace FindLineTool
|
|||||||
FormFindLine.Instance.myHwindow.DispHWindow.ClearWindow();
|
FormFindLine.Instance.myHwindow.DispHWindow.ClearWindow();
|
||||||
DispImage();
|
DispImage();
|
||||||
}
|
}
|
||||||
|
// 更新模板线的位置,并生成变换矩阵
|
||||||
|
public void UpdateModelLineLocation()
|
||||||
|
{
|
||||||
|
// 计算新的位置线和转换之后位置线之间的差异,再将差异补偿到模板位置线中
|
||||||
|
HOperatorSet.VectorToSimilarity(new HTuple(newExpectLineStartRow, newExpectLineEndRow), new HTuple(newExpectLineStartCol, newExpectLineEndCol),
|
||||||
|
new HTuple(expectLineStartRow, expectLineEndRow), new HTuple(expectLineStartCol, expectLineEndCol), out changePoseHomMat2D);
|
||||||
|
// 更新位置
|
||||||
|
HOperatorSet.AffineTransPixel(changePoseHomMat2D, modelStartRow, modelStartCol, out modelStartRow, out modelStartCol);
|
||||||
|
HOperatorSet.AffineTransPixel(changePoseHomMat2D, modelEndRow, modelEndCol, out modelEndRow, out modelEndCol);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Run(SoftwareRunState softwareRunState)
|
public override void Run(SoftwareRunState softwareRunState)
|
||||||
{
|
{
|
||||||
@@ -235,20 +291,62 @@ namespace FindLineTool
|
|||||||
{
|
{
|
||||||
UpdateImage();
|
UpdateImage();
|
||||||
}
|
}
|
||||||
if (inputPose != null)
|
if (inputPoseHomMat2D != null)
|
||||||
{
|
{
|
||||||
HTuple Row = inputPose.X - templatePose.X;
|
<<<<<<< HEAD
|
||||||
HTuple Col = inputPose.Y - templatePose.Y;
|
<<<<<<< HEAD
|
||||||
HTuple angle = inputPose.U - templatePose.U;
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
//对预期线的起始点做放射变换
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelStartRow, modelStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelEndRow, modelEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
||||||
|
=======
|
||||||
|
=======
|
||||||
|
>>>>>>> fa76389 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> b070592 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> fa76389 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
//HTuple Row = inputPose.X - templatePose.X;
|
||||||
|
//HTuple Col = inputPose.Y - templatePose.Y;
|
||||||
|
//HTuple angle = inputPose.U - templatePose.U;
|
||||||
|
|
||||||
HTuple _homMat2D;
|
//HTuple _homMat2D;
|
||||||
HOperatorSet.HomMat2dIdentity(out _homMat2D);
|
//HOperatorSet.HomMat2dIdentity(out _homMat2D);
|
||||||
HOperatorSet.HomMat2dRotate(_homMat2D, (HTuple)(angle), (HTuple)templatePose.X, (HTuple)templatePose.Y, out _homMat2D);
|
//HOperatorSet.HomMat2dRotate(_homMat2D, (HTuple)(angle), (HTuple)templatePose.X, (HTuple)templatePose.Y, out _homMat2D);
|
||||||
HOperatorSet.HomMat2dTranslate(_homMat2D, (HTuple)(Row), (HTuple)(Col), out _homMat2D);
|
//HOperatorSet.HomMat2dTranslate(_homMat2D, (HTuple)(Row), (HTuple)(Col), out _homMat2D);
|
||||||
|
|
||||||
//对预期线的起始点做放射变换
|
//对预期线的起始点做放射变换
|
||||||
HOperatorSet.AffineTransPixel(_homMat2D, (HTuple)expectLineStartRow, (HTuple)expectLineStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, (HTuple)expectLineStartRow, (HTuple)expectLineStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||||
HOperatorSet.AffineTransPixel(_homMat2D, (HTuple)expectLineEndRow, (HTuple)expectLineEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, (HTuple)expectLineEndRow, (HTuple)expectLineEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
>>>>>>> b070592 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> fa76389 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
//对预期线的起始点做放射变换
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelStartRow, modelStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelEndRow, modelEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
||||||
|
>>>>>>> 751e985 (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
=======
|
||||||
|
//对预期线的起始点做放射变换
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelStartRow, modelStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelEndRow, modelEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
||||||
|
>>>>>>> 8c64a4f (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> b070592 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
>>>>>>> fa76389 (修正FindLine工具无法位置跟随的问题)
|
||||||
|
=======
|
||||||
|
//对预期线的起始点做放射变换
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelStartRow, modelStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||||
|
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, modelEndRow, modelEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
||||||
|
>>>>>>> 751e985 (1、修复找线工具的selectObject无法实时跟随的问题)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
<Reference Include="halcondotnet">
|
<Reference Include="halcondotnet">
|
||||||
<HintPath>C:\Program Files\MVTec\HALCON-19.05-Progress\bin\dotnet20\halcondotnet.dll</HintPath>
|
<HintPath>C:\Program Files\MVTec\HALCON-19.05-Progress\bin\dotnet20\halcondotnet.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="SunnyUI">
|
||||||
|
<HintPath>..\VisionEdit\bin\Debug\ThirdLib\SunnyUI.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace FindLineTool
|
|||||||
myFindLine.inputImage = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HObject;
|
myFindLine.inputImage = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HObject;
|
||||||
break;
|
break;
|
||||||
case "InputPos":
|
case "InputPos":
|
||||||
myFindLine.inputPose = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as PosXYU;
|
myFindLine.inputPoseHomMat2D = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HTuple;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
17
FindLine/FormFindLine.Designer.cs
generated
17
FindLine/FormFindLine.Designer.cs
generated
@@ -71,6 +71,7 @@ namespace FindLineTool
|
|||||||
this.label7 = new System.Windows.Forms.Label();
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
this.label9 = new System.Windows.Forms.Label();
|
this.label9 = new System.Windows.Forms.Label();
|
||||||
|
this.btnSetModelPose = new Sunny.UI.UISymbolButton();
|
||||||
this.toolStrip1.SuspendLayout();
|
this.toolStrip1.SuspendLayout();
|
||||||
this.statusStrip.SuspendLayout();
|
this.statusStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||||
@@ -189,6 +190,7 @@ namespace FindLineTool
|
|||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.btnSetModelPose);
|
||||||
this.groupBox1.Controls.Add(this.label6);
|
this.groupBox1.Controls.Add(this.label6);
|
||||||
this.groupBox1.Controls.Add(this.tbx_minScore);
|
this.groupBox1.Controls.Add(this.tbx_minScore);
|
||||||
this.groupBox1.Controls.Add(this.label5);
|
this.groupBox1.Controls.Add(this.label5);
|
||||||
@@ -544,6 +546,20 @@ namespace FindLineTool
|
|||||||
this.label9.TabIndex = 105;
|
this.label9.TabIndex = 105;
|
||||||
this.label9.Text = "起点列坐标:";
|
this.label9.Text = "起点列坐标:";
|
||||||
//
|
//
|
||||||
|
// btnSetModelPose
|
||||||
|
//
|
||||||
|
this.btnSetModelPose.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnSetModelPose.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.btnSetModelPose.IsScaled = false;
|
||||||
|
this.btnSetModelPose.Location = new System.Drawing.Point(40, 437);
|
||||||
|
this.btnSetModelPose.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.btnSetModelPose.Name = "btnSetModelPose";
|
||||||
|
this.btnSetModelPose.Size = new System.Drawing.Size(352, 35);
|
||||||
|
this.btnSetModelPose.Symbol = 361771;
|
||||||
|
this.btnSetModelPose.TabIndex = 334;
|
||||||
|
this.btnSetModelPose.Text = "标定为模板位置";
|
||||||
|
this.btnSetModelPose.Click += new System.EventHandler(this.btnSetModelPose_Click);
|
||||||
|
//
|
||||||
// FormFindLine
|
// FormFindLine
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
@@ -624,5 +640,6 @@ namespace FindLineTool
|
|||||||
private System.Windows.Forms.ToolStripStatusLabel lb_RunStatus;
|
private System.Windows.Forms.ToolStripStatusLabel lb_RunStatus;
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
|
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
|
||||||
private System.Windows.Forms.ToolStripStatusLabel lb_RunTime;
|
private System.Windows.Forms.ToolStripStatusLabel lb_RunTime;
|
||||||
|
private Sunny.UI.UISymbolButton btnSetModelPose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,10 @@ namespace FindLineTool
|
|||||||
myHwindow.Dock = DockStyle.Fill;
|
myHwindow.Dock = DockStyle.Fill;
|
||||||
InitTool();
|
InitTool();
|
||||||
}
|
}
|
||||||
|
bool isInit = false;
|
||||||
private void InitTool()
|
private void InitTool()
|
||||||
{
|
{
|
||||||
|
isInit = true;
|
||||||
this.Text = myToolInfo.toolName;
|
this.Text = myToolInfo.toolName;
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
@@ -84,14 +86,16 @@ namespace FindLineTool
|
|||||||
tbx_caliperLength2.Text = myFindLine.weidth.ToString();
|
tbx_caliperLength2.Text = myFindLine.weidth.ToString();
|
||||||
chBDispRec.Checked = myFindLine.dispRec;
|
chBDispRec.Checked = myFindLine.dispRec;
|
||||||
chBDispCross.Checked = myFindLine.dispCross;
|
chBDispCross.Checked = myFindLine.dispCross;
|
||||||
// 将要编辑的线显示
|
//// 将要编辑的线显示
|
||||||
selected_drawing_object = HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.LINE, new HTuple[] { myFindLine.expectLineStartRow, myFindLine.expectLineStartCol, myFindLine.expectLineEndRow, myFindLine.expectLineEndCol });
|
selected_drawing_object = myFindLine.inputPoseHomMat2D != null? HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.LINE, new HTuple[] { myFindLine.newExpectLineStartRow, myFindLine.newExpectLineStartCol, myFindLine.newExpectLineEndRow, myFindLine.newExpectLineEndCol })
|
||||||
|
:HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.LINE, new HTuple[] {myFindLine.modelStartRow, myFindLine.modelStartCol, myFindLine.modelEndRow, myFindLine.modelEndCol });
|
||||||
GC.KeepAlive(selected_drawing_object);
|
GC.KeepAlive(selected_drawing_object);
|
||||||
selected_drawing_object.OnSelect(OnSelectDrawingObject);
|
selected_drawing_object.OnSelect(OnSelectDrawingObject);
|
||||||
selected_drawing_object.OnAttach(OnSelectDrawingObject);
|
selected_drawing_object.OnAttach(OnSelectDrawingObject);
|
||||||
selected_drawing_object.OnResize(OnSelectDrawingObject);
|
selected_drawing_object.OnResize(OnSelectDrawingObject);
|
||||||
selected_drawing_object.OnDrag(OnSelectDrawingObject);
|
selected_drawing_object.OnDrag(OnSelectDrawingObject);
|
||||||
myHwindow.DispHWindow.AttachDrawingObjectToWindow(selected_drawing_object);
|
myHwindow.DispHWindow.AttachDrawingObjectToWindow(selected_drawing_object);
|
||||||
|
isInit = false;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参数回调
|
/// 参数回调
|
||||||
@@ -122,7 +126,7 @@ namespace FindLineTool
|
|||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设定工具运行状态
|
/// 设定工具运行状态
|
||||||
/// </summary>
|
/// </summary>`
|
||||||
/// <param name="msg">运行中的信息</param>
|
/// <param name="msg">运行中的信息</param>
|
||||||
/// <param name="status">运行状态</param>
|
/// <param name="status">运行状态</param>
|
||||||
public void SetToolStatus(string msg, ToolRunStatu status)
|
public void SetToolStatus(string msg, ToolRunStatu status)
|
||||||
@@ -146,8 +150,11 @@ namespace FindLineTool
|
|||||||
|
|
||||||
private void DispSetCheck(object sender, EventArgs e)
|
private void DispSetCheck(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
myFindLine.dispRec = chBDispRec.Checked ? true : false;
|
if(!isInit)
|
||||||
myFindLine.dispCross = chBDispCross.Checked ? true : false;
|
{
|
||||||
|
myFindLine.dispRec = chBDispRec.Checked ? true : false;
|
||||||
|
myFindLine.dispCross = chBDispCross.Checked ? true : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormFindLine2_FormClosing(object sender, FormClosingEventArgs e)
|
private void FormFindLine2_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
@@ -157,5 +164,11 @@ namespace FindLineTool
|
|||||||
this.Dispose();
|
this.Dispose();
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnSetModelPose_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
myFindLine.UpdateModelLineLocation();
|
||||||
|
MessageBox.Show("模板线位置已更新");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
PMAlignTool/FormPMAlignTool.Designer.cs
generated
8
PMAlignTool/FormPMAlignTool.Designer.cs
generated
@@ -1030,6 +1030,7 @@ namespace PMAlignTool
|
|||||||
this.nud_angleRange.Size = new System.Drawing.Size(102, 28);
|
this.nud_angleRange.Size = new System.Drawing.Size(102, 28);
|
||||||
this.nud_angleRange.TabIndex = 182;
|
this.nud_angleRange.TabIndex = 182;
|
||||||
this.nud_angleRange.Value = 10D;
|
this.nud_angleRange.Value = 10D;
|
||||||
|
this.nud_angleRange.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// ckb_autoContrast
|
// ckb_autoContrast
|
||||||
//
|
//
|
||||||
@@ -1071,6 +1072,7 @@ namespace PMAlignTool
|
|||||||
this.nud_ScaleRange.Size = new System.Drawing.Size(104, 28);
|
this.nud_ScaleRange.Size = new System.Drawing.Size(104, 28);
|
||||||
this.nud_ScaleRange.TabIndex = 180;
|
this.nud_ScaleRange.TabIndex = 180;
|
||||||
this.nud_ScaleRange.Value = 1.1D;
|
this.nud_ScaleRange.Value = 1.1D;
|
||||||
|
this.nud_ScaleRange.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// nud_ScaleStart
|
// nud_ScaleStart
|
||||||
//
|
//
|
||||||
@@ -1100,6 +1102,7 @@ namespace PMAlignTool
|
|||||||
this.nud_ScaleStart.Size = new System.Drawing.Size(96, 28);
|
this.nud_ScaleStart.Size = new System.Drawing.Size(96, 28);
|
||||||
this.nud_ScaleStart.TabIndex = 179;
|
this.nud_ScaleStart.TabIndex = 179;
|
||||||
this.nud_ScaleStart.Value = 0.9D;
|
this.nud_ScaleStart.Value = 0.9D;
|
||||||
|
this.nud_ScaleStart.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// nud_angleStart
|
// nud_angleStart
|
||||||
//
|
//
|
||||||
@@ -1129,6 +1132,7 @@ namespace PMAlignTool
|
|||||||
this.nud_angleStart.Size = new System.Drawing.Size(96, 28);
|
this.nud_angleStart.Size = new System.Drawing.Size(96, 28);
|
||||||
this.nud_angleStart.TabIndex = 176;
|
this.nud_angleStart.TabIndex = 176;
|
||||||
this.nud_angleStart.Value = -10D;
|
this.nud_angleStart.Value = -10D;
|
||||||
|
this.nud_angleStart.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// cbx_polarity
|
// cbx_polarity
|
||||||
//
|
//
|
||||||
@@ -1176,6 +1180,7 @@ namespace PMAlignTool
|
|||||||
this.nud_minScore.Size = new System.Drawing.Size(227, 26);
|
this.nud_minScore.Size = new System.Drawing.Size(227, 26);
|
||||||
this.nud_minScore.TabIndex = 173;
|
this.nud_minScore.TabIndex = 173;
|
||||||
this.nud_minScore.Value = 0.8D;
|
this.nud_minScore.Value = 0.8D;
|
||||||
|
this.nud_minScore.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// nud_Timeout
|
// nud_Timeout
|
||||||
//
|
//
|
||||||
@@ -1205,6 +1210,7 @@ namespace PMAlignTool
|
|||||||
this.nud_Timeout.Size = new System.Drawing.Size(227, 28);
|
this.nud_Timeout.Size = new System.Drawing.Size(227, 28);
|
||||||
this.nud_Timeout.TabIndex = 177;
|
this.nud_Timeout.TabIndex = 177;
|
||||||
this.nud_Timeout.Value = 500D;
|
this.nud_Timeout.Value = 500D;
|
||||||
|
this.nud_Timeout.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// nud_angleStep
|
// nud_angleStep
|
||||||
//
|
//
|
||||||
@@ -1234,6 +1240,7 @@ namespace PMAlignTool
|
|||||||
this.nud_angleStep.Size = new System.Drawing.Size(227, 28);
|
this.nud_angleStep.Size = new System.Drawing.Size(227, 28);
|
||||||
this.nud_angleStep.TabIndex = 175;
|
this.nud_angleStep.TabIndex = 175;
|
||||||
this.nud_angleStep.Value = 1D;
|
this.nud_angleStep.Value = 1D;
|
||||||
|
this.nud_angleStep.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// nud_matchNum
|
// nud_matchNum
|
||||||
//
|
//
|
||||||
@@ -1263,6 +1270,7 @@ namespace PMAlignTool
|
|||||||
this.nud_matchNum.Size = new System.Drawing.Size(227, 28);
|
this.nud_matchNum.Size = new System.Drawing.Size(227, 28);
|
||||||
this.nud_matchNum.TabIndex = 174;
|
this.nud_matchNum.TabIndex = 174;
|
||||||
this.nud_matchNum.Value = 1D;
|
this.nud_matchNum.Value = 1D;
|
||||||
|
this.nud_matchNum.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||||
//
|
//
|
||||||
// tkb_contrast
|
// tkb_contrast
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ namespace PMAlignTool
|
|||||||
tkb_contrast.Value = myPMAlign.contrast;
|
tkb_contrast.Value = myPMAlign.contrast;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
isInitTool = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnAcqNewModelImage_Click(object sender, EventArgs e)
|
private void btnAcqNewModelImage_Click(object sender, EventArgs e)
|
||||||
@@ -305,5 +306,21 @@ namespace PMAlignTool
|
|||||||
{
|
{
|
||||||
lbl_contastValue.Text = tkb_contrast.Value.ToString();
|
lbl_contastValue.Text = tkb_contrast.Value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UIParams_ValueChanged(double value)
|
||||||
|
{
|
||||||
|
if (!isInitTool)
|
||||||
|
{
|
||||||
|
myPMAlign.minScore = nud_minScore.Value;
|
||||||
|
myPMAlign.startAngle = Convert.ToInt16(nud_angleStart.Value);
|
||||||
|
myPMAlign.angleRange = Convert.ToInt16(nud_angleRange.Value);
|
||||||
|
myPMAlign.angleStep = Convert.ToInt16(nud_angleStep.Value);
|
||||||
|
myPMAlign.polarity = cbx_polarity.TextStr;
|
||||||
|
myPMAlign.isAutoConstants = ckb_autoContrast.Checked;
|
||||||
|
myPMAlign.minScale = nud_ScaleStart.Value;
|
||||||
|
myPMAlign.maxScale = nud_ScaleRange.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,21 +211,6 @@
|
|||||||
<metadata name="Column12.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Column12.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Column12.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>71</value>
|
<value>71</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ namespace PMAlignTool
|
|||||||
public HObject oldTrainImage { get; set; }
|
public HObject oldTrainImage { get; set; }
|
||||||
public bool isCreateModel { get; set; }
|
public bool isCreateModel { get; set; }
|
||||||
internal string pmaModelName { get; set; } = Guid.NewGuid().ToString();
|
internal string pmaModelName { get; set; } = Guid.NewGuid().ToString();
|
||||||
|
/// <summary>
|
||||||
|
/// 模板位置和实际位置的姿态差异
|
||||||
|
/// </summary>
|
||||||
|
internal HTuple posHomMat2D = new HTuple();
|
||||||
|
|
||||||
public override void DispMainWindow(HWindow dispHWindow)
|
public override void DispMainWindow(HWindow dispHWindow)
|
||||||
{
|
{
|
||||||
@@ -185,7 +189,7 @@ namespace PMAlignTool
|
|||||||
//对预期线的找模板区域做放射变换
|
//对预期线的找模板区域做放射变换
|
||||||
|
|
||||||
}
|
}
|
||||||
UpdateParamsFromUI(); // 操作前先将UI中参数写入类
|
// UpdateParamsFromUI(); // 操作前先将UI中参数写入类
|
||||||
HObject findModelImg = ProcessImage(inputImage);
|
HObject findModelImg = ProcessImage(inputImage);
|
||||||
int ret = FindModelTemplate(findModelImg);
|
int ret = FindModelTemplate(findModelImg);
|
||||||
ToolRunStatu myState = ret == 0 ? ToolRunStatu.Succeed : ToolRunStatu.Model_UnFound;
|
ToolRunStatu myState = ret == 0 ? ToolRunStatu.Succeed : ToolRunStatu.Model_UnFound;
|
||||||
@@ -239,6 +243,18 @@ namespace PMAlignTool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetParamsFromUI()
|
||||||
|
{
|
||||||
|
minScore = FormPMAlignTool.Instance.nud_minScore.Value;
|
||||||
|
startAngle = Convert.ToInt16(FormPMAlignTool.Instance.nud_angleStart.Value);
|
||||||
|
angleRange = Convert.ToInt16(FormPMAlignTool.Instance.nud_angleRange.Value);
|
||||||
|
angleStep = Convert.ToInt16(FormPMAlignTool.Instance.nud_angleStep.Value);
|
||||||
|
polarity = FormPMAlignTool.Instance.cbx_polarity.TextStr;
|
||||||
|
isAutoConstants = FormPMAlignTool.Instance.ckb_autoContrast.Checked;
|
||||||
|
minScale = FormPMAlignTool.Instance.nud_ScaleStart.Value;
|
||||||
|
maxScale = FormPMAlignTool.Instance.nud_ScaleRange.Value;
|
||||||
|
}
|
||||||
|
|
||||||
public int CreateModelTemplate()
|
public int CreateModelTemplate()
|
||||||
{
|
{
|
||||||
HObject template;
|
HObject template;
|
||||||
@@ -254,14 +270,7 @@ namespace PMAlignTool
|
|||||||
HOperatorSet.GenEmptyObj(out createModelImg);
|
HOperatorSet.GenEmptyObj(out createModelImg);
|
||||||
createModelImg = ProcessImage(inputImage);
|
createModelImg = ProcessImage(inputImage);
|
||||||
HOperatorSet.ReduceDomain(createModelImg, templateRegion, out template);
|
HOperatorSet.ReduceDomain(createModelImg, templateRegion, out template);
|
||||||
minScore = FormPMAlignTool.Instance.nud_minScore.Value;
|
//SetParamsFromUI();
|
||||||
startAngle = Convert.ToInt16(FormPMAlignTool.Instance.nud_angleStart.Value);
|
|
||||||
angleRange = Convert.ToInt16(FormPMAlignTool.Instance.nud_angleRange.Value);
|
|
||||||
angleStep = Convert.ToInt16(FormPMAlignTool.Instance.nud_angleStep.Value);
|
|
||||||
polarity = FormPMAlignTool.Instance.cbx_polarity.TextStr;
|
|
||||||
isAutoConstants = FormPMAlignTool.Instance.ckb_autoContrast.Checked;
|
|
||||||
minScale = FormPMAlignTool.Instance.nud_ScaleStart.Value;
|
|
||||||
maxScale = FormPMAlignTool.Instance.nud_ScaleRange.Value;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HTuple rows, cols, angles, scores, scale;
|
HTuple rows, cols, angles, scores, scale;
|
||||||
@@ -291,38 +300,6 @@ namespace PMAlignTool
|
|||||||
out cols,
|
out cols,
|
||||||
out angles,
|
out angles,
|
||||||
out scores);
|
out scores);
|
||||||
/*
|
|
||||||
HOperatorSet.CreateScaledShapeModel(template,
|
|
||||||
"auto",
|
|
||||||
((HTuple)startAngle).TupleRad(),
|
|
||||||
((HTuple)angleRange).TupleRad(),
|
|
||||||
"auto",
|
|
||||||
minScale,
|
|
||||||
maxScale,
|
|
||||||
"auto",
|
|
||||||
"auto",
|
|
||||||
polarity,
|
|
||||||
isAutoConstants ? (HTuple)"auto" : (HTuple)contrast,
|
|
||||||
"auto",
|
|
||||||
out modelID);
|
|
||||||
HOperatorSet.FindScaledShapeModel(createModelImg,
|
|
||||||
(HTuple)modelID,
|
|
||||||
((HTuple)startAngle).TupleRad(),
|
|
||||||
((HTuple)angleRange - startAngle).TupleRad(),
|
|
||||||
minScale,
|
|
||||||
maxScale,
|
|
||||||
(HTuple)minScore,
|
|
||||||
(HTuple)matchNum,
|
|
||||||
(HTuple)0.5,
|
|
||||||
(HTuple)"least_squares",
|
|
||||||
(HTuple)0,
|
|
||||||
(HTuple)0.9,
|
|
||||||
out rows,
|
|
||||||
out cols,
|
|
||||||
out angles,
|
|
||||||
out scale,
|
|
||||||
out scores);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -354,6 +331,7 @@ namespace PMAlignTool
|
|||||||
{
|
{
|
||||||
templatePose = new PosXYU { X = rows[0].D, Y = cols[0].D , U = angles[0].D };
|
templatePose = new PosXYU { X = rows[0].D, Y = cols[0].D , U = angles[0].D };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -463,6 +441,7 @@ namespace PMAlignTool
|
|||||||
L_resultList.Add(matchResult);
|
L_resultList.Add(matchResult);
|
||||||
}
|
}
|
||||||
MatchResult temp;
|
MatchResult temp;
|
||||||
|
// 将匹配结果按分值由大到小排序
|
||||||
for (int i = 0; i < L_resultList.Count - 1; i++)
|
for (int i = 0; i < L_resultList.Count - 1; i++)
|
||||||
{
|
{
|
||||||
for (int j = i + 1; j < L_resultList.Count; j++)
|
for (int j = i + 1; j < L_resultList.Count; j++)
|
||||||
@@ -475,6 +454,7 @@ namespace PMAlignTool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HOperatorSet.VectorAngleToRigid(templatePose.X, templatePose.Y, templatePose.U, L_resultList[0].Row, L_resultList[0].Col, L_resultList[0].Angle, out posHomMat2D);
|
||||||
}
|
}
|
||||||
if (softwareRunState == SoftwareRunState.Debug)
|
if (softwareRunState == SoftwareRunState.Debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,9 +67,7 @@ namespace PMAlignTool
|
|||||||
// 将输出值赋值到界面输出中
|
// 将输出值赋值到界面输出中
|
||||||
if (myPMAlign.L_resultList.Count > 0)
|
if (myPMAlign.L_resultList.Count > 0)
|
||||||
{
|
{
|
||||||
L_toolList[toolIndex].toolOutput[0] = new ToolIO("GetPose",
|
L_toolList[toolIndex].toolOutput[0] = new ToolIO("GetPose", myPMAlign.posHomMat2D,DataType.Pose);
|
||||||
new PosXYU { X = myPMAlign.L_resultList[0].Row, Y = myPMAlign.L_resultList[0].Col, U = myPMAlign.L_resultList[0].Angle },
|
|
||||||
DataType.Pose);
|
|
||||||
L_toolList[toolIndex].toolOutput[1] = new ToolIO("GetPose.X", myPMAlign.L_resultList[0].Row, DataType.IntValue);
|
L_toolList[toolIndex].toolOutput[1] = new ToolIO("GetPose.X", myPMAlign.L_resultList[0].Row, DataType.IntValue);
|
||||||
L_toolList[toolIndex].toolOutput[2] = new ToolIO("GetPose.Y", myPMAlign.L_resultList[0].Col, DataType.IntValue);
|
L_toolList[toolIndex].toolOutput[2] = new ToolIO("GetPose.Y", myPMAlign.L_resultList[0].Col, DataType.IntValue);
|
||||||
L_toolList[toolIndex].toolOutput[3] = new ToolIO("GetPose.Z", myPMAlign.L_resultList[0].Angle, DataType.DoubleValue);
|
L_toolList[toolIndex].toolOutput[3] = new ToolIO("GetPose.Z", myPMAlign.L_resultList[0].Angle, DataType.DoubleValue);
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ namespace VisionEdit
|
|||||||
if (dr == DialogResult.Yes)
|
if (dr == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
VisionJobParams.pVisionProject.SaveObject();
|
VisionJobParams.pVisionProject.SaveObject();
|
||||||
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
else if (dr == DialogResult.Cancel)
|
else if (dr == DialogResult.Cancel)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user