pictureBox2.Image = templateImage.ToBitmap();
            const double threshold = 0.83; // 模板匹配的阈值
            double rotationStep = 10; // 旋转角度步长
            double minScale = 0.9; // 最小缩放比例
            double maxScale = 1.1; // 最大缩放比例
            double scaleStep = 0.1; // 缩放比例步长
            double overlapThreshold = 0.3; // NMS的重叠阈值

            // 转为灰度图像
            //Mat sourceGray = sourceImage.CvtColor(ColorConversionCodes.BGR2GRAY);
            //Mat templateGray = templateImage.CvtColor(ColorConversionCodes.BGR2GRAY);

            Mat sourceGray = new Mat();
            Mat templateGray = new Mat();
            if (sourceImage.Channels() == 1)
            {
                sourceGray = sourceImage;
                templateGray = templateImage;

            }
            List<Rect> possibleMatches = new List<Rect>();
            List<RotatedRect> lstMatches = new List<RotatedRect>();
            // 循环多个角度和缩放比例

 

在原图上鼠标单击后拖拽 可自定义模板哦。

 发布版exe可到主页下载,不卖源码哈

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐