Skip to content

Commit 522bba3

Browse files
author
AleksandrPanov
committed
move drawDetectedDiamonds
1 parent f4868db commit 522bba3

File tree

2 files changed

+2
-70
lines changed

2 files changed

+2
-70
lines changed

modules/aruco/include/opencv2/aruco/charuco.hpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Inp
6868
* This function detects Diamond markers from the previous detected ArUco markers. The diamonds
6969
* are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters
7070
* are provided, the diamond search is based on reprojection. If not, diamond search is based on
71-
* homography. Homography is faster than reprojection but can slightly reduce the detection rate.
71+
* homography. Homography is faster than reprojection, but less accurate.
7272
*/
7373
CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays markerCorners,
7474
InputArray markerIds, float squareMarkerLengthRate,
@@ -79,32 +79,6 @@ CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays mark
7979
(getPredefinedDictionary(PredefinedDictionaryType::DICT_4X4_50)));
8080

8181

82-
83-
/**
84-
* @brief Draw a set of detected ChArUco Diamond markers
85-
*
86-
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
87-
* altered.
88-
* @param diamondCorners positions of diamond corners in the same format returned by
89-
* detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
90-
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
91-
* @param diamondIds vector of identifiers for diamonds in diamondCorners, in the same format
92-
* returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>).
93-
* Optional, if not provided, ids are not painted.
94-
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
95-
* are calculated based on this one.
96-
*
97-
* Given an array of detected diamonds, this functions draws them in the image. The marker borders
98-
* are painted and the markers identifiers if provided.
99-
* Useful for debugging purposes.
100-
*/
101-
CV_EXPORTS_W void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays diamondCorners,
102-
InputArray diamondIds = noArray(),
103-
Scalar borderColor = Scalar(0, 0, 255));
104-
105-
106-
107-
10882
/**
10983
* @brief Draw a ChArUco Diamond marker
11084
*

modules/aruco/src/charuco.cpp

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static void _getMaximumSubPixWindowSizes(InputArrayOfArrays markerCorners, Input
128128

129129
for(unsigned int i = 0; i < nCharucoCorners; i++) {
130130
if(charucoCorners.getMat().at< Point2f >(i) == Point2f(-1, -1)) continue;
131-
if(board->getNearestMarkerIdx()[i].size() == 0) continue;
131+
if(board->getNearestMarkerIdx()[i].empty()) continue;
132132

133133
double minDist = -1;
134134
int counter = 0;
@@ -461,47 +461,5 @@ void drawCharucoDiamond(const Ptr<Dictionary> &dictionary, Vec4i ids, int square
461461
board->generateImage(outSize, _img, marginSize, borderBits);
462462
}
463463

464-
465-
void drawDetectedDiamonds(InputOutputArray _image, InputArrayOfArrays _corners, InputArray _ids, Scalar borderColor) {
466-
CV_Assert(_image.getMat().total() != 0 &&
467-
(_image.getMat().channels() == 1 || _image.getMat().channels() == 3));
468-
CV_Assert((_corners.total() == _ids.total()) || _ids.total() == 0);
469-
470-
// calculate colors
471-
Scalar textColor, cornerColor;
472-
textColor = cornerColor = borderColor;
473-
swap(textColor.val[0], textColor.val[1]); // text color just sawp G and R
474-
swap(cornerColor.val[1], cornerColor.val[2]); // corner color just sawp G and B
475-
476-
int nMarkers = (int)_corners.total();
477-
for(int i = 0; i < nMarkers; i++) {
478-
Mat currentMarker = _corners.getMat(i);
479-
CV_Assert(currentMarker.total() == 4 && currentMarker.type() == CV_32FC2);
480-
481-
// draw marker sides
482-
for(int j = 0; j < 4; j++) {
483-
Point2f p0, p1;
484-
p0 = currentMarker.at< Point2f >(j);
485-
p1 = currentMarker.at< Point2f >((j + 1) % 4);
486-
line(_image, p0, p1, borderColor, 1);
487-
}
488-
489-
// draw first corner mark
490-
rectangle(_image, currentMarker.at< Point2f >(0) - Point2f(3, 3),
491-
currentMarker.at< Point2f >(0) + Point2f(3, 3), cornerColor, 1, LINE_AA);
492-
493-
// draw id composed by four numbers
494-
if(_ids.total() != 0) {
495-
Point2f cent(0, 0);
496-
for(int p = 0; p < 4; p++)
497-
cent += currentMarker.at< Point2f >(p);
498-
cent = cent / 4.;
499-
stringstream s;
500-
s << "id=" << _ids.getMat().at< Vec4i >(i);
501-
putText(_image, s.str(), cent, FONT_HERSHEY_SIMPLEX, 0.5, textColor, 2);
502-
}
503-
}
504-
}
505-
506464
}
507465
}

0 commit comments

Comments
 (0)