@@ -785,11 +785,11 @@ static void _getSingleMarkerObjectPoints(float markerLength, OutputArray _objPoi
785785
786786 _objPoints.create (4 , 1 , CV_32FC3);
787787 Mat objPoints = _objPoints.getMat ();
788- // set coordinate system in the middle of the marker, with Z pointing out
789- objPoints.ptr < Vec3f >(0 )[0 ] = Vec3f (-markerLength / 2 .f , markerLength / 2 .f , 0 );
790- objPoints.ptr < Vec3f >(0 )[1 ] = Vec3f (markerLength / 2 . f , markerLength / 2 .f , 0 );
791- objPoints.ptr < Vec3f >(0 )[2 ] = Vec3f (markerLength / 2 . f , - markerLength / 2 . f , 0 );
792- objPoints.ptr < Vec3f >(0 )[3 ] = Vec3f (-markerLength / 2 .f , - markerLength / 2 . f , 0 );
788+ // set coordinate system in the top-left corner of the marker, with Z pointing out
789+ objPoints.ptr < Vec3f >(0 )[0 ] = Vec3f (0 .f , 0 .f , 0 );
790+ objPoints.ptr < Vec3f >(0 )[1 ] = Vec3f (markerLength, 0 .f , 0 );
791+ objPoints.ptr < Vec3f >(0 )[2 ] = Vec3f (markerLength, markerLength, 0 );
792+ objPoints.ptr < Vec3f >(0 )[3 ] = Vec3f (0 .f , markerLength, 0 );
793793}
794794
795795/* *
@@ -1593,6 +1593,7 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
15931593 CV_Assert (objPoints.type () == CV_32FC3 || objPoints.type () == CV_32FC1);
15941594
15951595 std::vector< std::vector< Point3f > > obj_points_vector;
1596+ Point3f rightBottomBorder = Point3f (0 .f , 0 .f , 0 .f );
15961597 for (unsigned int i = 0 ; i < objPoints.total (); i++) {
15971598 std::vector<Point3f> corners;
15981599 Mat corners_mat = objPoints.getMat (i);
@@ -1602,7 +1603,11 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
16021603 CV_Assert (corners_mat.total () == 4 );
16031604
16041605 for (int j = 0 ; j < 4 ; j++) {
1605- corners.push_back (corners_mat.at <Point3f>(j));
1606+ const Point3f& corner = corners_mat.at <Point3f>(j);
1607+ corners.push_back (corner);
1608+ rightBottomBorder.x = std::max (rightBottomBorder.x , corner.x );
1609+ rightBottomBorder.y = std::max (rightBottomBorder.y , corner.y );
1610+ rightBottomBorder.z = std::max (rightBottomBorder.z , corner.z );
16061611 }
16071612 obj_points_vector.push_back (corners);
16081613 }
@@ -1611,6 +1616,7 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
16111616 ids.copyTo (res->ids );
16121617 res->objPoints = obj_points_vector;
16131618 res->dictionary = cv::makePtr<Dictionary>(dictionary);
1619+ res->rightBottomBorder = rightBottomBorder;
16141620 return res;
16151621}
16161622
@@ -1646,20 +1652,19 @@ Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength,
16461652 }
16471653
16481654 // calculate Board objPoints
1649- float maxY = (float )markersY * markerLength + (markersY - 1 ) * markerSeparation;
16501655 for (int y = 0 ; y < markersY; y++) {
16511656 for (int x = 0 ; x < markersX; x++) {
1652- vector< Point3f > corners;
1653- corners.resize (4 );
1657+ vector<Point3f> corners (4 );
16541658 corners[0 ] = Point3f (x * (markerLength + markerSeparation),
1655- maxY - y * (markerLength + markerSeparation), 0 );
1659+ y * (markerLength + markerSeparation), 0 );
16561660 corners[1 ] = corners[0 ] + Point3f (markerLength, 0 , 0 );
1657- corners[2 ] = corners[0 ] + Point3f (markerLength, - markerLength, 0 );
1658- corners[3 ] = corners[0 ] + Point3f (0 , - markerLength, 0 );
1661+ corners[2 ] = corners[0 ] + Point3f (markerLength, markerLength, 0 );
1662+ corners[3 ] = corners[0 ] + Point3f (0 , markerLength, 0 );
16591663 res->objPoints .push_back (corners);
16601664 }
16611665 }
1662-
1666+ res->rightBottomBorder = Point3f (markersX * markerLength + markerSeparation * (markersX - 1 ),
1667+ markersY * markerLength + markerSeparation * (markersY - 1 ), 0 .f );
16631668 return res;
16641669}
16651670
@@ -1711,15 +1716,6 @@ void drawDetectedMarkers(InputOutputArray _image, InputArrayOfArrays _corners,
17111716}
17121717
17131718
1714-
1715- /* *
1716- */
1717- void drawAxis (InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs, InputArray _rvec,
1718- InputArray _tvec, float length)
1719- {
1720- drawFrameAxes (_image, _cameraMatrix, _distCoeffs, _rvec, _tvec, length, 3 );
1721- }
1722-
17231719/* *
17241720 */
17251721void drawMarker (const Ptr<Dictionary> &dictionary, int id, int sidePixels, OutputArray _img, int borderBits) {
@@ -1784,7 +1780,7 @@ void _drawPlanarBoardImpl(Board *_board, Size outSize, OutputArray _img, int mar
17841780 // move top left to 0, 0
17851781 pf -= Point2f (minX, minY);
17861782 pf.x = pf.x / sizeX * float (out.cols );
1787- pf.y = ( 1 . 0f - pf.y / sizeY) * float (out.rows );
1783+ pf.y = pf.y / sizeY * float (out.rows );
17881784 outCorners[j] = pf;
17891785 }
17901786
0 commit comments