|
|
|
@ -338,3 +338,72 @@ TEST(CV_ArucoRefine, accuracy) { |
|
|
|
|
CV_ArucoRefine test; |
|
|
|
|
test.safe_run(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(CV_ArucoBoardPose, CheckNegativeZ) |
|
|
|
|
{ |
|
|
|
|
double matrixData[9] = { -3.9062571886921410e+02, 0., 4.2350000000000000e+02, |
|
|
|
|
0., 3.9062571886921410e+02, 2.3950000000000000e+02, |
|
|
|
|
0., 0., 1 }; |
|
|
|
|
cv::Mat cameraMatrix = cv::Mat(3, 3, CV_64F, matrixData); |
|
|
|
|
|
|
|
|
|
cv::Ptr<cv::aruco::Board> boardPtr(new cv::aruco::Board); |
|
|
|
|
cv::aruco::Board& board = *boardPtr; |
|
|
|
|
board.ids.push_back(0); |
|
|
|
|
board.ids.push_back(1); |
|
|
|
|
|
|
|
|
|
vector<cv::Point3f> pts3d; |
|
|
|
|
pts3d.push_back(cv::Point3f(0.326198f, -0.030621f, 0.303620f)); |
|
|
|
|
pts3d.push_back(cv::Point3f(0.325340f, -0.100594f, 0.301862f)); |
|
|
|
|
pts3d.push_back(cv::Point3f(0.255859f, -0.099530f, 0.293416f)); |
|
|
|
|
pts3d.push_back(cv::Point3f(0.256717f, -0.029557f, 0.295174f)); |
|
|
|
|
board.objPoints.push_back(pts3d); |
|
|
|
|
pts3d.clear(); |
|
|
|
|
pts3d.push_back(cv::Point3f(-0.033144f, -0.034819f, 0.245216f)); |
|
|
|
|
pts3d.push_back(cv::Point3f(-0.035507f, -0.104705f, 0.241987f)); |
|
|
|
|
pts3d.push_back(cv::Point3f(-0.105289f, -0.102120f, 0.237120f)); |
|
|
|
|
pts3d.push_back(cv::Point3f(-0.102926f, -0.032235f, 0.240349f)); |
|
|
|
|
board.objPoints.push_back(pts3d); |
|
|
|
|
|
|
|
|
|
vector<vector<Point2f> > corners; |
|
|
|
|
vector<Point2f> pts2d; |
|
|
|
|
pts2d.push_back(cv::Point2f(37.7f, 203.3f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(38.5f, 120.5f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(105.5f, 115.8f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(104.2f, 202.7f)); |
|
|
|
|
corners.push_back(pts2d); |
|
|
|
|
pts2d.clear(); |
|
|
|
|
pts2d.push_back(cv::Point2f(476.0f, 184.2f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(479.6f, 73.8f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(590.9f, 77.0f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(587.5f, 188.1f)); |
|
|
|
|
corners.push_back(pts2d); |
|
|
|
|
|
|
|
|
|
Vec3d rvec, tvec; |
|
|
|
|
int nUsed = cv::aruco::estimatePoseBoard(corners, board.ids, boardPtr, cameraMatrix, Mat(), rvec, tvec); |
|
|
|
|
ASSERT_EQ(nUsed, 2); |
|
|
|
|
|
|
|
|
|
cv::Matx33d rotm; cv::Point3d out; |
|
|
|
|
cv::Rodrigues(rvec, rotm); |
|
|
|
|
out = cv::Point3d(tvec) + rotm*Point3d(board.objPoints[0][0]); |
|
|
|
|
ASSERT_GT(out.z, 0); |
|
|
|
|
|
|
|
|
|
corners.clear(); pts2d.clear(); |
|
|
|
|
pts2d.push_back(cv::Point2f(38.4f, 204.5f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(40.0f, 124.7f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(102.0f, 119.1f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(99.9f, 203.6f)); |
|
|
|
|
corners.push_back(pts2d); |
|
|
|
|
pts2d.clear(); |
|
|
|
|
pts2d.push_back(cv::Point2f(476.0f, 184.3f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(479.2f, 75.1f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(588.7f, 79.2f)); |
|
|
|
|
pts2d.push_back(cv::Point2f(586.3f, 188.5f)); |
|
|
|
|
corners.push_back(pts2d); |
|
|
|
|
|
|
|
|
|
nUsed = cv::aruco::estimatePoseBoard(corners, board.ids, boardPtr, cameraMatrix, Mat(), rvec, tvec); |
|
|
|
|
ASSERT_EQ(nUsed, 2); |
|
|
|
|
|
|
|
|
|
cv::Rodrigues(rvec, rotm); |
|
|
|
|
out = cv::Point3d(tvec) + rotm*Point3d(board.objPoints[0][0]); |
|
|
|
|
ASSERT_GT(out.z, 0); |
|
|
|
|
} |
|
|
|
|