Emgu.CV.BinaryMatching 1.0.1

dotnet add package Emgu.CV.BinaryMatching --version 1.0.1
                    
NuGet\Install-Package Emgu.CV.BinaryMatching -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Emgu.CV.BinaryMatching" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Emgu.CV.BinaryMatching" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Emgu.CV.BinaryMatching" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Emgu.CV.BinaryMatching --version 1.0.1
                    
#r "nuget: Emgu.CV.BinaryMatching, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Emgu.CV.BinaryMatching@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Emgu.CV.BinaryMatching&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Emgu.CV.BinaryMatching&version=1.0.1
                    
Install as a Cake Tool

Emgu.CV.BinaryMatching

Emgu.CV.BinaryMatching is a high-performance C# library built on top of EmguCV, designed to perform template matching on binary images with rotation invariance. This library offers exceptional speed, making it suitable for real-time applications and capable of detecting multiple objects in an image.

Features

  • Binary Image Template Matching: Specifically optimized for binary (black and white) images.
  • Rotation Invariance: Detects objects regardless of their rotation angle.
  • High Speed: Efficient implementation allows real-time processing.
  • Multiple Object Detection: Capable of identifying more than one matching object in the image.

Requirements

  • .NET Framework 4.6.1+
  • Emgu.CV 4.9.0.5494+
  • Emgu.CV.Bitmap 4.9.0.5494+
  • Emgu.CV.runtime.windows 4.9.0.5494+

Installation

You can install Emgu.CV.BinaryMatching via NuGet:

Install-Package Emgu.CV.BinaryMatching -Version 1.0.1

Usage

Please set the build architecture to either "x86" or "x64". Do not set the architecture to "Any CPU". Here's a simple example demonstrating how to use the Emgu.CV.BinaryMatching library:

using Emgu.CV;
using Emgu.CV.BinaryMatching;
using Emgu.CV.CvEnum;
using System.Linq;

public class Example
{
	public void DetectObject()
	{
		Mat src = CvInvoke.Imread("E:\\src.jpg", ImreadModes.Grayscale);
		Mat templ = CvInvoke.Imread("E:\\template.jpg", ImreadModes.Grayscale);

		Mat binarySrc = new Mat();
		Mat binaryTempl = new Mat();

		// Adjust the parameters appropriately.
		CvInvoke.Threshold(src, binarySrc, 70, 255, ThresholdType.BinaryInv);
		CvInvoke.Threshold(templ, binaryTempl, 70, 255, ThresholdType.BinaryInv);

		CvInvoke.Imshow("binary src", binarySrc);
		CvInvoke.Imshow("binary templ", binaryTempl);

		/* Find one matched object
		* "templScore" is MatchTemplate score
		* "shapeScore" is MatShapes score*/
		MatchedObject obj = FlatMatcher.FindOne(binarySrc, binaryTempl, templScore: 0.9, shapeScore: 0.1);

		/* Or use Find if you want to find a maximum of 3 objects.
		MatchedObject[] objs = FlatMatcher.Find(binarySrc, binaryTempl, count: 3, templScore: 0.9, shapeScore: 0.1);*/

		Image<Bgr, byte> result = src.ToImage<Bgr, byte>();

		if (obj != null)
		{
			// Draw the rotated rectangle.
			System.Drawing.Point[] points = obj.RotatedRect.GetVertices().Select(pF => System.Drawing.Point.Round(pF)).ToArray();
			CvInvoke.Polylines(result, points, true, new MCvScalar(0, 255, 0), 1, LineType.AntiAlias);

			// Draw the center point.
			System.Drawing.Point center = System.Drawing.Point.Round(obj.Center);
			CvInvoke.Circle(result, center, 1, new MCvScalar(0, 255, 0), 1, LineType.AntiAlias);

			// Draw the angle text (the angle difference from the template).
			CvInvoke.PutText(result, obj.Angle.ToString("F1"), center, FontFace.HersheySimplex, 1, new MCvScalar(0,0,255), 1, LineType.AntiAlias);
		}

		CvInvoke.Imshow("result", result);
	}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 252 9/25/2024
1.0.0 129 9/24/2024

fix bugs