@@ -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/* *
@@ -1594,6 +1594,7 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
15941594 CV_Assert (objPoints.type () == CV_32FC3 || objPoints.type () == CV_32FC1);
15951595
15961596 std::vector< std::vector< Point3f > > obj_points_vector;
1597+ Point3f rightBottomBorder = Point3f (0 .f , 0 .f , 0 .f );
15971598 for (unsigned int i = 0 ; i < objPoints.total (); i++) {
15981599 std::vector<Point3f> corners;
15991600 Mat corners_mat = objPoints.getMat (i);
@@ -1603,7 +1604,11 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
16031604 CV_Assert (corners_mat.total () == 4 );
16041605
16051606 for (int j = 0 ; j < 4 ; j++) {
1606- corners.push_back (corners_mat.at <Point3f>(j));
1607+ const Point3f& corner = corners_mat.at <Point3f>(j);
1608+ corners.push_back (corner);
1609+ rightBottomBorder.x = std::max (rightBottomBorder.x , corner.x );
1610+ rightBottomBorder.y = std::max (rightBottomBorder.y , corner.y );
1611+ rightBottomBorder.z = std::max (rightBottomBorder.z , corner.z );
16071612 }
16081613 obj_points_vector.push_back (corners);
16091614 }
@@ -1612,6 +1617,7 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
16121617 ids.copyTo (res->ids );
16131618 res->objPoints = obj_points_vector;
16141619 res->dictionary = cv::makePtr<Dictionary>(dictionary);
1620+ res->rightBottomBorder = rightBottomBorder;
16151621 return res;
16161622}
16171623
@@ -1647,20 +1653,19 @@ Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength,
16471653 }
16481654
16491655 // calculate Board objPoints
1650- float maxY = (float )markersY * markerLength + (markersY - 1 ) * markerSeparation;
16511656 for (int y = 0 ; y < markersY; y++) {
16521657 for (int x = 0 ; x < markersX; x++) {
1653- vector< Point3f > corners;
1654- corners.resize (4 );
1658+ vector<Point3f> corners (4 );
16551659 corners[0 ] = Point3f (x * (markerLength + markerSeparation),
1656- maxY - y * (markerLength + markerSeparation), 0 );
1660+ y * (markerLength + markerSeparation), 0 );
16571661 corners[1 ] = corners[0 ] + Point3f (markerLength, 0 , 0 );
1658- corners[2 ] = corners[0 ] + Point3f (markerLength, - markerLength, 0 );
1659- corners[3 ] = corners[0 ] + Point3f (0 , - markerLength, 0 );
1662+ corners[2 ] = corners[0 ] + Point3f (markerLength, markerLength, 0 );
1663+ corners[3 ] = corners[0 ] + Point3f (0 , markerLength, 0 );
16601664 res->objPoints .push_back (corners);
16611665 }
16621666 }
1663-
1667+ res->rightBottomBorder = Point3f (markersX * markerLength + markerSeparation * (markersX - 1 ),
1668+ markersY * markerLength + markerSeparation * (markersY - 1 ), 0 .f );
16641669 return res;
16651670}
16661671
@@ -1712,15 +1717,6 @@ void drawDetectedMarkers(InputOutputArray _image, InputArrayOfArrays _corners,
17121717}
17131718
17141719
1715-
1716- /* *
1717- */
1718- void drawAxis (InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs, InputArray _rvec,
1719- InputArray _tvec, float length)
1720- {
1721- drawFrameAxes (_image, _cameraMatrix, _distCoeffs, _rvec, _tvec, length, 3 );
1722- }
1723-
17241720/* *
17251721 */
17261722void drawMarker (const Ptr<Dictionary> &dictionary, int id, int sidePixels, OutputArray _img, int borderBits) {
@@ -1785,7 +1781,7 @@ void _drawPlanarBoardImpl(Board *_board, Size outSize, OutputArray _img, int mar
17851781 // move top left to 0, 0
17861782 pf -= Point2f (minX, minY);
17871783 pf.x = pf.x / sizeX * float (out.cols );
1788- pf.y = ( 1 . 0f - pf.y / sizeY) * float (out.rows );
1784+ pf.y = pf.y / sizeY * float (out.rows );
17891785 outCorners[j] = pf;
17901786 }
17911787
0 commit comments