From 522bba3d370f8ba06fc0034c09a63ecdddebb5e5 Mon Sep 17 00:00:00 2001 From: AleksandrPanov Date: Thu, 22 Dec 2022 03:24:44 +0300 Subject: [PATCH] move drawDetectedDiamonds --- .../aruco/include/opencv2/aruco/charuco.hpp | 28 +----------- modules/aruco/src/charuco.cpp | 44 +------------------ 2 files changed, 2 insertions(+), 70 deletions(-) diff --git a/modules/aruco/include/opencv2/aruco/charuco.hpp b/modules/aruco/include/opencv2/aruco/charuco.hpp index c13e09491..2f5c14f0b 100644 --- a/modules/aruco/include/opencv2/aruco/charuco.hpp +++ b/modules/aruco/include/opencv2/aruco/charuco.hpp @@ -68,7 +68,7 @@ CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Inp * This function detects Diamond markers from the previous detected ArUco markers. The diamonds * are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters * are provided, the diamond search is based on reprojection. If not, diamond search is based on - * homography. Homography is faster than reprojection but can slightly reduce the detection rate. + * homography. Homography is faster than reprojection, but less accurate. */ CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays markerCorners, InputArray markerIds, float squareMarkerLengthRate, @@ -79,32 +79,6 @@ CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays mark (getPredefinedDictionary(PredefinedDictionaryType::DICT_4X4_50))); - -/** - * @brief Draw a set of detected ChArUco Diamond markers - * - * @param image input/output image. It must have 1 or 3 channels. The number of channels is not - * altered. - * @param diamondCorners positions of diamond corners in the same format returned by - * detectCharucoDiamond(). (e.g std::vector > ). For N detected markers, - * the dimensions of this array should be Nx4. The order of the corners should be clockwise. - * @param diamondIds vector of identifiers for diamonds in diamondCorners, in the same format - * returned by detectCharucoDiamond() (e.g. std::vector). - * Optional, if not provided, ids are not painted. - * @param borderColor color of marker borders. Rest of colors (text color and first corner color) - * are calculated based on this one. - * - * Given an array of detected diamonds, this functions draws them in the image. The marker borders - * are painted and the markers identifiers if provided. - * Useful for debugging purposes. - */ -CV_EXPORTS_W void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays diamondCorners, - InputArray diamondIds = noArray(), - Scalar borderColor = Scalar(0, 0, 255)); - - - - /** * @brief Draw a ChArUco Diamond marker * diff --git a/modules/aruco/src/charuco.cpp b/modules/aruco/src/charuco.cpp index 2cc3c8103..8b7f747f6 100644 --- a/modules/aruco/src/charuco.cpp +++ b/modules/aruco/src/charuco.cpp @@ -128,7 +128,7 @@ static void _getMaximumSubPixWindowSizes(InputArrayOfArrays markerCorners, Input for(unsigned int i = 0; i < nCharucoCorners; i++) { if(charucoCorners.getMat().at< Point2f >(i) == Point2f(-1, -1)) continue; - if(board->getNearestMarkerIdx()[i].size() == 0) continue; + if(board->getNearestMarkerIdx()[i].empty()) continue; double minDist = -1; int counter = 0; @@ -461,47 +461,5 @@ void drawCharucoDiamond(const Ptr &dictionary, Vec4i ids, int square board->generateImage(outSize, _img, marginSize, borderBits); } - -void drawDetectedDiamonds(InputOutputArray _image, InputArrayOfArrays _corners, InputArray _ids, Scalar borderColor) { - CV_Assert(_image.getMat().total() != 0 && - (_image.getMat().channels() == 1 || _image.getMat().channels() == 3)); - CV_Assert((_corners.total() == _ids.total()) || _ids.total() == 0); - - // calculate colors - Scalar textColor, cornerColor; - textColor = cornerColor = borderColor; - swap(textColor.val[0], textColor.val[1]); // text color just sawp G and R - swap(cornerColor.val[1], cornerColor.val[2]); // corner color just sawp G and B - - int nMarkers = (int)_corners.total(); - for(int i = 0; i < nMarkers; i++) { - Mat currentMarker = _corners.getMat(i); - CV_Assert(currentMarker.total() == 4 && currentMarker.type() == CV_32FC2); - - // draw marker sides - for(int j = 0; j < 4; j++) { - Point2f p0, p1; - p0 = currentMarker.at< Point2f >(j); - p1 = currentMarker.at< Point2f >((j + 1) % 4); - line(_image, p0, p1, borderColor, 1); - } - - // draw first corner mark - rectangle(_image, currentMarker.at< Point2f >(0) - Point2f(3, 3), - currentMarker.at< Point2f >(0) + Point2f(3, 3), cornerColor, 1, LINE_AA); - - // draw id composed by four numbers - if(_ids.total() != 0) { - Point2f cent(0, 0); - for(int p = 0; p < 4; p++) - cent += currentMarker.at< Point2f >(p); - cent = cent / 4.; - stringstream s; - s << "id=" << _ids.getMat().at< Vec4i >(i); - putText(_image, s.str(), cent, FONT_HERSHEY_SIMPLEX, 0.5, textColor, 2); - } - } -} - } }