OpenCVSharp 4.5 特征检测

用 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();            
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值