@ -887,18 +887,13 @@ void estimatePoseSingleMarkers(InputArrayOfArrays _corners, float markerLength,
/**
* @ brief Given a board configuration and a set of detected markers , returns the corresponding
* image points and object points to call solvePnP
*/
static void _getBoardObjectAndImagePoints ( const Ptr < Board > & _board , InputArray _detectedIds ,
InputArrayOfArrays _detectedCorners ,
OutputArray _imgPoints , OutputArray _objPoints ) {
void getBoardObjectAndImagePoints ( const Ptr < Board > & board , InputArrayOfArrays detectedCorners ,
InputArray detectedIds , OutputArray objPoints , OutputArray imgPoints ) {
CV_Assert ( _ board- > ids . size ( ) = = _ board- > objPoints . size ( ) ) ;
CV_Assert ( _ detectedIds. total ( ) = = _ detectedCorners. total ( ) ) ;
CV_Assert ( board - > ids . size ( ) = = board - > objPoints . size ( ) ) ;
CV_Assert ( detectedIds . total ( ) = = detectedCorners . total ( ) ) ;
size_t nDetectedMarkers = _ detectedIds. total ( ) ;
size_t nDetectedMarkers = detectedIds . total ( ) ;
vector < Point3f > objPnts ;
objPnts . reserve ( nDetectedMarkers ) ;
@ -908,20 +903,20 @@ static void _getBoardObjectAndImagePoints(const Ptr<Board> &_board, InputArray _
// look for detected markers that belong to the board and get their information
for ( unsigned int i = 0 ; i < nDetectedMarkers ; i + + ) {
int currentId = _ detectedIds. getMat ( ) . ptr < int > ( 0 ) [ i ] ;
for ( unsigned int j = 0 ; j < _ board- > ids . size ( ) ; j + + ) {
if ( currentId = = _ board- > ids [ j ] ) {
int currentId = detectedIds . getMat ( ) . ptr < int > ( 0 ) [ i ] ;
for ( unsigned int j = 0 ; j < board - > ids . size ( ) ; j + + ) {
if ( currentId = = board - > ids [ j ] ) {
for ( int p = 0 ; p < 4 ; p + + ) {
objPnts . push_back ( _ board- > objPoints [ j ] [ p ] ) ;
imgPnts . push_back ( _ detectedCorners. getMat ( i ) . ptr < Point2f > ( 0 ) [ p ] ) ;
objPnts . push_back ( board - > objPoints [ j ] [ p ] ) ;
imgPnts . push_back ( detectedCorners . getMat ( i ) . ptr < Point2f > ( 0 ) [ p ] ) ;
}
}
}
}
// create output
Mat ( objPnts ) . copyTo ( _ objPoints) ;
Mat ( imgPnts ) . copyTo ( _ imgPoints) ;
Mat ( objPnts ) . copyTo ( objPoints ) ;
Mat ( imgPnts ) . copyTo ( imgPoints ) ;
}
@ -1243,7 +1238,7 @@ int estimatePoseBoard(InputArrayOfArrays _corners, InputArray _ids, const Ptr<Bo
// get object and image points for the solvePnP function
Mat objPoints , imgPoints ;
_ getBoardObjectAndImagePoints( board , _ids , _corners , imgPoints , obj Points ) ;
getBoardObjectAndImagePoints ( board , _corners , _ids , objPoints , img Points ) ;
CV_Assert ( imgPoints . total ( ) = = objPoints . total ( ) ) ;
@ -1544,8 +1539,8 @@ double calibrateCameraAruco(InputArrayOfArrays _corners, InputArray _ids, InputA
}
markerCounter + = nMarkersInThisFrame ;
Mat currentImgPoints , currentObjPoints ;
_ getBoardObjectAndImagePoints( board , thisFrameIds , thisFrameCorners , currentImg Points ,
currentObj Points ) ;
getBoardObjectAndImagePoints ( board , thisFrameCorners , thisFrameIds , currentObj Points ,
currentImg Points) ;
if ( currentImgPoints . total ( ) > 0 & & currentObjPoints . total ( ) > 0 ) {
processedImagePoints . push_back ( currentImgPoints ) ;
processedObjectPoints . push_back ( currentObjPoints ) ;