diff --git a/Hawkeye.VisionBuilder.Workflow/Operations/AI/YoloDetectionOperation.cs b/Hawkeye.VisionBuilder.Workflow/Operations/AI/YoloDetectionOperation.cs index b6ca8a9..ebac6e6 100644 --- a/Hawkeye.VisionBuilder.Workflow/Operations/AI/YoloDetectionOperation.cs +++ b/Hawkeye.VisionBuilder.Workflow/Operations/AI/YoloDetectionOperation.cs @@ -147,6 +147,7 @@ public class YoloDetectionOperation:BaseOperation { base.Save(dict); dict[nameof(ModelFilePath)] = ModelFilePath.Path; + dict[nameof(IgnoreType)] = IgnoreType; } public override void Load(Dictionary dict) @@ -154,5 +155,8 @@ public class YoloDetectionOperation:BaseOperation base.Load(dict); if (dict.ContainsKey(nameof(ModelFilePath))) ModelFilePath.Path = dict[nameof(ModelFilePath)].ToString(); + + if (dict.ContainsKey(nameof(IgnoreType))) + IgnoreType = Convert.ToInt32(dict[nameof(IgnoreType)]); } } \ No newline at end of file diff --git a/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.Designer.cs b/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.Designer.cs index 7dfba81..5af973e 100644 --- a/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.Designer.cs +++ b/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.Designer.cs @@ -20,77 +20,115 @@ namespace Hawkeye.VisionBuilder.Features.ImageStatistics private void InitializeComponent() { - this.treeView = new System.Windows.Forms.TreeView(); - this.btnReset = new System.Windows.Forms.Button(); - this.btnClose = new System.Windows.Forms.Button(); - this.btnBackward = new System.Windows.Forms.Button(); - this.btnForward = new System.Windows.Forms.Button(); - this.SuspendLayout(); + components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageStatisticsDialog)); + treeView = new TreeView(); + btnReset = new Button(); + btnClose = new Button(); + btnBackward = new Button(); + btnForward = new Button(); + cbExpectedMode = new CheckBox(); + toolTip1 = new ToolTip(components); + SuspendLayout(); // // treeView // - this.treeView.Location = new System.Drawing.Point(12, 12); - this.treeView.Name = "treeView"; - this.treeView.Size = new System.Drawing.Size(360, 300); - this.treeView.TabIndex = 0; - this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_NodeMouseClick); + treeView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + treeView.Location = new Point(10, 9); + treeView.Margin = new Padding(3, 2, 3, 2); + treeView.Name = "treeView"; + treeView.Size = new Size(316, 395); + treeView.TabIndex = 0; + treeView.NodeMouseClick += treeView_NodeMouseClick; // // btnReset // - this.btnReset.Location = new System.Drawing.Point(12, 320); - this.btnReset.Name = "btnReset"; - this.btnReset.Size = new System.Drawing.Size(75, 30); - this.btnReset.TabIndex = 1; - this.btnReset.Text = "Reset"; - this.btnReset.UseVisualStyleBackColor = true; - this.btnReset.Click += new System.EventHandler(this.btnReset_Click); + btnReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + btnReset.Location = new Point(10, 409); + btnReset.Margin = new Padding(3, 2, 3, 2); + btnReset.Name = "btnReset"; + btnReset.Size = new Size(66, 22); + btnReset.TabIndex = 1; + btnReset.Text = "Reset"; + btnReset.UseVisualStyleBackColor = true; + btnReset.Click += btnReset_Click; // // btnClose // - this.btnClose.Location = new System.Drawing.Point(297, 320); - this.btnClose.Name = "btnClose"; - this.btnClose.Size = new System.Drawing.Size(75, 30); - this.btnClose.TabIndex = 2; - this.btnClose.Text = "Close"; - this.btnClose.UseVisualStyleBackColor = true; - this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + btnClose.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + btnClose.Location = new Point(260, 409); + btnClose.Margin = new Padding(3, 2, 3, 2); + btnClose.Name = "btnClose"; + btnClose.Size = new Size(66, 22); + btnClose.TabIndex = 2; + btnClose.Text = "Close"; + btnClose.UseVisualStyleBackColor = true; + btnClose.Click += btnClose_Click; // // btnBackward // - this.btnBackward.Location = new System.Drawing.Point(100, 320); - this.btnBackward.Name = "btnBackward"; - this.btnBackward.Size = new System.Drawing.Size(75, 30); - this.btnBackward.TabIndex = 3; - this.btnBackward.Text = "<"; - this.btnBackward.UseVisualStyleBackColor = true; - this.btnBackward.Click += new System.EventHandler(this.btnBackward_Click); + btnBackward.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + btnBackward.Location = new Point(88, 409); + btnBackward.Margin = new Padding(3, 2, 3, 2); + btnBackward.Name = "btnBackward"; + btnBackward.Size = new Size(66, 22); + btnBackward.TabIndex = 3; + btnBackward.Text = "<"; + btnBackward.UseVisualStyleBackColor = true; + btnBackward.Click += btnBackward_Click; // // btnForward // - this.btnForward.Location = new System.Drawing.Point(190, 320); - this.btnForward.Name = "btnForward"; - this.btnForward.Size = new System.Drawing.Size(75, 30); - this.btnForward.TabIndex = 4; - this.btnForward.Text = ">"; - this.btnForward.UseVisualStyleBackColor = true; - this.btnForward.Click += new System.EventHandler(this.btnForward_Click); + btnForward.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + btnForward.Location = new Point(166, 409); + btnForward.Margin = new Padding(3, 2, 3, 2); + btnForward.Name = "btnForward"; + btnForward.Size = new Size(66, 22); + btnForward.TabIndex = 4; + btnForward.Text = ">"; + btnForward.UseVisualStyleBackColor = true; + btnForward.Click += btnForward_Click; + // + // cbExpectedMode + // + cbExpectedMode.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + cbExpectedMode.AutoSize = true; + cbExpectedMode.Location = new Point(8, 441); + cbExpectedMode.Name = "cbExpectedMode"; + cbExpectedMode.Size = new Size(108, 19); + cbExpectedMode.TabIndex = 5; + cbExpectedMode.Text = "Expected mode"; + toolTip1.SetToolTip(cbExpectedMode, resources.GetString("cbExpectedMode.ToolTip")); + cbExpectedMode.UseVisualStyleBackColor = true; + // + // toolTip1 + // + toolTip1.AutoPopDelay = 100500; + toolTip1.InitialDelay = 550; + toolTip1.IsBalloon = true; + toolTip1.ReshowDelay = 110; // // ImageStatisticsDialog // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(384, 361); - this.Controls.Add(this.btnForward); - this.Controls.Add(this.btnBackward); - this.Controls.Add(this.btnClose); - this.Controls.Add(this.btnReset); - this.Controls.Add(this.treeView); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ImageStatisticsDialog"; - this.Text = "Image Statistics"; - this.ResumeLayout(false); + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(336, 476); + Controls.Add(cbExpectedMode); + Controls.Add(btnForward); + Controls.Add(btnBackward); + Controls.Add(btnClose); + Controls.Add(btnReset); + Controls.Add(treeView); + FormBorderStyle = FormBorderStyle.FixedDialog; + Margin = new Padding(3, 2, 3, 2); + MaximizeBox = false; + MinimizeBox = false; + Name = "ImageStatisticsDialog"; + Text = "Image Statistics"; + ResumeLayout(false); + PerformLayout(); } + public CheckBox cbExpectedMode; + private ToolTip toolTip1; } } \ No newline at end of file diff --git a/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.cs b/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.cs index 22c4987..a53bd29 100644 --- a/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.cs +++ b/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.cs @@ -69,6 +69,20 @@ namespace Hawkeye.VisionBuilder.Features.ImageStatistics //treeView.ExpandAll(); } + public void AddExpected(string filePath, string[]? defects) + { + // get folder name as expected defect + string expectedDefect = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(filePath) ?? string.Empty) ?? string.Empty; + if (defects.Contains(expectedDefect, StringComparer.OrdinalIgnoreCase)) + { + AddGoodImage(filePath); + } + else + { + AddBadImage(filePath, [expectedDefect]); + } + } + private void UpdateBranchText(TreeNode node, string name) { if (node == _badNode) diff --git a/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.resx b/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.resx index 1af7de1..399a98b 100644 --- a/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.resx +++ b/Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.resx @@ -1,17 +1,17 @@  - @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + takes image folder name as expected defect. + +if defect is found - the image goes to Good folder +if defect is not found - the image goes to Bad folder, specifying which defect was expected + +Example: +".\LindtCandies\bad_set_b24\darkChocolate\2024-05-16 17-03-35 193.png" +darkChocolate is image folder name + \ No newline at end of file diff --git a/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.Designer.cs b/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.Designer.cs index b8c6027..dfb626c 100644 --- a/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.Designer.cs +++ b/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.Designer.cs @@ -139,7 +139,7 @@ ncInterval.AutoSize = false; ncInterval.Name = "ncInterval"; ncInterval.Size = new Size(64, 23); - ncInterval.Text = "100"; + ncInterval.Text = "1"; // // ckbExecuteWorkflow // diff --git a/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.cs b/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.cs index e777bee..534c71a 100644 --- a/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.cs +++ b/Hawkeye.VisionBuilder/Features/ImagesStrip/ImageStripPanel.cs @@ -102,9 +102,9 @@ namespace Hawkeye.VisionBuilder.Features.ImagesStrip g.DrawString("Not loaded", new Font("Arial", 12), Brushes.Gray, new PointF(0, 0)); } - var allImages = Directory.GetFiles(directory, "*.bmp") - .Concat(Directory.GetFiles(directory, "*.png")) - .Concat(Directory.GetFiles(directory, "*.jpg")) + var allImages = Directory.GetFiles(directory, "*.bmp", SearchOption.AllDirectories) + .Concat(Directory.GetFiles(directory, "*.png", SearchOption.AllDirectories)) + .Concat(Directory.GetFiles(directory, "*.jpg", SearchOption.AllDirectories)) .Where(x => !Path.GetFileNameWithoutExtension(x).Contains("_analysis")) //.Select(x=>new {path=x,bmp = new Bitmap(x)}) .Select(x => new { path = x, bmp = mock }) diff --git a/Hawkeye.VisionBuilder/MainWindow.cs b/Hawkeye.VisionBuilder/MainWindow.cs index a27c113..8655f2c 100644 --- a/Hawkeye.VisionBuilder/MainWindow.cs +++ b/Hawkeye.VisionBuilder/MainWindow.cs @@ -122,14 +122,24 @@ namespace Hawkeye.VisionBuilder { if (_statisticsDialog != null) { - if (result) + if (_statisticsDialog.cbExpectedMode.Checked) { - _statisticsDialog.AddGoodImage((_imagesStripPanel as ImageStripPanel).GetImagePath()); + _statisticsDialog.AddExpected((_imagesStripPanel as ImageStripPanel).GetImagePath(), + _visionStepsPanel.WorkflowList.Operations.Where(x => x.Result == false).Select(x => x.Label) + .ToArray()); } else { - _statisticsDialog.AddBadImage((_imagesStripPanel as ImageStripPanel).GetImagePath(), _visionStepsPanel.WorkflowList.Operations.Where(x=>x.Result==false).Select(x=>x.Label).ToArray()); + if (result) + { + _statisticsDialog.AddGoodImage((_imagesStripPanel as ImageStripPanel).GetImagePath()); + } + else + { + _statisticsDialog.AddBadImage((_imagesStripPanel as ImageStripPanel).GetImagePath(), _visionStepsPanel.WorkflowList.Operations.Where(x => x.Result == false).Select(x => x.Label).ToArray()); + } } + } if (!copyOnStopToolStripMenuItem.Checked) return; diff --git a/VisionBuilder.UI.Windows.Duo/VisionBuilder.UI.Windows.Duo.csproj b/VisionBuilder.UI.Windows.Duo/VisionBuilder.UI.Windows.Duo.csproj index 02523ed..1d913cf 100644 --- a/VisionBuilder.UI.Windows.Duo/VisionBuilder.UI.Windows.Duo.csproj +++ b/VisionBuilder.UI.Windows.Duo/VisionBuilder.UI.Windows.Duo.csproj @@ -8,7 +8,7 @@ enable Inspectron icon-512.ico false - 2.0.10 + 2.0.11 diff --git a/VisionBuilder.UI.Windows.Test/VisionBuilder.UI.Windows.Uno.csproj b/VisionBuilder.UI.Windows.Test/VisionBuilder.UI.Windows.Uno.csproj index 5a746e9..2d07983 100644 --- a/VisionBuilder.UI.Windows.Test/VisionBuilder.UI.Windows.Uno.csproj +++ b/VisionBuilder.UI.Windows.Test/VisionBuilder.UI.Windows.Uno.csproj @@ -8,7 +8,7 @@ enable Inspectron icon-512.ico false - 2.0.10 + 2.0.11