diff --git a/OpenCV/Forms/CVBinDialog.Designer.cs b/OpenCV/Forms/CVBinDialog.Designer.cs
new file mode 100644
index 0000000..9f51ec5
--- /dev/null
+++ b/OpenCV/Forms/CVBinDialog.Designer.cs
@@ -0,0 +1,111 @@
+namespace OpenCV.Forms
+{
+ partial class CVBinDialog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/OpenCV/Forms/CVBinDialog.cs b/OpenCV/Forms/CVBinDialog.cs
new file mode 100644
index 0000000..1ed4c71
--- /dev/null
+++ b/OpenCV/Forms/CVBinDialog.cs
@@ -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();
+ }
+ }
+}
diff --git a/OpenCV/Forms/CVBinDialog.resx b/OpenCV/Forms/CVBinDialog.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/OpenCV/Forms/CVBinDialog.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/OpenCV/Forms/MainForm.Designer.cs b/OpenCV/Forms/MainForm.Designer.cs
index f7cbad7..20455a2 100644
--- a/OpenCV/Forms/MainForm.Designer.cs
+++ b/OpenCV/Forms/MainForm.Designer.cs
@@ -33,6 +33,7 @@
this.btnLapace = new System.Windows.Forms.Button();
this.btnContour = new System.Windows.Forms.Button();
this.btnScanContour = new System.Windows.Forms.Button();
+ this.btnTest = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnCanny
@@ -85,6 +86,16 @@
this.btnScanContour.UseVisualStyleBackColor = true;
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -92,6 +103,7 @@
this.ClientSize = new System.Drawing.Size(470, 365);
this.Controls.Add(this.btnScanContour);
this.Controls.Add(this.btnContour);
+ this.Controls.Add(this.btnTest);
this.Controls.Add(this.btnLapace);
this.Controls.Add(this.btnSobel);
this.Controls.Add(this.btnCanny);
@@ -108,5 +120,6 @@
private System.Windows.Forms.Button btnLapace;
private System.Windows.Forms.Button btnContour;
private System.Windows.Forms.Button btnScanContour;
+ private System.Windows.Forms.Button btnTest;
}
}
\ No newline at end of file
diff --git a/OpenCV/Forms/MainForm.cs b/OpenCV/Forms/MainForm.cs
index 26f690d..7bff73f 100644
--- a/OpenCV/Forms/MainForm.cs
+++ b/OpenCV/Forms/MainForm.cs
@@ -88,8 +88,9 @@ namespace OpenCV.Forms
OpenCVClass converter = new OpenCVClass();
IplImage converted = converter.FindContour(src);
- CVDialog dlg = new CVDialog();
+ CVBinDialog dlg = new CVBinDialog();
dlg.Source = src;
+ dlg.Binary = converter.InterimBinaryImage;
dlg.Converted = converted;
dlg.ShowDialog();
@@ -105,6 +106,24 @@ namespace OpenCV.Forms
OpenCVClass converter = new OpenCVClass();
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();
dlg.Source = src;
dlg.Converted = converted;
diff --git a/OpenCV/OpenCV.csproj b/OpenCV/OpenCV.csproj
index c081a08..c1579e6 100644
--- a/OpenCV/OpenCV.csproj
+++ b/OpenCV/OpenCV.csproj
@@ -72,6 +72,12 @@
Form1.cs
+
+ Form
+
+
+ CVBinDialog.cs
+
Form
@@ -92,6 +98,9 @@
Form1.cs
+
+ CVBinDialog.cs
+
CVDialog.cs
diff --git a/OpenCV/OpenCV/OpenCVClass.cs b/OpenCV/OpenCV/OpenCVClass.cs
index 12c07a7..7b7bdad 100644
--- a/OpenCV/OpenCV/OpenCVClass.cs
+++ b/OpenCV/OpenCV/OpenCVClass.cs
@@ -12,10 +12,15 @@ namespace OpenCV.OpenCV
IplConvKernel _convKernel;
+ public IplImage InterimGrayImage { get; set; }
+ public IplImage InterimBinaryImage { get; set; }
+
public IplImage GrayScale(IplImage src)
{
_gray = new IplImage(src.Size, BitDepth.U8, 1);
Cv.CvtColor(src, _gray, ColorConversion.BgrToGray);
+ InterimGrayImage = new IplImage(_gray.Size, BitDepth.U8, 1);
+ Cv.Copy(_gray, InterimGrayImage);
return _gray;
}
@@ -30,6 +35,8 @@ namespace OpenCV.OpenCV
{
_bin = GrayScale(src);
Cv.Threshold(_bin, _bin, threshold, 255, ThresholdType.Binary);
+ InterimBinaryImage = new IplImage(_bin.Size, BitDepth.U8, 1);
+ Cv.Copy(_bin, InterimBinaryImage);
return _bin;
}
@@ -252,7 +259,9 @@ namespace OpenCV.OpenCV
Release(
_cvt,
_gray,
- _bin);
+ _bin,
+ InterimGrayImage,
+ InterimGrayImage);
}
public IplConvKernel ConvKernel