mirror of
https://github.com/eggplantlwj/VisionEdit.git
synced 2026-03-28 19:26:35 +08:00
1、修复找线工具的selectObject无法实时跟随的问题
2、可以重定义找线工具的初始位置 3、在工具初始化时加入防止其他事件更改UI参数的逻辑,以解决工具参数无法保存的bug
This commit is contained in:
Binary file not shown.
@@ -16,10 +16,53 @@ namespace FindLineTool
|
||||
/// </summary>
|
||||
public PosXYU inputPose = new PosXYU();
|
||||
/// <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>
|
||||
public PosXYU templatePose = new PosXYU();
|
||||
/// <summary>
|
||||
/// 修改的位姿
|
||||
/// </summary>
|
||||
public HTuple changedPose = new HTuple();
|
||||
/// <summary>
|
||||
/// 卡尺
|
||||
/// </summary>
|
||||
public HObject contoursDisp = null;
|
||||
@@ -50,7 +93,11 @@ namespace FindLineTool
|
||||
/// <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>
|
||||
@@ -214,7 +261,16 @@ namespace FindLineTool
|
||||
FormFindLine.Instance.myHwindow.DispHWindow.ClearWindow();
|
||||
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)
|
||||
{
|
||||
@@ -235,20 +291,62 @@ namespace FindLineTool
|
||||
{
|
||||
UpdateImage();
|
||||
}
|
||||
if (inputPose != null)
|
||||
if (inputPoseHomMat2D != null)
|
||||
{
|
||||
HTuple Row = inputPose.X - templatePose.X;
|
||||
HTuple Col = inputPose.Y - templatePose.Y;
|
||||
HTuple angle = inputPose.U - templatePose.U;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< 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;
|
||||
HOperatorSet.HomMat2dIdentity(out _homMat2D);
|
||||
HOperatorSet.HomMat2dRotate(_homMat2D, (HTuple)(angle), (HTuple)templatePose.X, (HTuple)templatePose.Y, out _homMat2D);
|
||||
HOperatorSet.HomMat2dTranslate(_homMat2D, (HTuple)(Row), (HTuple)(Col), out _homMat2D);
|
||||
//HTuple _homMat2D;
|
||||
//HOperatorSet.HomMat2dIdentity(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.AffineTransPixel(_homMat2D, (HTuple)expectLineStartRow, (HTuple)expectLineStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||
HOperatorSet.AffineTransPixel(_homMat2D, (HTuple)expectLineEndRow, (HTuple)expectLineEndCol, out newExpectLineEndRow, out newExpectLineEndCol);
|
||||
HOperatorSet.AffineTransPixel(inputPoseHomMat2D, (HTuple)expectLineStartRow, (HTuple)expectLineStartCol, out newExpectLineStartRow, out newExpectLineStartCol);
|
||||
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
|
||||
{
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<Reference Include="halcondotnet">
|
||||
<HintPath>C:\Program Files\MVTec\HALCON-19.05-Progress\bin\dotnet20\halcondotnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SunnyUI">
|
||||
<HintPath>..\VisionEdit\bin\Debug\ThirdLib\SunnyUI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace FindLineTool
|
||||
myFindLine.inputImage = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HObject;
|
||||
break;
|
||||
case "InputPos":
|
||||
myFindLine.inputPose = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as PosXYU;
|
||||
myFindLine.inputPoseHomMat2D = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HTuple;
|
||||
break;
|
||||
default:
|
||||
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.label10 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.btnSetModelPose = new Sunny.UI.UISymbolButton();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.statusStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
@@ -189,6 +190,7 @@ namespace FindLineTool
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.btnSetModelPose);
|
||||
this.groupBox1.Controls.Add(this.label6);
|
||||
this.groupBox1.Controls.Add(this.tbx_minScore);
|
||||
this.groupBox1.Controls.Add(this.label5);
|
||||
@@ -544,6 +546,20 @@ namespace FindLineTool
|
||||
this.label9.TabIndex = 105;
|
||||
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
|
||||
//
|
||||
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 toolStripStatusLabel1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lb_RunTime;
|
||||
private Sunny.UI.UISymbolButton btnSetModelPose;
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,10 @@ namespace FindLineTool
|
||||
myHwindow.Dock = DockStyle.Fill;
|
||||
InitTool();
|
||||
}
|
||||
bool isInit = false;
|
||||
private void InitTool()
|
||||
{
|
||||
isInit = true;
|
||||
this.Text = myToolInfo.toolName;
|
||||
Application.DoEvents();
|
||||
|
||||
@@ -84,14 +86,16 @@ namespace FindLineTool
|
||||
tbx_caliperLength2.Text = myFindLine.weidth.ToString();
|
||||
chBDispRec.Checked = myFindLine.dispRec;
|
||||
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);
|
||||
selected_drawing_object.OnSelect(OnSelectDrawingObject);
|
||||
selected_drawing_object.OnAttach(OnSelectDrawingObject);
|
||||
selected_drawing_object.OnResize(OnSelectDrawingObject);
|
||||
selected_drawing_object.OnDrag(OnSelectDrawingObject);
|
||||
myHwindow.DispHWindow.AttachDrawingObjectToWindow(selected_drawing_object);
|
||||
isInit = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 参数回调
|
||||
@@ -122,7 +126,7 @@ namespace FindLineTool
|
||||
}
|
||||
/// <summary>
|
||||
/// 设定工具运行状态
|
||||
/// </summary>
|
||||
/// </summary>`
|
||||
/// <param name="msg">运行中的信息</param>
|
||||
/// <param name="status">运行状态</param>
|
||||
public void SetToolStatus(string msg, ToolRunStatu status)
|
||||
@@ -146,8 +150,11 @@ namespace FindLineTool
|
||||
|
||||
private void DispSetCheck(object sender, EventArgs e)
|
||||
{
|
||||
myFindLine.dispRec = chBDispRec.Checked ? true : false;
|
||||
myFindLine.dispCross = chBDispCross.Checked ? true : false;
|
||||
if(!isInit)
|
||||
{
|
||||
myFindLine.dispRec = chBDispRec.Checked ? true : false;
|
||||
myFindLine.dispCross = chBDispCross.Checked ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
private void FormFindLine2_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -157,5 +164,11 @@ namespace FindLineTool
|
||||
this.Dispose();
|
||||
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.TabIndex = 182;
|
||||
this.nud_angleRange.Value = 10D;
|
||||
this.nud_angleRange.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// ckb_autoContrast
|
||||
//
|
||||
@@ -1071,6 +1072,7 @@ namespace PMAlignTool
|
||||
this.nud_ScaleRange.Size = new System.Drawing.Size(104, 28);
|
||||
this.nud_ScaleRange.TabIndex = 180;
|
||||
this.nud_ScaleRange.Value = 1.1D;
|
||||
this.nud_ScaleRange.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// nud_ScaleStart
|
||||
//
|
||||
@@ -1100,6 +1102,7 @@ namespace PMAlignTool
|
||||
this.nud_ScaleStart.Size = new System.Drawing.Size(96, 28);
|
||||
this.nud_ScaleStart.TabIndex = 179;
|
||||
this.nud_ScaleStart.Value = 0.9D;
|
||||
this.nud_ScaleStart.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// nud_angleStart
|
||||
//
|
||||
@@ -1129,6 +1132,7 @@ namespace PMAlignTool
|
||||
this.nud_angleStart.Size = new System.Drawing.Size(96, 28);
|
||||
this.nud_angleStart.TabIndex = 176;
|
||||
this.nud_angleStart.Value = -10D;
|
||||
this.nud_angleStart.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// cbx_polarity
|
||||
//
|
||||
@@ -1176,6 +1180,7 @@ namespace PMAlignTool
|
||||
this.nud_minScore.Size = new System.Drawing.Size(227, 26);
|
||||
this.nud_minScore.TabIndex = 173;
|
||||
this.nud_minScore.Value = 0.8D;
|
||||
this.nud_minScore.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// nud_Timeout
|
||||
//
|
||||
@@ -1205,6 +1210,7 @@ namespace PMAlignTool
|
||||
this.nud_Timeout.Size = new System.Drawing.Size(227, 28);
|
||||
this.nud_Timeout.TabIndex = 177;
|
||||
this.nud_Timeout.Value = 500D;
|
||||
this.nud_Timeout.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// nud_angleStep
|
||||
//
|
||||
@@ -1234,6 +1240,7 @@ namespace PMAlignTool
|
||||
this.nud_angleStep.Size = new System.Drawing.Size(227, 28);
|
||||
this.nud_angleStep.TabIndex = 175;
|
||||
this.nud_angleStep.Value = 1D;
|
||||
this.nud_angleStep.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// nud_matchNum
|
||||
//
|
||||
@@ -1263,6 +1270,7 @@ namespace PMAlignTool
|
||||
this.nud_matchNum.Size = new System.Drawing.Size(227, 28);
|
||||
this.nud_matchNum.TabIndex = 174;
|
||||
this.nud_matchNum.Value = 1D;
|
||||
this.nud_matchNum.ValueChanged += new Controls.DValueChanged(this.UIParams_ValueChanged);
|
||||
//
|
||||
// tkb_contrast
|
||||
//
|
||||
|
||||
@@ -102,6 +102,7 @@ namespace PMAlignTool
|
||||
tkb_contrast.Value = myPMAlign.contrast;
|
||||
|
||||
#endregion
|
||||
isInitTool = false;
|
||||
}
|
||||
|
||||
private void btnAcqNewModelImage_Click(object sender, EventArgs e)
|
||||
@@ -305,5 +306,21 @@ namespace PMAlignTool
|
||||
{
|
||||
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">
|
||||
<value>True</value>
|
||||
</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">
|
||||
<value>71</value>
|
||||
</metadata>
|
||||
|
||||
@@ -117,6 +117,10 @@ namespace PMAlignTool
|
||||
public HObject oldTrainImage { get; set; }
|
||||
public bool isCreateModel { get; set; }
|
||||
internal string pmaModelName { get; set; } = Guid.NewGuid().ToString();
|
||||
/// <summary>
|
||||
/// 模板位置和实际位置的姿态差异
|
||||
/// </summary>
|
||||
internal HTuple posHomMat2D = new HTuple();
|
||||
|
||||
public override void DispMainWindow(HWindow dispHWindow)
|
||||
{
|
||||
@@ -185,7 +189,7 @@ namespace PMAlignTool
|
||||
//对预期线的找模板区域做放射变换
|
||||
|
||||
}
|
||||
UpdateParamsFromUI(); // 操作前先将UI中参数写入类
|
||||
// UpdateParamsFromUI(); // 操作前先将UI中参数写入类
|
||||
HObject findModelImg = ProcessImage(inputImage);
|
||||
int ret = FindModelTemplate(findModelImg);
|
||||
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()
|
||||
{
|
||||
HObject template;
|
||||
@@ -254,14 +270,7 @@ namespace PMAlignTool
|
||||
HOperatorSet.GenEmptyObj(out createModelImg);
|
||||
createModelImg = ProcessImage(inputImage);
|
||||
HOperatorSet.ReduceDomain(createModelImg, templateRegion, out template);
|
||||
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;
|
||||
//SetParamsFromUI();
|
||||
try
|
||||
{
|
||||
HTuple rows, cols, angles, scores, scale;
|
||||
@@ -291,38 +300,6 @@ namespace PMAlignTool
|
||||
out cols,
|
||||
out angles,
|
||||
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
|
||||
{
|
||||
@@ -354,6 +331,7 @@ namespace PMAlignTool
|
||||
{
|
||||
templatePose = new PosXYU { X = rows[0].D, Y = cols[0].D , U = angles[0].D };
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -463,6 +441,7 @@ namespace PMAlignTool
|
||||
L_resultList.Add(matchResult);
|
||||
}
|
||||
MatchResult temp;
|
||||
// 将匹配结果按分值由大到小排序
|
||||
for (int i = 0; i < L_resultList.Count - 1; i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -67,9 +67,7 @@ namespace PMAlignTool
|
||||
// 将输出值赋值到界面输出中
|
||||
if (myPMAlign.L_resultList.Count > 0)
|
||||
{
|
||||
L_toolList[toolIndex].toolOutput[0] = new ToolIO("GetPose",
|
||||
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[0] = new ToolIO("GetPose", myPMAlign.posHomMat2D,DataType.Pose);
|
||||
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[3] = new ToolIO("GetPose.Z", myPMAlign.L_resultList[0].Angle, DataType.DoubleValue);
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace VisionEdit
|
||||
if (dr == DialogResult.Yes)
|
||||
{
|
||||
VisionJobParams.pVisionProject.SaveObject();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else if (dr == DialogResult.Cancel)
|
||||
{
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user