xw.OpenCvSharp4.LineMod
4.11.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.8
This package targets .NET Framework 4.8. The package is compatible with this framework or higher.
dotnet add package xw.OpenCvSharp4.LineMod --version 4.11.0
NuGet\Install-Package xw.OpenCvSharp4.LineMod -Version 4.11.0
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="xw.OpenCvSharp4.LineMod" Version="4.11.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="xw.OpenCvSharp4.LineMod" Version="4.11.0" />
<PackageReference Include="xw.OpenCvSharp4.LineMod" />
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 xw.OpenCvSharp4.LineMod --version 4.11.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: xw.OpenCvSharp4.LineMod, 4.11.0"
#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 xw.OpenCvSharp4.LineMod@4.11.0
#: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=xw.OpenCvSharp4.LineMod&version=4.11.0
#tool nuget:?package=xw.OpenCvSharp4.LineMod&version=4.11.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
xw.OpenCvSharp4.LineMod
为 OpenCvSharp4 补上 cv::linemod::Detector(LINE-MOD 模板匹配)能力。该类位于 opencv_contrib 的 rgbd 模块,OpenCvSharp 托管层未暴露,本包通过自建原生桥接层直接调用 OpenCV 4.11 + opencv_contrib。
安装
dotnet add package xw.OpenCvSharp4.LineMod --version 4.11.0
支持 netstandard2.0、net48、net6.0、net8.0、net9.0、net10.0,原生库为 win-x64。
用法
using OpenCvSharp;
using OpenCvSharp.LineMod;
using var template = Cv2.ImRead("object.png", ImreadModes.Color);
using var mask = new Mat(template.Size(), MatType.CV_8UC1, Scalar.All(255)); // 非零为有效像素
using var detector = new LineModDetector(); // 默认 ColorGradient 单模态(getDefaultLINE)
int templateId = detector.AddTemplate(template, "cup", mask, out Rect bbox);
using var scene = Cv2.ImRead("scene.jpg", ImreadModes.Color);
foreach (var m in detector.Match(scene, threshold: 50f))
Console.WriteLine($"class={m.ClassId} template={m.TemplateId} at ({m.X},{m.Y}) sim={m.Similarity:F1}");
模板可持久化:
detector.Save("templates.yml");
using var loaded = LineModDetector.Load("templates.yml");
AddTemplate的mask传null表示整幅图有效。Match的threshold为相似度百分比(0~100),默认 50。- 输入支持灰度和 4 通道图像,内部统一转换为 8UC3。
实现说明
- 原生层
linemod_shim.cpp封装getDefaultLINE/addTemplate/match/read/write - 图像与掩码以裸像素指针传入,避免与 OpenCvSharp 内部 OpenCV 的
cv::Mat混用 - 原生库名为无点的
ocvlinemod.dll,规避 .NET Framework 对多点号 DllImport 的解析问题
许可
- 本包:Apache-2.0
- OpenCV 4.11 / opencv_contrib:Apache-2.0
- 静态链接组件:BSD-3-Clause(ittnotify、Protocol Buffers)、Zlib
完整第三方声明见包内 THIRD-PARTY-NOTICES.txt、OpenCV-LICENSE.txt。
本包为非官方扩展,与 OpenCvSharp、OpenCV 无隶属关系。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.8
- OpenCvSharp4 (>= 4.11.0.20250507)
-
.NETStandard 2.0
- OpenCvSharp4 (>= 4.11.0.20250507)
-
net10.0
- OpenCvSharp4 (>= 4.11.0.20250507)
-
net6.0
- OpenCvSharp4 (>= 4.11.0.20250507)
-
net8.0
- OpenCvSharp4 (>= 4.11.0.20250507)
-
net9.0
- OpenCvSharp4 (>= 4.11.0.20250507)
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 |
|---|---|---|
| 4.11.0 | 67 | 11/29/2026 |