diff --git a/.vs/VisionEdit/v14/.suo b/.vs/VisionEdit/v14/.suo
index 7a038c5..ff30275 100644
Binary files a/.vs/VisionEdit/v14/.suo and b/.vs/VisionEdit/v14/.suo differ
diff --git a/CommonMethods/Interface/IToolInfo.cs b/CommonMethods/Interface/IToolInfo.cs
index 177875b..88d8deb 100644
--- a/CommonMethods/Interface/IToolInfo.cs
+++ b/CommonMethods/Interface/IToolInfo.cs
@@ -29,7 +29,8 @@ namespace CommonMethods
///
/// 工具窗体,由于无法对Form进行序列化,所以作为静态变量
///
- public static Form FormTool { get; set; }
+ [NonSerialized]
+ public Form FormTool = new Form();
///
/// 工具窗体名
///
@@ -54,11 +55,16 @@ namespace CommonMethods
/// 工具运行结果
///
public ToolRunStatu toolRunStatu { get; set; }
+ ///
+ /// 绑定的JOB名称
+ ///
+ public string bingingJobName { get; set; }
public IToolInfo()
{
enable = true;
toolType = ToolType.None;
toolName = string.Empty;
+ bingingJobName = string.Empty;
tool = new object();
toolInput = new List();
toolOutput = new List();
diff --git a/DataStruct/ConfigData.cs b/DataStruct/ConfigData.cs
new file mode 100644
index 0000000..2763334
--- /dev/null
+++ b/DataStruct/ConfigData.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataStruct
+{
+ [Serializable]
+ public class ConfigData
+ {
+ public static string ConfigPath { get; set; } = @"D:\VisionSystem\";
+ }
+}
diff --git a/DataStruct/DataStruct.csproj b/DataStruct/DataStruct.csproj
index f959560..7624323 100644
--- a/DataStruct/DataStruct.csproj
+++ b/DataStruct/DataStruct.csproj
@@ -44,6 +44,7 @@
+
diff --git a/FindLine/FormFindLine.cs b/FindLine/FormFindLine.cs
index 6f01142..1d0b1be 100644
--- a/FindLine/FormFindLine.cs
+++ b/FindLine/FormFindLine.cs
@@ -87,8 +87,14 @@ namespace FindLineTool
chBDispRec.Checked = myFindLine.dispRec;
chBDispCross.Checked = myFindLine.dispCross;
//// 将要编辑的线显示
- selected_drawing_object = myFindLine.inputPoseHomMat2D.Length != 0? 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 });
+ if(myFindLine.inputPoseHomMat2D.Type != HTupleType.EMPTY)
+ {
+ selected_drawing_object = HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.LINE, new HTuple[] { myFindLine.newExpectLineStartRow, myFindLine.newExpectLineStartCol, myFindLine.newExpectLineEndRow, myFindLine.newExpectLineEndCol });
+ }
+ else
+ {
+ selected_drawing_object = 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);
diff --git a/HalconTool/HalconTool.cs b/HalconTool/HalconTool.cs
index 8dbc7e1..56db98b 100644
--- a/HalconTool/HalconTool.cs
+++ b/HalconTool/HalconTool.cs
@@ -76,7 +76,8 @@ namespace HalconTool
///
/// 输出图像
///
- public HObject outputImage = null;
+ [NonSerialized]
+ public HObject outputImage = new HObject();
///
/// 输出图像的路径
///
@@ -98,7 +99,7 @@ namespace HalconTool
}
else
{
- if (currentImageIndex <= L_imageFile.Count)
+ if (currentImageIndex <= L_imageFile.Count && L_imageFile.Count != 0)
{
currentImageIndex = currentImageIndex == L_imageFile.Count ? 0 : currentImageIndex;
outputImageFilePath = L_imageFile[currentImageIndex];
diff --git a/PMAlignTool/FormPMAlignTool.Designer.cs b/PMAlignTool/FormPMAlignTool.Designer.cs
index 87ecad1..5c6536d 100644
--- a/PMAlignTool/FormPMAlignTool.Designer.cs
+++ b/PMAlignTool/FormPMAlignTool.Designer.cs
@@ -29,10 +29,6 @@ namespace PMAlignTool
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormPMAlignTool));
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.lb_RunStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
@@ -123,7 +119,7 @@ namespace PMAlignTool
this.ckb_showFeature = new System.Windows.Forms.CheckBox();
this.ckb_showCross = new System.Windows.Forms.CheckBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
- this.dgv_matchResult = new Sunny.UI.UIDataGridView();
+ this.dgv_matchResult = new System.Windows.Forms.DataGridView();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -1550,21 +1546,7 @@ namespace PMAlignTool
//
// dgv_matchResult
//
- dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
- this.dgv_matchResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
- this.dgv_matchResult.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
- this.dgv_matchResult.BackgroundColor = System.Drawing.Color.White;
- this.dgv_matchResult.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
- dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
- dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
- dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dgv_matchResult.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
- this.dgv_matchResult.ColumnHeadersHeight = 32;
- this.dgv_matchResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+ this.dgv_matchResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgv_matchResult.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2,
@@ -1572,62 +1554,36 @@ namespace PMAlignTool
this.Column4,
this.Column5});
this.dgv_matchResult.Dock = System.Windows.Forms.DockStyle.Fill;
- this.dgv_matchResult.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
- this.dgv_matchResult.EnableHeadersVisualStyles = false;
- this.dgv_matchResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.dgv_matchResult.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.dgv_matchResult.Location = new System.Drawing.Point(0, 0);
this.dgv_matchResult.Name = "dgv_matchResult";
- dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
- dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
- dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
- dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White;
- dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dgv_matchResult.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
- this.dgv_matchResult.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToFirstHeader;
- dataGridViewCellStyle4.BackColor = System.Drawing.Color.White;
- this.dgv_matchResult.RowsDefaultCellStyle = dataGridViewCellStyle4;
this.dgv_matchResult.RowTemplate.Height = 23;
- this.dgv_matchResult.SelectedIndex = -1;
- this.dgv_matchResult.ShowGridLine = true;
this.dgv_matchResult.Size = new System.Drawing.Size(392, 568);
this.dgv_matchResult.TabIndex = 0;
//
// Column1
//
- this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
- this.Column1.HeaderText = "编号";
+ this.Column1.HeaderText = "序号";
this.Column1.Name = "Column1";
- this.Column1.Width = 66;
//
// Column2
//
- this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column2.HeaderText = "分值";
this.Column2.Name = "Column2";
//
// Column3
//
- this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.Column3.HeaderText = "行";
this.Column3.Name = "Column3";
- this.Column3.Width = 50;
//
// Column4
//
- this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.Column4.HeaderText = "列";
this.Column4.Name = "Column4";
- this.Column4.Width = 50;
//
// Column5
//
- this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.Column5.HeaderText = "角度";
this.Column5.Name = "Column5";
- this.Column5.Width = 66;
//
// FormPMAlignTool
//
@@ -1788,6 +1744,6 @@ namespace PMAlignTool
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
- public Sunny.UI.UIDataGridView dgv_matchResult;
+ public System.Windows.Forms.DataGridView dgv_matchResult;
}
}
\ No newline at end of file
diff --git a/PMAlignTool/FormPMAlignTool.cs b/PMAlignTool/FormPMAlignTool.cs
index 198c79d..d72cc2d 100644
--- a/PMAlignTool/FormPMAlignTool.cs
+++ b/PMAlignTool/FormPMAlignTool.cs
@@ -33,7 +33,8 @@ namespace PMAlignTool
{
myToolInfo = (IToolInfo)pmalign;
myPMAlign = (PMAlign)myToolInfo.tool;
- myPMAlign.toolName = myToolInfo.FormToolName;
+ myPMAlign.toolName = myToolInfo.toolName;
+ myPMAlign.bingdingJobName = myToolInfo.bingingJobName;
myPMAlign.DispImage();
}
}
diff --git a/PMAlignTool/PMAlign.cs b/PMAlignTool/PMAlign.cs
index e8c81d2..bdb065a 100644
--- a/PMAlignTool/PMAlign.cs
+++ b/PMAlignTool/PMAlign.cs
@@ -25,12 +25,20 @@ using Logger;
using System.Diagnostics;
using System.IO;
using ViewROI;
+using DataStruct;
namespace PMAlignTool
{
[Serializable]
public class PMAlign : IToolBase
{
+ ///
+ /// 绑定job名称
+ ///
+ public string bingdingJobName { get; set; }
+ ///
+ /// 工具名称
+ ///
public string toolName { get; set; } = string.Empty;
///
/// 输入姿态
@@ -115,12 +123,14 @@ namespace PMAlignTool
///
/// 训练时所使用的模板图像,不点击获取图像时,不进行更新
///
- public HObject oldTrainImage { get; set; }
+ [NonSerialized]
+ public HObject oldTrainImage;
public bool isCreateModel { get; set; }
internal string pmaModelName { get; set; } = Guid.NewGuid().ToString();
///
/// 剪出的模板图像
///
+ [NonSerialized]
public HObject modelPartImage = new HObject();
///
/// 模板位置和实际位置的姿态差异
@@ -163,7 +173,8 @@ namespace PMAlignTool
public bool isAutoConstants { get; set; }
public string modelFilePath { get; set; }
public RegionType searchRegionType { get; set; }
- public HObject SearchRegion { get; set; }
+ [NonSerialized]
+ public HObject SearchRegion;
public override void Run(SoftwareRunState softwareState)
{
Stopwatch sw = new Stopwatch();
@@ -195,7 +206,6 @@ namespace PMAlignTool
//对预期线的找模板区域做放射变换
}
- // UpdateParamsFromUI(); // 操作前先将UI中参数写入类
HObject findModelImg = ProcessImage(inputImage);
int ret = FindModelTemplate(findModelImg);
UpdateResultDataGridview();
@@ -220,10 +230,16 @@ namespace PMAlignTool
public void UpdateResultDataGridview()
{
FormPMAlignTool.Instance.dgv_matchResult.Rows.Clear();
+ //FormPMAlignTool.Instance.dgv_matchResult.Columns.Clear();
+ //FormPMAlignTool.Instance.dgv_matchResult.Columns.Add("num", "序号");
+ //FormPMAlignTool.Instance.dgv_matchResult.Columns.Add("Socre", "分值");
+ //FormPMAlignTool.Instance.dgv_matchResult.Columns.Add("Row", "行");
+ //FormPMAlignTool.Instance.dgv_matchResult.Columns.Add("Col", "列");
+ //FormPMAlignTool.Instance.dgv_matchResult.Columns.Add("Angle", "角度");
int count = 0;
foreach (var item in L_resultList)
{
- FormPMAlignTool.Instance.dgv_matchResult.AddRow(++count, item.Socre, item.Row, item.Col, item.Angle);
+ FormPMAlignTool.Instance.dgv_matchResult.Rows.Add(++count, item.Socre, item.Row, item.Col, item.Angle);
}
}
@@ -355,8 +371,9 @@ namespace PMAlignTool
out scores);
}
isCreateModel = true;
- HOperatorSet.WriteRegion(templateRegion, FormPMAlignTool.Instance.myToolInfo.FormToolName + ".hobj");
- HOperatorSet.WriteShapeModel(modelID, pmaModelName + ".ShapeModel");
+ // 模板句柄信息
+ Directory.CreateDirectory(ConfigData.ConfigPath + $"\\{bingdingJobName}\\");
+ HOperatorSet.WriteShapeModel(modelID, ConfigData.ConfigPath + $"\\{bingdingJobName}\\{toolName}_{pmaModelName}.Shm");
if (scores != null && scores.Type != HTupleType.EMPTY)
{
@@ -380,12 +397,12 @@ namespace PMAlignTool
public int FindModelTemplate(HObject findModelImage)
{
- if (!File.Exists(pmaModelName + ".ShapeModel"))
+ if (!File.Exists(ConfigData.ConfigPath + $"\\{bingdingJobName}\\{toolName}_{pmaModelName}.Shm"))
{
LoggerClass.WriteLog($"{toolName}未创建或加载模板", MsgLevel.Exception);
return -1;
}
- HOperatorSet.ReadShapeModel(pmaModelName + ".ShapeModel", out modelID);
+ HOperatorSet.ReadShapeModel(ConfigData.ConfigPath + $"\\{bingdingJobName}\\{toolName}_{pmaModelName}.Shm", out modelID);
HObject image;
if (searchRegionType == RegionType.AllImage)
{
diff --git a/ToolLib.VisionJob/OperateProject.cs b/ToolLib.VisionJob/OperateProject.cs
index 5767d5d..bc197ee 100644
--- a/ToolLib.VisionJob/OperateProject.cs
+++ b/ToolLib.VisionJob/OperateProject.cs
@@ -64,7 +64,6 @@ namespace ToolLib.VisionJob
{
VisionJobParams.pVisionProject.Project.Add(jobName, new VisionJob(jobName));
FormJobManage.Instance.tabJobUnion.SelectedTab = newTab;
- // newTab.Select();
}
InitJob(VisionJobParams.pVisionProject.Project[jobName]);
}
@@ -219,12 +218,12 @@ namespace ToolLib.VisionJob
string AssemblyName = VisionJobParams.pVisionProject.Project[jobName].L_toolList[i].FormToolName.Split('.')[0];
string className = VisionJobParams.pVisionProject.Project[jobName].L_toolList[i].FormToolName;
toolClass = VisionJobParams.pVisionProject.Project[jobName].L_toolList[i];
- IToolInfo.FormTool = (Form)Assembly.Load(AssemblyName).CreateInstance(className, false, BindingFlags.Default, null, new object[] { toolClass }, null, null);
- IToolInfo.FormTool.ShowDialog();
- //VisionJobParams.myProject[jobName].L_toolList[i].SetFormTool(IToolInfo.FormTool);
- //VisionJobParams.myProject[jobName].L_toolList[i].GetFormTool().ShowDialog();
- //VisionJobParams.myProject[jobName].L_toolList[i].FormTool = (Form)Assembly.Load(AssemblyName).CreateInstance(className, false, BindingFlags.Default, null, new object[] { toolClass }, null, null);
- //VisionJobParams.myProject[jobName].L_toolList[i].FormTool.ShowDialog();
+ VisionJobParams.pVisionProject.Project[jobName].L_toolList[i].bingingJobName = jobName;
+ //IToolInfo.FormTool = (Form)Assembly.Load(AssemblyName).CreateInstance(className, false, BindingFlags.Default, null, new object[] { toolClass }, null, null);
+ //IToolInfo.FormTool.ShowDialog();
+ VisionJobParams.pVisionProject.Project[jobName].L_toolList[i].FormTool = (Form)Assembly.Load(AssemblyName).CreateInstance(className, false, BindingFlags.Default, null, new object[] { toolClass }, null, null);
+ VisionJobParams.pVisionProject.Project[jobName].L_toolList[i].FormTool.Show();
+
}
}
}
diff --git a/ToolLib.VisionJob/VisionJob.cs b/ToolLib.VisionJob/VisionJob.cs
index 92d8467..b304da0 100644
--- a/ToolLib.VisionJob/VisionJob.cs
+++ b/ToolLib.VisionJob/VisionJob.cs
@@ -904,6 +904,7 @@ namespace ToolLib.VisionJob
}
[NonSerialized]
public FormImageWindow myHalconWindow = new FormImageWindow();
+ public string JobDirectoryPath { get; set; } = @"D:\VisionSystem\";
}
}
diff --git a/VisionEdit/AppConfig.cs b/VisionEdit/AppConfig.cs
deleted file mode 100644
index 907305c..0000000
--- a/VisionEdit/AppConfig.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using WeifenLuo.WinFormsUI.Docking;
-
-namespace VisionEdit
-{
- public class AppConfig
- {
- public static DockState leftForm = DockState.DockLeft; // 功能窗体,左端停靠
- public static DockState rightForm = DockState.DockRight; // 功能窗体,右端停靠
- public static DockState docForm = DockState.Document; // 功能窗体,中间停靠
- }
-}
diff --git a/VisionEdit/VisionEdit.csproj b/VisionEdit/VisionEdit.csproj
index 5b6b33e..3c660c2 100644
--- a/VisionEdit/VisionEdit.csproj
+++ b/VisionEdit/VisionEdit.csproj
@@ -59,7 +59,6 @@
-
Form
diff --git a/VisionEdit/bin/Debug/DockPanel.config b/VisionEdit/bin/Debug/DockPanel.config
index 7de7575..0ab0045 100644
Binary files a/VisionEdit/bin/Debug/DockPanel.config and b/VisionEdit/bin/Debug/DockPanel.config differ
diff --git a/VisionEdit/bin/Debug/VisionEdit.vshost.exe.manifest b/VisionEdit/bin/Debug/VisionEdit.vshost.exe.manifest
deleted file mode 100644
index 061c9ca..0000000
--- a/VisionEdit/bin/Debug/VisionEdit.vshost.exe.manifest
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-