C# OpenCV 图形图像 图像处理26.3 SURF 特征检测

C# OpenCV 图形图像 图像处理26.3 SURF 特征检测

Visual Studio 2019
C# OpenCV 图形图像 图像处理26.3 SURF 特征检测_第1张图片

//
// 摘要:
//     The SURF constructor.
//
// 参数:
//   hessianThreshold:
//     Only features with keypoint.hessian larger than that are extracted.
//
//   nOctaves:
//     The number of a gaussian pyramid octaves that the detector uses. It is set to
//     4 by default. If you want to get very large features, use the larger value. If
//     you want just small features, decrease it.
//
//   nOctaveLayers:
//     The number of images within each octave of a gaussian pyramid. It is set to 2
//     by default.
//
//   extended:
//     false means basic descriptors (64 elements each), true means extended descriptors
//     (128 elements each)
//
//   upright:
//     false means that detector computes orientation of each feature. true means that
//     the orientation is not computed (which is much, much faster).
public static SURF Create(double hessianThreshold, int nOctaves = 4, int nOctaveLayers = 2, bool extended = true, bool upright = false);
using OpenCvSharp;
using OpenCvSharp.Features2D;
using OpenCvSharp.XFeatures2D;
using System;

namespace OpenCV {

    class Program {
        static void Main(string[] args) {
            Cv2.ImShow("OpenCV", Surf());
            Cv2.WaitKey(1);
            Console.ReadLine();
        }

        /// 
        /// SIFT 特征检测
        /// 
        /// Mat
        public static Mat Sift() {
            Mat src = new(@"C:\Users\hyacinth\Desktop\1.jpg", ImreadModes.Color);
            SIFT sift = SIFT.Create(400);
            KeyPoint[] point;
            sift.DetectAndCompute(src, null, out point, new Mat());
            Mat img = new Mat();
            Cv2.DrawKeypoints(src, point, img);
            return img;
        }

        /// 
        /// SURF 特征检测
        /// 
        /// Mat
        public static Mat Surf() {
            Mat src = new(@"C:\Users\hyacinth\Desktop\1.jpg", ImreadModes.Color);
            SURF surf = SURF.Create(400, 4, 3, false, false);
            KeyPoint[] point;
            surf.DetectAndCompute(src, null, out point, new Mat());
            Mat img = new Mat();
            Cv2.DrawKeypoints(src, point, img);
            return img;
        }

    }
}
/// 
/// SURF 特征检测
/// 
/// Mat
public static Mat Surf() {
    Mat src = new(@"C:\Users\hyacinth\Desktop\1.jpg", ImreadModes.Color);
    SURF surf = SURF.Create(400, 4, 3, false, false);
    KeyPoint[] point;
    surf.DetectAndCompute(src, null, out point, new Mat());
    Mat img = new Mat();
    Cv2.DrawKeypoints(src, point, img);
    return img;
}

C# OpenCV 图形图像 图像处理26.3 SURF 特征检测_第2张图片

你可能感兴趣的:(C#,OpenCV,opencv,人脸识别,计算机视觉,cv)