1 | initial version |
Debugging my app I have noticed that minRepDistance inside detectCharucoDiamond
is growing in squared proportion to the image width, and then its value is squared again for the thresholding using closestCandidateDistance inside of refineDetectedMarkers
.
So to supress this escalation 'to the fourth' of the image size, I have implemented the following patch in charuco.cpp (in the aruco module folder)
--- charuco.cpp 2017-08-09 14:01:38.583984613 +0200
+++ charuco.1.cpp 2017-08-09 14:01:08.972215628 +0200 @@ -738,7
+738,7 @@
CV_Assert(_markerIds.total() > 0 && _markerIds.total() ==
_markerCorners.total());
- const float minRepDistanceRate = 0.12f;
+ const float minRepDistanceRate = 1.3024550356922115f;
// create Charuco board layout for diamond (3x3 layout)
Ptr<Dictionary> dict = getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME(0)); @@ -771,7 +771,7 @@
perimeterSq += edge.x*edge.x + edge.y*edge.y;
}
// maximum reprojection error relative to perimeter
- float minRepDistance = perimeterSq * minRepDistanceRate * minRepDistanceRate;
+ float minRepDistance = sqrt(perimeterSq) * minRepDistanceRate;
int currentId = _markerIds.getMat().at< int >(i);
I came out with that (unneccesarily long) float minRepDistanceRate by trying to maintain the same threashold for a resolution of 640x480 when making the minRepDistance not quadratic anymore. Now when using it for 1920x1080, it works great!