Skip to content

Commit c8936ad

Browse files
author
AleksandrPanov
committed
fix axes and add charuco dict
1 parent 4970a6d commit c8936ad

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays
502502
* @deprecated use cv::drawFrameAxes
503503
*/
504504
CV_EXPORTS_W void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
505-
InputArray rvec, InputArray tvec, float length);
505+
InputArray rvec, InputArray tvec, float length, int thickness=3);
506506

507507

508508

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays mark
285285
InputArray markerIds, float squareMarkerLengthRate,
286286
OutputArrayOfArrays diamondCorners, OutputArray diamondIds,
287287
InputArray cameraMatrix = noArray(),
288-
InputArray distCoeffs = noArray());
288+
InputArray distCoeffs = noArray(),
289+
Ptr<Dictionary> dict = getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME(0)));
289290

290291

291292

modules/aruco/src/aruco.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,9 +1787,18 @@ void drawDetectedMarkers(InputOutputArray _image, InputArrayOfArrays _corners,
17871787
/**
17881788
*/
17891789
void drawAxis(InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs, InputArray _rvec,
1790-
InputArray _tvec, float length)
1790+
InputArray _tvec, float length, int thickness)
17911791
{
1792-
drawFrameAxes(_image, _cameraMatrix, _distCoeffs, _rvec, _tvec, length, 3);
1792+
vector<Point3f> axis;
1793+
axis.push_back(Point3f(0.f, 0.f, 0.f));
1794+
axis.push_back(Point3f(length, 0.f, 0.f));
1795+
axis.push_back(Point3f(0.f, length, 0.f));
1796+
axis.push_back(Point3f(0.f, 0.f, -length));
1797+
vector<Point2f> axis_to_img;
1798+
projectPoints(axis, _rvec, _tvec, _cameraMatrix, _distCoeffs, axis_to_img);
1799+
line(_image, Point2i(axis_to_img[0]), Point2i(axis_to_img[1]), Scalar(255,0,0), thickness);
1800+
line(_image, Point2i(axis_to_img[0]), Point2i(axis_to_img[2]), Scalar(0,255,0), thickness);
1801+
line(_image, Point2i(axis_to_img[0]), Point2i(axis_to_img[3]), Scalar(0,0,255), thickness);
17931802
}
17941803

17951804
/**

modules/aruco/src/charuco.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,14 +743,13 @@ double calibrateCameraCharuco(InputArrayOfArrays _charucoCorners, InputArrayOfAr
743743
void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,
744744
InputArray _markerIds, float squareMarkerLengthRate,
745745
OutputArrayOfArrays _diamondCorners, OutputArray _diamondIds,
746-
InputArray _cameraMatrix, InputArray _distCoeffs) {
746+
InputArray _cameraMatrix, InputArray _distCoeffs, Ptr<Dictionary> dict) {
747747

748748
CV_Assert(_markerIds.total() > 0 && _markerIds.total() == _markerCorners.total());
749749

750750
const float minRepDistanceRate = 1.302455f;
751751

752752
// create Charuco board layout for diamond (3x3 layout)
753-
Ptr<Dictionary> dict = getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME(0));
754753
Ptr<CharucoBoard> _charucoDiamondLayout = CharucoBoard::create(3, 3, squareMarkerLengthRate, 1., dict);
755754

756755

0 commit comments

Comments
 (0)