This commit is contained in:
meelstorm
2025-11-10 11:49:51 +01:00
parent 745a15b162
commit 0ee132788d
9 changed files with 168 additions and 89 deletions

View File

@@ -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<string, object> 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)]);
}
}

View File

@@ -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;
}
}

View File

@@ -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)

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
@@ -117,4 +117,17 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="cbExpectedMode.ToolTip" xml:space="preserve">
<value>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</value>
</data>
</root>

View File

@@ -139,7 +139,7 @@
ncInterval.AutoSize = false;
ncInterval.Name = "ncInterval";
ncInterval.Size = new Size(64, 23);
ncInterval.Text = "100";
ncInterval.Text = "1";
//
// ckbExecuteWorkflow
//

View File

@@ -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 })

View File

@@ -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;

View File

@@ -8,7 +8,7 @@
<Nullable>enable</Nullable>
<ApplicationIcon>Inspectron icon-512.ico</ApplicationIcon>
<Deterministic>false</Deterministic>
<Version>2.0.10</Version>
<Version>2.0.11</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -8,7 +8,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>Inspectron icon-512.ico</ApplicationIcon>
<Deterministic>false</Deterministic>
<Version>2.0.10</Version>
<Version>2.0.11</Version>
</PropertyGroup>