OpenCvSharp (C# OpenCV) 带掩码(mask)的模板匹配使用技巧与演示(附源码)

点击下方卡片,关注“OpenCV与AI深度学习”公众号!

视觉/图像重磅干货,第一时间送达!

前言

具体步骤与思路请参考下面文章:

实战 | OpenCV带掩码(mask)的模板匹配使用技巧与演示(附源码)_Color Space的博客-CSDN博客

下面给出OpenCvSharp对应实现代码(版本--OpenCvSharp4.5.5.20211231) :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using OpenCvSharp;

namespace MatchTemplate_WithMask
{
    class Program
    {
        static void Main(string[] args)
        {
            ///单模板匹配
            Mat img = Cv2.ImRead("A1.png");
            //Mat temp = new Mat(img, new Rect(420, 20, 90, 90)).Clone(); //A2.png
            Mat temp = new Mat(img, new Rect(550+130, 20, 90, 90)).Clone(); //A1.p

猜你喜欢

转载自blog.csdn.net/stq054188/article/details/123750169