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); base.Save(dict);
dict[nameof(ModelFilePath)] = ModelFilePath.Path; dict[nameof(ModelFilePath)] = ModelFilePath.Path;
dict[nameof(IgnoreType)] = IgnoreType;
} }
public override void Load(Dictionary<string, object> dict) public override void Load(Dictionary<string, object> dict)
@@ -154,5 +155,8 @@ public class YoloDetectionOperation:BaseOperation
base.Load(dict); base.Load(dict);
if (dict.ContainsKey(nameof(ModelFilePath))) if (dict.ContainsKey(nameof(ModelFilePath)))
ModelFilePath.Path = dict[nameof(ModelFilePath)].ToString(); 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() private void InitializeComponent()
{ {
this.treeView = new System.Windows.Forms.TreeView(); components = new System.ComponentModel.Container();
this.btnReset = new System.Windows.Forms.Button(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageStatisticsDialog));
this.btnClose = new System.Windows.Forms.Button(); treeView = new TreeView();
this.btnBackward = new System.Windows.Forms.Button(); btnReset = new Button();
this.btnForward = new System.Windows.Forms.Button(); btnClose = new Button();
this.SuspendLayout(); btnBackward = new Button();
btnForward = new Button();
cbExpectedMode = new CheckBox();
toolTip1 = new ToolTip(components);
SuspendLayout();
// //
// treeView // treeView
// //
this.treeView.Location = new System.Drawing.Point(12, 12); treeView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
this.treeView.Name = "treeView"; treeView.Location = new Point(10, 9);
this.treeView.Size = new System.Drawing.Size(360, 300); treeView.Margin = new Padding(3, 2, 3, 2);
this.treeView.TabIndex = 0; treeView.Name = "treeView";
this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_NodeMouseClick); treeView.Size = new Size(316, 395);
treeView.TabIndex = 0;
treeView.NodeMouseClick += treeView_NodeMouseClick;
// //
// btnReset // btnReset
// //
this.btnReset.Location = new System.Drawing.Point(12, 320); btnReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
this.btnReset.Name = "btnReset"; btnReset.Location = new Point(10, 409);
this.btnReset.Size = new System.Drawing.Size(75, 30); btnReset.Margin = new Padding(3, 2, 3, 2);
this.btnReset.TabIndex = 1; btnReset.Name = "btnReset";
this.btnReset.Text = "Reset"; btnReset.Size = new Size(66, 22);
this.btnReset.UseVisualStyleBackColor = true; btnReset.TabIndex = 1;
this.btnReset.Click += new System.EventHandler(this.btnReset_Click); btnReset.Text = "Reset";
btnReset.UseVisualStyleBackColor = true;
btnReset.Click += btnReset_Click;
// //
// btnClose // btnClose
// //
this.btnClose.Location = new System.Drawing.Point(297, 320); btnClose.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
this.btnClose.Name = "btnClose"; btnClose.Location = new Point(260, 409);
this.btnClose.Size = new System.Drawing.Size(75, 30); btnClose.Margin = new Padding(3, 2, 3, 2);
this.btnClose.TabIndex = 2; btnClose.Name = "btnClose";
this.btnClose.Text = "Close"; btnClose.Size = new Size(66, 22);
this.btnClose.UseVisualStyleBackColor = true; btnClose.TabIndex = 2;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click); btnClose.Text = "Close";
btnClose.UseVisualStyleBackColor = true;
btnClose.Click += btnClose_Click;
// //
// btnBackward // btnBackward
// //
this.btnBackward.Location = new System.Drawing.Point(100, 320); btnBackward.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
this.btnBackward.Name = "btnBackward"; btnBackward.Location = new Point(88, 409);
this.btnBackward.Size = new System.Drawing.Size(75, 30); btnBackward.Margin = new Padding(3, 2, 3, 2);
this.btnBackward.TabIndex = 3; btnBackward.Name = "btnBackward";
this.btnBackward.Text = "<"; btnBackward.Size = new Size(66, 22);
this.btnBackward.UseVisualStyleBackColor = true; btnBackward.TabIndex = 3;
this.btnBackward.Click += new System.EventHandler(this.btnBackward_Click); btnBackward.Text = "<";
btnBackward.UseVisualStyleBackColor = true;
btnBackward.Click += btnBackward_Click;
// //
// btnForward // btnForward
// //
this.btnForward.Location = new System.Drawing.Point(190, 320); btnForward.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
this.btnForward.Name = "btnForward"; btnForward.Location = new Point(166, 409);
this.btnForward.Size = new System.Drawing.Size(75, 30); btnForward.Margin = new Padding(3, 2, 3, 2);
this.btnForward.TabIndex = 4; btnForward.Name = "btnForward";
this.btnForward.Text = ">"; btnForward.Size = new Size(66, 22);
this.btnForward.UseVisualStyleBackColor = true; btnForward.TabIndex = 4;
this.btnForward.Click += new System.EventHandler(this.btnForward_Click); 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 // ImageStatisticsDialog
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 361); ClientSize = new Size(336, 476);
this.Controls.Add(this.btnForward); Controls.Add(cbExpectedMode);
this.Controls.Add(this.btnBackward); Controls.Add(btnForward);
this.Controls.Add(this.btnClose); Controls.Add(btnBackward);
this.Controls.Add(this.btnReset); Controls.Add(btnClose);
this.Controls.Add(this.treeView); Controls.Add(btnReset);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; Controls.Add(treeView);
this.MaximizeBox = false; FormBorderStyle = FormBorderStyle.FixedDialog;
this.MinimizeBox = false; Margin = new Padding(3, 2, 3, 2);
this.Name = "ImageStatisticsDialog"; MaximizeBox = false;
this.Text = "Image Statistics"; MinimizeBox = false;
this.ResumeLayout(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(); //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) private void UpdateBranchText(TreeNode node, string name)
{ {
if (node == _badNode) if (node == _badNode)

View File

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

View File

@@ -139,7 +139,7 @@
ncInterval.AutoSize = false; ncInterval.AutoSize = false;
ncInterval.Name = "ncInterval"; ncInterval.Name = "ncInterval";
ncInterval.Size = new Size(64, 23); ncInterval.Size = new Size(64, 23);
ncInterval.Text = "100"; ncInterval.Text = "1";
// //
// ckbExecuteWorkflow // 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)); g.DrawString("Not loaded", new Font("Arial", 12), Brushes.Gray, new PointF(0, 0));
} }
var allImages = Directory.GetFiles(directory, "*.bmp") var allImages = Directory.GetFiles(directory, "*.bmp", SearchOption.AllDirectories)
.Concat(Directory.GetFiles(directory, "*.png")) .Concat(Directory.GetFiles(directory, "*.png", SearchOption.AllDirectories))
.Concat(Directory.GetFiles(directory, "*.jpg")) .Concat(Directory.GetFiles(directory, "*.jpg", SearchOption.AllDirectories))
.Where(x => !Path.GetFileNameWithoutExtension(x).Contains("_analysis")) .Where(x => !Path.GetFileNameWithoutExtension(x).Contains("_analysis"))
//.Select(x=>new {path=x,bmp = new Bitmap(x)}) //.Select(x=>new {path=x,bmp = new Bitmap(x)})
.Select(x => new { path = x, bmp = mock }) .Select(x => new { path = x, bmp = mock })

View File

@@ -122,14 +122,24 @@ namespace Hawkeye.VisionBuilder
{ {
if (_statisticsDialog != null) 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 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; if (!copyOnStopToolStripMenuItem.Checked) return;

View File

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

View File

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