corner GoodFeatureToTrack

master
syneffort 12 months ago
parent b8da8da9c2
commit 2b602b16e1
  1. 13
      OpenCV/Forms/MainForm.Designer.cs
  2. 17
      OpenCV/Forms/MainForm.cs
  3. 1
      OpenCV/OpenCV.csproj
  4. 34
      OpenCV/OpenCV/Corner.cs

@ -34,6 +34,7 @@
this.btnContour = new System.Windows.Forms.Button();
this.btnScanContour = new System.Windows.Forms.Button();
this.btnTest = new System.Windows.Forms.Button();
this.btnG2Track = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnCanny
@ -96,11 +97,22 @@
this.btnTest.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// btnG2Track
//
this.btnG2Track.Location = new System.Drawing.Point(122, 71);
this.btnG2Track.Name = "btnG2Track";
this.btnG2Track.Size = new System.Drawing.Size(102, 23);
this.btnG2Track.TabIndex = 0;
this.btnG2Track.Text = "Corner -G2T";
this.btnG2Track.UseVisualStyleBackColor = true;
this.btnG2Track.Click += new System.EventHandler(this.btnG2Track_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(470, 365);
this.Controls.Add(this.btnG2Track);
this.Controls.Add(this.btnScanContour);
this.Controls.Add(this.btnContour);
this.Controls.Add(this.btnTest);
@ -121,5 +133,6 @@
private System.Windows.Forms.Button btnContour;
private System.Windows.Forms.Button btnScanContour;
private System.Windows.Forms.Button btnTest;
private System.Windows.Forms.Button btnG2Track;
}
}

@ -131,5 +131,22 @@ namespace OpenCV.Forms
converter.Dispose();
}
private void btnG2Track_Click(object sender, EventArgs e)
{
IplImage src = GetImage();
if (src == null)
return;
OpenCVClass converter = new OpenCVClass();
IplImage converted = converter.GoodFeaturesToTrack(src);
CVDialog dlg = new CVDialog();
dlg.Source = src;
dlg.Converted = converted;
dlg.ShowDialog();
converter.Dispose();
}
}
}

@ -91,6 +91,7 @@
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="OpenCV\Contour.cs" />
<Compile Include="OpenCV\Corner.cs" />
<Compile Include="OpenCV\Edge.cs" />
<Compile Include="OpenCV\OpenCVClass.cs" />
<Compile Include="Program.cs" />

@ -0,0 +1,34 @@
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenCV.OpenCV
{
internal partial class OpenCVClass
{
public IplImage GoodFeaturesToTrack(IplImage src)
{
_cvt = new IplImage(src.Size, BitDepth.U8, 3);
IplImage eigImage = new IplImage(src.Size, BitDepth.U8, 1);
IplImage tempImage = new IplImage(src.Size, BitDepth.U8, 1);
Cv.Copy(src, _cvt);
_gray = GrayScale(src);
CvPoint2D32f[] corners;
int cornerCount = 150;
Cv.GoodFeaturesToTrack(_gray, eigImage, tempImage, out corners, ref cornerCount, 0.01, 5);
for (int i = 0; i < cornerCount; i++)
{
Cv.DrawCircle(_cvt, corners[i], 3, CvColor.Red, 1);
}
return _cvt;
}
}
}
Loading…
Cancel
Save