39 #include <opencv2/core.hpp>
67 double etalon_square_size,
74 std::vector<PointDouble> &marker_corners_img,
85 double calib_K_data[3][3];
87 double calib_D_data[4];
96 bool LoadCalibXML(
const char *calibfile);
97 bool LoadCalibOpenCV(
const char *calibfile);
98 bool SaveCalibXML(
const char *calibfile);
99 bool SaveCalibOpenCV(
const char *calibfile);
137 if (!ser->
Serialize(calib_x_res,
"width"))
139 if (!ser->
Serialize(calib_y_res,
"height"))
141 if (!ser->
Serialize(calib_K,
"intrinsic_matrix"))
143 if (!ser->
Serialize(calib_D,
"distortion"))
155 return (2.0f * atan2(
double(x_res) / 2.0f, (
double)calib_K_data[0][0]));
161 return (2.0f * atan2(
double(y_res) / 2.0f, (
double)calib_K_data[1][1]));
164 void SetSimpleCalib(
int _x_res,
int _y_res,
double f_fac = 1.);
209 const float far_clip = 1000.0f,
210 const float near_clip = 0.1f);
228 void Distort(std::vector<PointDouble> &points);
236 const std::vector<PointDouble> &pi,
238 cv::Mat & tra)
const;
243 const std::vector<PointDouble> &pi,
245 cv::Mat & tra)
const;
249 const std::vector<PointDouble> &pi,
253 CalcExteriorOrientation(std::vector<cv::Point3d> &pw, std::vector<cv::Point2d> &pi,
Pose *pose);
255 bool CalcExteriorOrientation(
const cv::Mat &object_points, cv::Mat &image_points,
Pose *pose);
257 bool CalcExteriorOrientation(
const cv::Mat &object_points,
258 cv::Mat & image_points,
268 void ProjectPoints(std::vector<cv::Point3d> &pw,
Pose *pose, std::vector<cv::Point2d> &pi)
const;
273 const cv::Mat &rotation_vector,
274 const cv::Mat &translation_vector,
275 cv::Mat & image_points)
const;
279 void ProjectPoints(
const cv::Mat &object_points,
double gl[16], cv::Mat &image_points)
const;
282 void ProjectPoints(
const cv::Mat &object_points,
const Pose *pose, cv::Mat &image_points)
const;
296 void Find(
const std::vector<PointDouble> &pw,
const std::vector<PointDouble> &pi);
299 void ProjectPoints(
const std::vector<PointDouble> &from, std::vector<PointDouble> &to)
const;
This file defines library export definitions, version numbers and build information.
This file implements a pose.
This file implements generic utility functions and a serialization interface.
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
void ProjectPoint(const cv::Point3d &pw, const Pose *pose, cv::Point2d &pi) const
Project one point.
void Undistort(PointDouble &point)
Unapplys the lens distortion for one point on an image plane.
void Undistort(cv::Point2f &point)
Unapplys the lens distortion for one point on an image plane.
void ProjectPoints(const cv::Mat &object_points, double gl[16], cv::Mat &image_points) const
Project points.
void Distort(std::vector< PointDouble > &points)
Applys the lens distortion for points on image plane.
void Distort(PointDouble &point)
Applys the lens distortion for points on image plane.
double GetFovX()
Get x-direction FOV in radians.
void GetOpenglProjectionMatrix(double proj_matrix[16], const int width, const int height, const float far_clip=1000.0f, const float near_clip=0.1f)
Get OpenGL matrix Generates the OpenGL projection matrix based on OpenCV intrinsic camera matrix K.
void ProjectPoint(const cv::Point3f &pw, const Pose *pose, cv::Point2f &pi) const
Project one point.
void CalcExteriorOrientation(const std::vector< PointDouble > &pw, const std::vector< PointDouble > &pi, Pose *pose) const
Update existing pose (in rodriques&tra) based on new observations. Use (CV_32FC3 and CV_32FC2) for ma...
bool SetCalib(const char *calibfile, int _x_res, int _y_res, FILE_FORMAT format=FILE_FORMAT_DEFAULT)
Set the calibration file and the current resolution for which the calibration is adjusted to.
void SetRes(int _x_res, int _y_res)
If we have no calibration file we can still adjust the default calibration to current resolution
bool Serialize(Serialization *ser)
One of the two methods to make this class serializable by Serialization class.
void Undistort(std::vector< PointDouble > &points)
Unapplys the lens distortion for points on image plane.
void CalcExteriorOrientation(const std::vector< PointDouble > &pw, const std::vector< PointDouble > &pi, cv::Mat &rodriques, cv::Mat &tra) const
Calculate exterior orientation.
void ProjectPoints(std::vector< cv::Point3d > &pw, Pose *pose, std::vector< cv::Point2d > &pi) const
Project points.
void Distort(cv::Point2f &point)
Applys the lens distortion for one point on an image plane.
bool SaveCalib(const char *calibfile, FILE_FORMAT format=FILE_FORMAT_DEFAULT)
Save the current calibration information to a file.
double GetFovY()
Get y-direction FOV in radians.
void SetOpenglProjectionMatrix(double proj_matrix[16], const int width, const int height)
Invert operation for GetOpenglProjectionMatrix.
void ProjectPoints(const cv::Mat &object_points, const Pose *pose, cv::Mat &image_points) const
Project points
void ProjectPoints(const cv::Mat &object_points, const cv::Mat &rotation_vector, const cv::Mat &translation_vector, cv::Mat &image_points) const
Project points.
void Calibrate(ProjPoints &pp)
Calibrate using the collected ProjPoints.
std::string SerializeId()
One of the two methods to make this class serializable by Serialization class.
void CalcExteriorOrientation(const std::vector< cv::Point3d > &pw, const std::vector< PointDouble > &pi, cv::Mat &rodriques, cv::Mat &tra) const
Calculate exterior orientation.
Pose representation derived from the Rotation class
Class for serializing class content to/from file or std::iostream.
bool Serialize(int &data, const std::string &name)
Method for serializing 'int' data element. Used from your serializable class.
ALVAR_EXPORT Point< cv::Point2d > PointDouble
The default double point type.
@ FILE_FORMAT_DEFAULT
Default file format.
Simple Homography class for finding and projecting points between two planes.
void ProjectPoints(const std::vector< PointDouble > &from, std::vector< PointDouble > &to) const
Project points using the Homography.
void Find(const std::vector< PointDouble > &pw, const std::vector< PointDouble > &pi)
Find Homography for two point-sets.
Simple structure for collecting 2D and 3D points e.g. for camera calibration.
bool AddPointsUsingMarkers(std::vector< PointDouble > &marker_corners, std::vector< PointDouble > &marker_corners_img, cv::Mat &image)
Add elements to object_points , image_points and point_counts using detected markers.
void Reset()
Reset object_points , image_points and point_counts.
std::vector< cv::Point2d > image_points
Detected 2D object points If point_counts[0] == 10, then the first 10 points are detected in the firs...
std::vector< int > point_counts
Vector indicating how many points are detected for each frame.
std::vector< cv::Point3d > object_points
3D object points corresponding with the detected 2D image points.
bool AddPointsUsingChessboard(const cv::Mat &, double etalon_square_size, int etalon_rows, int etalon_columns, bool visualize)
Add elements to object_points , image_points and point_counts using Chessboard pattern.