grayscale class

remotes/origin/master
syneffort 3 years ago
parent 397bae85a7
commit 6229b51a79
  1. 16
      OpenCV/Form1.Designer.cs
  2. 3
      OpenCV/Form1.cs
  3. 1
      OpenCV/OpenCV.csproj
  4. 23
      OpenCV/OpenCVClass.cs

@ -30,7 +30,9 @@ namespace OpenCV
private void InitializeComponent() private void InitializeComponent()
{ {
this.pictureBoxIpl1 = new OpenCvSharp.UserInterface.PictureBoxIpl(); this.pictureBoxIpl1 = new OpenCvSharp.UserInterface.PictureBoxIpl();
this.pictureBoxIpl2 = new OpenCvSharp.UserInterface.PictureBoxIpl();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl2)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// pictureBoxIpl1 // pictureBoxIpl1
@ -42,17 +44,28 @@ namespace OpenCV
this.pictureBoxIpl1.TabIndex = 0; this.pictureBoxIpl1.TabIndex = 0;
this.pictureBoxIpl1.TabStop = false; this.pictureBoxIpl1.TabStop = false;
// //
// pictureBoxIpl2
//
this.pictureBoxIpl2.Location = new System.Drawing.Point(658, 11);
this.pictureBoxIpl2.Name = "pictureBoxIpl2";
this.pictureBoxIpl2.Size = new System.Drawing.Size(640, 480);
this.pictureBoxIpl2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxIpl2.TabIndex = 1;
this.pictureBoxIpl2.TabStop = false;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(662, 503); this.ClientSize = new System.Drawing.Size(1302, 503);
this.Controls.Add(this.pictureBoxIpl2);
this.Controls.Add(this.pictureBoxIpl1); this.Controls.Add(this.pictureBoxIpl1);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl2)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -60,6 +73,7 @@ namespace OpenCV
#endregion #endregion
private OpenCvSharp.UserInterface.PictureBoxIpl pictureBoxIpl1; private OpenCvSharp.UserInterface.PictureBoxIpl pictureBoxIpl1;
private OpenCvSharp.UserInterface.PictureBoxIpl pictureBoxIpl2;
} }
} }

@ -36,7 +36,10 @@ namespace OpenCV
return; return;
src = new IplImage(fileName); src = new IplImage(fileName);
OpenCVClass Converter = new OpenCVClass();
pictureBoxIpl1.ImageIpl = src; pictureBoxIpl1.ImageIpl = src;
pictureBoxIpl2.ImageIpl = Converter.GrayScale(src);
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -72,6 +72,7 @@
<Compile Include="Form1.Designer.cs"> <Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="OpenCVClass.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">

@ -0,0 +1,23 @@
using OpenCvSharp;
using System;
namespace OpenCV
{
class OpenCVClass : IDisposable
{
IplImage gray;
public IplImage GrayScale(IplImage src)
{
gray = new IplImage(src.Size, BitDepth.U8, 1);
Cv.CvtColor(src, gray, ColorConversion.BgrToGray);
return gray;
}
public void Dispose()
{
if (gray != null)
Cv.ReleaseImage(gray);
}
}
}
Loading…
Cancel
Save