@@ -929,13 +929,8 @@ static void _distortPoints(vector<cv::Point2f>& in, const Mat& camMatrix, const
929929 * @param camMatrix, cameraMatrix input 3x3 floating-point camera matrix
930930 * @param distCoeff, distCoeffs vector of distortion coefficient
931931 */
932- static void _refineCandidateLines (std::vector<Point>& nContours, std::vector<Point2f>& nCorners, const Mat& camMatrix, const Mat& distCoeff ){
932+ static void _refineCandidateLines (std::vector<Point>& nContours, std::vector<Point2f>& nCorners){
933933 vector<Point2f> contour2f (nContours.begin (), nContours.end ());
934-
935- if (!camMatrix.empty () && !distCoeff.empty ()){
936- undistortPoints (contour2f, contour2f, camMatrix, distCoeff);
937- }
938-
939934 /* 5 groups :: to group the edges
940935 * 4 - classified by its corner
941936 * extra group - (temporary) if contours do not begin with a corner
@@ -953,10 +948,10 @@ static void _refineCandidateLines(std::vector<Point>& nContours, std::vector<Poi
953948 }
954949 cntPts[group].push_back (contour2f[i]);
955950 }
956-
951+ for (int i = 0 ; i < 4 ; i++)
952+ CV_Assert (cornerIndex[i] != -1 );
957953 // saves extra group into corresponding
958954 if ( !cntPts[4 ].empty () ){
959- CV_CheckLT (group, 4 , " FIXIT: avoiding infinite loop: implementation should be revised: https://github.com/opencv/opencv_contrib/issues/2738" );
960955 for ( unsigned int i=0 ; i < cntPts[4 ].size () ; i++ )
961956 cntPts[group].push_back (cntPts[4 ].at (i));
962957 cntPts[4 ].clear ();
@@ -989,10 +984,6 @@ static void _refineCandidateLines(std::vector<Point>& nContours, std::vector<Poi
989984 else
990985 nCorners[i] = _getCrossPoint (lines[ i ], lines[ (i+3 )%4 ]); // 30 01 12 23
991986 }
992-
993- if (!camMatrix.empty () && !distCoeff.empty ()){
994- _distortPoints (nCorners, camMatrix, distCoeff);
995- }
996987}
997988
998989
@@ -1002,13 +993,13 @@ static void _refineCandidateLines(std::vector<Point>& nContours, std::vector<Poi
1002993 */
1003994class MarkerContourParallel : public ParallelLoopBody {
1004995 public:
1005- MarkerContourParallel ( vector< vector< Point > >& _contours, vector< vector< Point2f > >& _candidates, const Mat& _camMatrix, const Mat& _distCoeff )
1006- : contours(_contours), candidates(_candidates), camMatrix(_camMatrix), distCoeff(_distCoeff) {}
996+ MarkerContourParallel ( vector< vector< Point > >& _contours, vector< vector< Point2f > >& _candidates)
997+ : contours(_contours), candidates(_candidates){}
1007998
1008999 void operator ()(const Range &range) const CV_OVERRIDE {
10091000
10101001 for (int i = range.start ; i < range.end ; i++) {
1011- _refineCandidateLines (contours[i], candidates[i], camMatrix, distCoeff );
1002+ _refineCandidateLines (contours[i], candidates[i]);
10121003 }
10131004 }
10141005
@@ -1019,8 +1010,6 @@ class MarkerContourParallel : public ParallelLoopBody {
10191010
10201011 vector< vector< Point > >& contours;
10211012 vector< vector< Point2f > >& candidates;
1022- const Mat& camMatrix;
1023- const Mat& distCoeff;
10241013};
10251014
10261015#ifdef APRIL_DEBUG
@@ -1162,7 +1151,7 @@ static void _apriltag(Mat im_orig, const Ptr<DetectorParameters> & _params, std:
11621151 */
11631152void detectMarkers (InputArray _image, const Ptr<Dictionary> &_dictionary, OutputArrayOfArrays _corners,
11641153 OutputArray _ids, const Ptr<DetectorParameters> &_params,
1165- OutputArrayOfArrays _rejectedImgPoints, InputArrayOfArrays camMatrix, InputArrayOfArrays distCoeff ) {
1154+ OutputArrayOfArrays _rejectedImgPoints) {
11661155
11671156 CV_Assert (!_image.empty ());
11681157
@@ -1221,7 +1210,7 @@ void detectMarkers(InputArray _image, const Ptr<Dictionary> &_dictionary, Output
12211210 if (! _ids.empty ()){
12221211
12231212 // do corner refinement using the contours for each detected markers
1224- parallel_for_ (Range (0 , _corners.cols ()), MarkerContourParallel (contours, candidates, camMatrix. getMat (), distCoeff. getMat () ));
1213+ parallel_for_ (Range (0 , _corners.cols ()), MarkerContourParallel (contours, candidates));
12251214
12261215 // copy the corners to the output array
12271216 _copyVector2Output (candidates, _corners);
0 commit comments