10 Pattern pattern_type_, cv::Point3f offset_)
28 for (
int i = 0; i < boardSize.height; i++)
29 for (
int j = 0; j < boardSize.width; j++)
31 cv::Point3f(
float(j * squareSize),
32 float(i * squareSize), 0) + offset);
35 for (
int i = 0; i < boardSize.height; i++)
36 for (
int j = 0; j < boardSize.width; j++)
38 cv::Point3f(
float(i * squareSize),
39 float((2 * j + i % 2) * squareSize), 0) + offset);
42 std::logic_error(
"Unknown pattern type.");
51 translation.setZero();
52 orientation.setIdentity();
61 found = cv::findCirclesGrid(inm,
grid_size, observation_points,
62 cv::CALIB_CB_ASYMMETRIC_GRID | cv::CALIB_CB_CLUSTERING);
65 found = cv::findChessboardCorners(inm,
grid_size, observation_points, cv::CALIB_CB_ADAPTIVE_THRESH);
68 found = cv::findCirclesGrid(inm,
grid_size, observation_points, cv::CALIB_CB_SYMMETRIC_GRID);
77 cv::cornerSubPix(inm, observation_points, cv::Size(5,5), cv::Size(-1,-1),
78 cv::TermCriteria(cv::TermCriteria::MAX_ITER + cv::TermCriteria::EPS, 100, 0.01));
81 cv::solvePnP(cv::Mat(
ideal_points), cv::Mat(observation_points),
K,
D,
83 cv::Rodrigues(
rvec,
R);
85 cv::drawChessboardCorners(inm,
grid_size, cv::Mat(observation_points), found);
97 translation = Eigen::Vector3f(tvec.at<
double>(0,0), tvec.at<
double>(0,1), tvec.at<
double>(0, 2));
100 Rmat << R.at<
double>(0,0), R.at<
double>(0,1), R.at<
double>(0,2),
101 R.at<
double>(1,0), R.at<
double>(1,1), R.at<
double>(1,2),
102 R.at<
double>(2,0), R.at<
double>(2,1), R.at<
double>(2,2);
104 orientation = Eigen::Quaternionf(Rmat);
void convertCVtoEigen(cv::Mat &tvec, cv::Mat &R, Eigen::Vector3f &translation, Eigen::Quaternionf &orientation)
object_pts_t ideal_points
void setPattern(cv::Size grid_size_, float square_size_, Pattern pattern_type_, cv::Point3f offset_=cv::Point3f())
void setCameraMatrices(cv::Matx33d K_, cv::Matx33d D_)
std::vector< cv::Point3f > object_pts_t
std::vector< cv::Point2f > observation_pts_t
static object_pts_t calcChessboardCorners(cv::Size boardSize, float squareSize, Pattern patternType=CHESSBOARD, cv::Point3f offset=cv::Point3f())
int detectPattern(cv::Mat &inm, Eigen::Vector3f &translation, Eigen::Quaternionf &orientation)