本文介绍了Aruco DetectMarkers 实现 Emgu C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 detectMarkers 函数来检测 ArUco 标记.我正在使用 Emgu 在 c# 中编写代码.使用该功能时出现多个错误.我正在关注此链接中的示例 https://docs.opencv.org/3.4/d5/dae/tutorial_aruco_detection.html.这是我的代码:

I want to use the detectMarkers function for detection ArUco Markers. I am using Emgu to write the code in c#. I get multiple errors when I use the function. I am following the example in this link https://docs.opencv.org/3.4/d5/dae/tutorial_aruco_detection.html. This is my code:

Dictionary.PredefinedDictionaryName name = new Dictionary.PredefinedDictionaryName();
Dictionary Dict = new Dictionary(name);
VectorOfVectorOfPointF Corners = new VectorOfVectorOfPointF();
VectorOfInt Ids = new VectorOfInt();
DetectorParameters Parameters = new DetectorParameters();

//If I uncomment this I get rid of some errors but new errors arise
/*
Parameters.AdaptiveThreshWinSizeMin = 5;
Parameters.AdaptiveThreshWinSizeMax = 21;
Parameters.AdaptiveThreshWinSizeStep = 4;
*/

VectorOfVectorOfPointF Rejected = new VectorOfVectorOfPointF();
ArucoInvoke.DetectMarkers(imgOriginal, Dict, Corners, Ids, Parameters, Rejected);

注释三行的错误是

CvException: OpenCV: params->adaptiveThreshWinSizeMin >= 3 && params->adaptiveThreshWinSizeMax >= 3

取消注释这三行会导致另一个错误

With the three lines uncommented it gives another error

OpenCV: minPerimeterRate > 0 && maxPerimeterRate > 0 && accuracyRate > 0 && minCornerDistanceRate >= 0 && minDistanceToBorder >= 0

是否需要为DetectorParameters设置各种默认值?据我在文档中看到的 DetectorParameters 已经有默认值.这些默认值是不是不行,还是有其他原因导致我收到这些错误?

Is it that I need to set all kinds of default values for DetectorParameters? As far as I see in the documentation there are already default values for the DetectorParameters. Are those default values not okay or is there another reason why I get these errors?

非常感谢您的帮助!

推荐答案

我最近遇到了同样的问题,想出了另一个解决方案.

I had the same problem recently, and figured out another solution.

您收到这些错误的原因是 new DetectorParameters(); 没有使用默认值创建新的参数对象.

The reason that you were getting those errors, is because new DetectorParameters(); doesn't create a new parameter object with the default values.

您可以使用DetectorParameters.GetDefault();,而不是自己设置每个参数,然后如果您需要除默认值以外的其他参数,则更新特定参数.

Instead of going about setting each parameter yourself, you can use DetectorParameters.GetDefault();, and then update specific parameters if you need something other than the default value.

所以只需替换:

DetectorParameters Parameters = new DetectorParameters();

与:

DetectorParameters Parameters = DetectorParameters.GetDefault();

这篇关于Aruco DetectMarkers 实现 Emgu C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-17 01:44