0

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);

The error with the three lines commented is

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

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?

Help would really be appreciated!

Lauran
  • 73
  • 1
  • 1
  • 9

2 Answers2

0

I've looked into it again. Before calling the DetectMarkers function I declare all variables of Parameters like I do in the commented section of my code with a few variables. So now I declare every variable that Parameters has. I just give it the default value. Now it works.

Lauran
  • 73
  • 1
  • 1
  • 9
0

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

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

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.

So just replace:

DetectorParameters Parameters = new DetectorParameters();

with:

DetectorParameters Parameters = DetectorParameters.GetDefault();