C # OpenCvsharp template match

tags: Identify  opencv  c#

C # OpenCvsharp template match

public static System.Drawing.Point FindPicFromImage(Mat srcMat, Mat dstMat, double threshold = 0.9)
{

        OpenCvSharp.OutputArray outArray = null;
        try
        {
            srcMat = srcMat.CvtColor(ColorConversionCodes.RGBA2RGB);

            outArray = OpenCvSharp.OutputArray.Create(srcMat);

            OpenCvSharp.Cv2.MatchTemplate(srcMat, dstMat, outArray, TemplateMatchModes.SqDiff);
            double minValue, maxValue;
            OpenCvSharp.Point location, point;
            OpenCvSharp.Cv2.MinMaxLoc(OpenCvSharp.InputArray.Create(outArray.GetMat()), out minValue, out maxValue, out location, out point);
            Console.WriteLine(maxValue);
            if (maxValue >= threshold)
                return new System.Drawing.Point(point.X, point.Y);
            return System.Drawing.Point.Empty;
        }
        catch (Exception ex)
        {
            return System.Drawing.Point.Empty;
        }
        finally
        {

        }
    }

Intelligent Recommendation

C#, opencvsharp related questions

C#, opencvsharp related questions The reason why C# VideoCapture cannot read the video: Custom picture Background subtraction, rotary gray diagram C# OPENCVSHARP Get the background picture Threshold F...

C#image processing (opencvsharp)

1. Overview This article records the image processing using the OpenCVSHARP package. Including two methods to enhance image contrast, zoom images, and delete transparent pixels. Second, conventional m...

opencvsharp c# Multi-template pattent recognition and positioning, draw box, write position, set similarity, by opening piturebox,bitmapconveter.tomap

using OpenCvSharp; using OpenCvSharp.Extensions; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.T...

C++ uses template functions to match built-in arrays

Matching built-in arrays with function templates This is a point of knowledge I saw when I read the Matrix library related content in "Programming Principles and Practices (Second Edition) (Advan...

OpenCV + C ++ makes simple image template match

1. Cropped a piece as a template image on the original image, if the image is not cropping, the size is changed, affects the matching result.      2. Run the code 3. Results image  ...

More Recommendation

[C#] Read the camera and display it with OpenCvSharp

1, first install OpenCvSharp, use cv2 function to get the device, and convert the image to Bitmap 2, open the thread when called, can be called within the main function, can also be called within the ...

Use OpenCV in C# (using OpenCVSharp)

1. What is OpenCVSharp In order to solve the problem of writing OpenCV programs under Csharp, I have done in-depth research and implemented a highly efficient method (GOCW); I have seen OpenCVSharp oc...

c# opencvsharp study notes (1)

opencvsharp is a computer vision library for c#. Its functions are similar to opencv, but there are still some differences. It seems that there are no tutorials on this library on the Internet, but th...

c# opencvsharp study notes (2)

The two most common ways to read pictures, personally prefer to use the former. These are several enumerations of imreadmodes. Just remember that the fourth one is converted to grayscale. For details,...

Use OpenCV (using OpenCvsharp) in C #

What is the characteristic of OpenCvsharp? Directly encapsulated more OpenCV methods, reducing the difficulty of learning, more convenient than Emgucv Most inherited the IDisposable interface for easy...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top