54 for (
int i = 0; i < boardSize.height; i++)
55 for (
int j = 0; j < boardSize.width; j++)
56 corners.push_back(cv::Point3f(
float(j * squareSize),
float(i * squareSize), 0) + offset);
59 for (
int i = 0; i < boardSize.height; i++)
60 for (
int j = 0; j < boardSize.width; j++)
61 corners.push_back(cv::Point3f(
float(i * squareSize),
float((2 * j + i % 2) * squareSize), 0) + offset);
64 std::logic_error(
"Unknown pattern type.");
72 translation.setZero();
73 orientation.setIdentity();
82 found = cv::findCirclesGrid(image_in,
grid_size, observation_points,
83 cv::CALIB_CB_ASYMMETRIC_GRID | cv::CALIB_CB_CLUSTERING);
86 found = cv::findChessboardCorners(image_in,
grid_size, observation_points, cv::CALIB_CB_ADAPTIVE_THRESH);
89 found = cv::findCirclesGrid(image_in,
grid_size, observation_points, cv::CALIB_CB_SYMMETRIC_GRID);
98 cv::cornerSubPix(image_in, observation_points, cv::Size(5, 5), cv::Size(-1, -1),
99 cv::TermCriteria(cv::TermCriteria::MAX_ITER + cv::TermCriteria::EPS, 100, 0.01));
103 cv::Rodrigues(
rvec,
R);
105 cv::drawChessboardCorners(image_out,
grid_size, cv::Mat(observation_points), found);
117 translation = Eigen::Vector3f(tvec.at<
double>(0, 0), tvec.at<
double>(0, 1), tvec.at<
double>(0, 2));
119 Eigen::Matrix3f Rmat;
120 Rmat << R.at<
double>(0, 0), R.at<
double>(0, 1), R.at<
double>(0, 2),
121 R.at<
double>(1, 0), R.at<
double>(1, 1), R.at<
double>(1, 2),
122 R.at<
double>(2, 0), R.at<
double>(2, 1), R.at<
double>(2, 2);
124 orientation = Eigen::Quaternionf(Rmat);
void convertCVtoEigen(cv::Mat &tvec, cv::Mat &R, Eigen::Vector3f &translation, Eigen::Quaternionf &orientation)
void setCameraMatrices(cv::Matx33d K_, cv::Mat D_)
object_pts_t ideal_points
void setPattern(cv::Size grid_size_, float square_size_, Pattern pattern_type_, cv::Point3f offset_=cv::Point3f())
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 &image_in, Eigen::Vector3f &translation, Eigen::Quaternionf &orientation, cv::Mat &image_out)