flip, rotate

remotes/origin/master
syneffort 3 years ago
parent 7787a4e8af
commit fad668a23c
  1. 1
      OpenCV/Form1.Designer.cs
  2. 4
      OpenCV/Form1.cs
  3. 54
      OpenCV/OpenCVClass.cs

@ -49,6 +49,7 @@ namespace OpenCV
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;
//

@ -39,8 +39,8 @@ namespace OpenCV
OpenCVClass Converter = new OpenCVClass();
pictureBoxIpl1.ImageIpl = src;
//pictureBoxIpl2.ImageIpl = Converter.Resize(src, 0.1, 0.2);
pictureBoxIpl2.ImageIpl = Converter.Slice(src, 750, 840, 350, 150);
//pictureBoxIpl2.ImageIpl = Converter.Symmetry(src, FlipMode.XY);
pictureBoxIpl2.ImageIpl = Converter.Rotate(src, -45);
}
catch (Exception ex)
{

@ -13,6 +13,8 @@ namespace OpenCV
IplImage zoomout;
IplImage resize;
IplImage slice;
IplImage symm;
IplImage rotate;
public IplImage GrayScale(IplImage src)
{
@ -84,24 +86,44 @@ namespace OpenCV
return slice;
}
public IplImage Symmetry(IplImage src, FlipMode mode)
{
symm = new IplImage(src.Size, BitDepth.U8, 3);
Cv.Flip(src, symm, mode);
return symm;
}
public IplImage Rotate(IplImage src, double angle)
{
rotate = new IplImage(src.Size, BitDepth.U8, 3);
CvMat matrix = Cv.GetRotationMatrix2D(new CvPoint2D32f(src.Width / 2, src.Height / 2), angle, 1);
Cv.WarpAffine(src, rotate, matrix, Interpolation.Linear, CvScalar.ScalarAll(0));
return rotate;
}
private void Release(params IplImage[] images)
{
for (int i = 0; i < images.Length; i++)
{
if (images[i] != null)
Cv.ReleaseImage(images[i]);
}
}
public void Dispose()
{
if (gray != null)
Cv.ReleaseImage(gray);
if (inversion != null)
Cv.ReleaseImage(inversion);
if (bin != null)
Cv.ReleaseImage(bin);
if (blur != null)
Cv.ReleaseImage(blur);
if (zoomin != null)
Cv.ReleaseImage(zoomin);
if (zoomout != null)
Cv.ReleaseImage(zoomout);
if (resize != null)
Cv.ReleaseImage(resize);
if (slice != null)
Cv.ReleaseImage(slice);
Release(
gray,
inversion,
bin,
blur,
zoomin,
zoomout,
resize,
slice,
symm,
rotate
);
}
}
}

Loading…
Cancel
Save