@@ -785,11 +785,11 @@ static void _getSingleMarkerObjectPoints(float markerLength, OutputArray _objPoi
785
785
786
786
_objPoints.create (4 , 1 , CV_32FC3);
787
787
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 );
793
793
}
794
794
795
795
/* *
@@ -1594,6 +1594,7 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
1594
1594
CV_Assert (objPoints.type () == CV_32FC3 || objPoints.type () == CV_32FC1);
1595
1595
1596
1596
std::vector< std::vector< Point3f > > obj_points_vector;
1597
+ Point3f rightBottomBorder = Point3f (0 .f , 0 .f , 0 .f );
1597
1598
for (unsigned int i = 0 ; i < objPoints.total (); i++) {
1598
1599
std::vector<Point3f> corners;
1599
1600
Mat corners_mat = objPoints.getMat (i);
@@ -1603,7 +1604,11 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
1603
1604
CV_Assert (corners_mat.total () == 4 );
1604
1605
1605
1606
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 );
1607
1612
}
1608
1613
obj_points_vector.push_back (corners);
1609
1614
}
@@ -1612,6 +1617,7 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
1612
1617
ids.copyTo (res->ids );
1613
1618
res->objPoints = obj_points_vector;
1614
1619
res->dictionary = cv::makePtr<Dictionary>(dictionary);
1620
+ res->rightBottomBorder = rightBottomBorder;
1615
1621
return res;
1616
1622
}
1617
1623
@@ -1647,20 +1653,19 @@ Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength,
1647
1653
}
1648
1654
1649
1655
// calculate Board objPoints
1650
- float maxY = (float )markersY * markerLength + (markersY - 1 ) * markerSeparation;
1651
1656
for (int y = 0 ; y < markersY; y++) {
1652
1657
for (int x = 0 ; x < markersX; x++) {
1653
- vector< Point3f > corners;
1654
- corners.resize (4 );
1658
+ vector<Point3f> corners (4 );
1655
1659
corners[0 ] = Point3f (x * (markerLength + markerSeparation),
1656
- maxY - y * (markerLength + markerSeparation), 0 );
1660
+ y * (markerLength + markerSeparation), 0 );
1657
1661
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 );
1660
1664
res->objPoints .push_back (corners);
1661
1665
}
1662
1666
}
1663
-
1667
+ res->rightBottomBorder = Point3f (markersX * markerLength + markerSeparation * (markersX - 1 ),
1668
+ markersY * markerLength + markerSeparation * (markersY - 1 ), 0 .f );
1664
1669
return res;
1665
1670
}
1666
1671
@@ -1712,15 +1717,6 @@ void drawDetectedMarkers(InputOutputArray _image, InputArrayOfArrays _corners,
1712
1717
}
1713
1718
1714
1719
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
-
1724
1720
/* *
1725
1721
*/
1726
1722
void 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
1785
1781
// move top left to 0, 0
1786
1782
pf -= Point2f (minX, minY);
1787
1783
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 );
1789
1785
outCorners[j] = pf;
1790
1786
}
1791
1787
0 commit comments