用 OpenCVSharp 4.5 跑一遍 OpenCV 官方教程。

原 OpenCV 官方教程链接:OpenCV: Feature Detection

核心函数:

  1. cv::FeatureDetector
  2. cv::xfeatures2d::SURF
  3. cv::xfeatures2d::SURF::detect
  4. cv::drawKeypoints
using System;
using OpenCvSharp;
using OpenCvSharp.XFeatures2D;

namespace ConsoleApp1
{
    class tutorial47 : ITutorial
    {
        public void Run()
        {
            
            Mat src = Cv2.ImRead(@"I:\csharp\images\box_in_scene.png", ImreadModes.Grayscale);
            if (src.Empty())
            {
                Console.WriteLine( "Could not open or find the image!\n");
                
                return;
            }
            //-- Step 1: Detect the keypoints using SURF Detector
            int minHessian = 400;
            SURF detector =  SURF.Create(minHessian);
            KeyPoint[] keypoints = detector.Detect(src);
            //-- Draw keypoints
            Mat img_keypoints = new Mat();
            Cv2.DrawKeypoints(src, keypoints, img_keypoints);
            //-- Show detected (drawn) keypoints
            Cv2.ImShow("SURF Keypoints", img_keypoints);
            Cv2.WaitKey();            
        }
    }
}

GitHub 加速计划 / opencv31 / opencv
77.38 K
55.71 K
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:2 个月前 )
c3747a68 Added Universal Windows Package build to CI. 4 天前
9b635da5 - 4 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐