interim dialog

master
syneffort 12 months ago
parent 19af6a4038
commit b8da8da9c2
  1. 111
      OpenCV/Forms/CVBinDialog.Designer.cs
  2. 39
      OpenCV/Forms/CVBinDialog.cs
  3. 120
      OpenCV/Forms/CVBinDialog.resx
  4. 13
      OpenCV/Forms/MainForm.Designer.cs
  5. 21
      OpenCV/Forms/MainForm.cs
  6. 9
      OpenCV/OpenCV.csproj
  7. 11
      OpenCV/OpenCV/OpenCVClass.cs

@ -0,0 +1,111 @@
namespace OpenCV.Forms
{
partial class CVBinDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.picSource = new OpenCvSharp.UserInterface.PictureBoxIpl();
this.picConverted = new OpenCvSharp.UserInterface.PictureBoxIpl();
this.picBinary = new OpenCvSharp.UserInterface.PictureBoxIpl();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picConverted)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picBinary)).BeginInit();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.Controls.Add(this.picSource, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.picConverted, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.picBinary, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(800, 450);
this.tableLayoutPanel1.TabIndex = 2;
//
// picSource
//
this.picSource.Dock = System.Windows.Forms.DockStyle.Fill;
this.picSource.Location = new System.Drawing.Point(3, 3);
this.picSource.Name = "picSource";
this.picSource.Size = new System.Drawing.Size(260, 444);
this.picSource.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picSource.TabIndex = 0;
this.picSource.TabStop = false;
//
// picConverted
//
this.picConverted.Dock = System.Windows.Forms.DockStyle.Fill;
this.picConverted.Location = new System.Drawing.Point(535, 3);
this.picConverted.Name = "picConverted";
this.picConverted.Size = new System.Drawing.Size(262, 444);
this.picConverted.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picConverted.TabIndex = 0;
this.picConverted.TabStop = false;
//
// picBinary
//
this.picBinary.Dock = System.Windows.Forms.DockStyle.Fill;
this.picBinary.Location = new System.Drawing.Point(269, 3);
this.picBinary.Name = "picBinary";
this.picBinary.Size = new System.Drawing.Size(260, 444);
this.picBinary.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picBinary.TabIndex = 0;
this.picBinary.TabStop = false;
//
// CVBinDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "CVBinDialog";
this.Text = "CVBinDialog";
this.tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picConverted)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picBinary)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private OpenCvSharp.UserInterface.PictureBoxIpl picSource;
private OpenCvSharp.UserInterface.PictureBoxIpl picConverted;
private OpenCvSharp.UserInterface.PictureBoxIpl picBinary;
}
}

@ -0,0 +1,39 @@
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OpenCV.Forms
{
public partial class CVBinDialog : Form
{
public IplImage Source
{
get { return picSource.ImageIpl; }
set { picSource.ImageIpl = value; }
}
public IplImage Binary
{
get { return picBinary.ImageIpl; }
set { picBinary.ImageIpl = value; }
}
public IplImage Converted
{
get { return picConverted.ImageIpl; }
set { picConverted.ImageIpl = value; }
}
public CVBinDialog()
{
InitializeComponent();
}
}
}

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
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
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<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
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
mimetype set.
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
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
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
: 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
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -33,6 +33,7 @@
this.btnLapace = new System.Windows.Forms.Button(); this.btnLapace = new System.Windows.Forms.Button();
this.btnContour = new System.Windows.Forms.Button(); this.btnContour = new System.Windows.Forms.Button();
this.btnScanContour = new System.Windows.Forms.Button(); this.btnScanContour = new System.Windows.Forms.Button();
this.btnTest = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnCanny // btnCanny
@ -85,6 +86,16 @@
this.btnScanContour.UseVisualStyleBackColor = true; this.btnScanContour.UseVisualStyleBackColor = true;
this.btnScanContour.Click += new System.EventHandler(this.btnScanContour_Click); this.btnScanContour.Click += new System.EventHandler(this.btnScanContour_Click);
// //
// btnTest
//
this.btnTest.Location = new System.Drawing.Point(13, 330);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(75, 23);
this.btnTest.TabIndex = 0;
this.btnTest.Text = "Test";
this.btnTest.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@ -92,6 +103,7 @@
this.ClientSize = new System.Drawing.Size(470, 365); this.ClientSize = new System.Drawing.Size(470, 365);
this.Controls.Add(this.btnScanContour); this.Controls.Add(this.btnScanContour);
this.Controls.Add(this.btnContour); this.Controls.Add(this.btnContour);
this.Controls.Add(this.btnTest);
this.Controls.Add(this.btnLapace); this.Controls.Add(this.btnLapace);
this.Controls.Add(this.btnSobel); this.Controls.Add(this.btnSobel);
this.Controls.Add(this.btnCanny); this.Controls.Add(this.btnCanny);
@ -108,5 +120,6 @@
private System.Windows.Forms.Button btnLapace; private System.Windows.Forms.Button btnLapace;
private System.Windows.Forms.Button btnContour; private System.Windows.Forms.Button btnContour;
private System.Windows.Forms.Button btnScanContour; private System.Windows.Forms.Button btnScanContour;
private System.Windows.Forms.Button btnTest;
} }
} }

@ -88,8 +88,9 @@ namespace OpenCV.Forms
OpenCVClass converter = new OpenCVClass(); OpenCVClass converter = new OpenCVClass();
IplImage converted = converter.FindContour(src); IplImage converted = converter.FindContour(src);
CVDialog dlg = new CVDialog(); CVBinDialog dlg = new CVBinDialog();
dlg.Source = src; dlg.Source = src;
dlg.Binary = converter.InterimBinaryImage;
dlg.Converted = converted; dlg.Converted = converted;
dlg.ShowDialog(); dlg.ShowDialog();
@ -105,6 +106,24 @@ namespace OpenCV.Forms
OpenCVClass converter = new OpenCVClass(); OpenCVClass converter = new OpenCVClass();
IplImage converted = converter.ScanContour(src); IplImage converted = converter.ScanContour(src);
CVBinDialog dlg = new CVBinDialog();
dlg.Source = src;
dlg.Binary = converter.InterimBinaryImage;
dlg.Converted = converted;
dlg.ShowDialog();
converter.Dispose();
}
private void btnTest_Click(object sender, EventArgs e)
{
IplImage src = GetImage();
if (src == null)
return;
OpenCVClass converter = new OpenCVClass();
IplImage converted = converter.Binary(src, 150);
CVDialog dlg = new CVDialog(); CVDialog dlg = new CVDialog();
dlg.Source = src; dlg.Source = src;
dlg.Converted = converted; dlg.Converted = converted;

@ -72,6 +72,12 @@
<Compile Include="Form1.Designer.cs"> <Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Forms\CVBinDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\CVBinDialog.Designer.cs">
<DependentUpon>CVBinDialog.cs</DependentUpon>
</Compile>
<Compile Include="Forms\CVDialog.cs"> <Compile Include="Forms\CVDialog.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -92,6 +98,9 @@
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Forms\CVBinDialog.resx">
<DependentUpon>CVBinDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\CVDialog.resx"> <EmbeddedResource Include="Forms\CVDialog.resx">
<DependentUpon>CVDialog.cs</DependentUpon> <DependentUpon>CVDialog.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

@ -12,10 +12,15 @@ namespace OpenCV.OpenCV
IplConvKernel _convKernel; IplConvKernel _convKernel;
public IplImage InterimGrayImage { get; set; }
public IplImage InterimBinaryImage { get; set; }
public IplImage GrayScale(IplImage src) public IplImage GrayScale(IplImage src)
{ {
_gray = new IplImage(src.Size, BitDepth.U8, 1); _gray = new IplImage(src.Size, BitDepth.U8, 1);
Cv.CvtColor(src, _gray, ColorConversion.BgrToGray); Cv.CvtColor(src, _gray, ColorConversion.BgrToGray);
InterimGrayImage = new IplImage(_gray.Size, BitDepth.U8, 1);
Cv.Copy(_gray, InterimGrayImage);
return _gray; return _gray;
} }
@ -30,6 +35,8 @@ namespace OpenCV.OpenCV
{ {
_bin = GrayScale(src); _bin = GrayScale(src);
Cv.Threshold(_bin, _bin, threshold, 255, ThresholdType.Binary); Cv.Threshold(_bin, _bin, threshold, 255, ThresholdType.Binary);
InterimBinaryImage = new IplImage(_bin.Size, BitDepth.U8, 1);
Cv.Copy(_bin, InterimBinaryImage);
return _bin; return _bin;
} }
@ -252,7 +259,9 @@ namespace OpenCV.OpenCV
Release( Release(
_cvt, _cvt,
_gray, _gray,
_bin); _bin,
InterimGrayImage,
InterimGrayImage);
} }
public IplConvKernel ConvKernel public IplConvKernel ConvKernel

Loading…
Cancel
Save