相机的内参标定
OpenCalibGui标定
OpenCalibGui基于OpenCV3和Qt5开发的跨平台可视化自动标定程序_铜锣烧阿南Anan的博客-CSDN博客
src/calibration.cpp · 铜锣烧阿南/OpenCalibGui - 码云 - 开源中国 (gitee.com)
void Calibration::calibCameraL(){
reprojectionErrorL = calibrateCamera(objectPointsSeq, imagePointsSeqL, imageSize, K_L, D_L, rvecsMat_L, tvecsMat_L, CV_CALIB_FIX_K3);
}
void Calibration::calibCameraR(){
reprojectionErrorR = calibrateCamera(objectPointsSeq, imagePointsSeqR, imageSize, K_R, D_R, rvecsMat_R, tvecsMat_R, CV_CALIB_FIX_K3);
}
void Calibration::calibCameraLR(){
reprojectionErrorLR = stereoCalibrate(objectPointsSeq, imagePointsSeqL, imagePointsSeqR,K_L,D_L,K_R,D_R,imageSize,R,T,E,F);// 立体标定
stereoRectify(K_L, D_L, K_R, D_R, imageSize, R, T, R_L, R_R, P_L, P_R, Q); // 获取立体矫正参数
}
opencv中标定函数calibrateCamera_ychl87的博客-CSDN博客_calibratecamera
opencv立体标定函数 stereoCalibrate()_JoannaJuanCV的博客-CSDN博客_opencv stereocalibrate
标定板aprilTag打印文件
E:\[openFromGit]\CamLaserCalibraTool-master\doc\april_6x6_80x80cm_A0.pdf
检测标定板位姿,去畸变和计算位姿,使用eigen计算;去图像畸变,得到归一化图像平面的坐标
E:\[openFromGit]\CamLaserCalibraTool-master\src\calcCamPose.cpp
std::vector<cv::Point2f> un_pts;
for (int i = 0, iend = (int)p2ds.size(); i < iend; ++i)
{
Eigen::Vector2d a(p2ds[i].x, p2ds[i].y);
Eigen::Vector3d b;
cam->liftProjective(a, b); // 去图像畸变, 得到归一化图像平面的坐标
un_pts.push_back(
cv::Point2f(b.x() / b.z(), b.y() / b.z() ));
}
if (EstimatePose(p3ds, un_pts, cam, Twc, img_raw))
{
cv::imshow("apriltag_detection & camPose_calculation", img_raw);
cv::waitKey(1);
return true;
}
bool CamPoseEst::EstimatePose(const std::vector<cv::Point3f> &p3ds,
const std::vector<cv::Point2f> &p2ds,
const CameraPtr &cam,
Eigen::Matrix4d &Twc, cv::Mat &img_raw)
{
glog和gflags可以在windows运行
库文件在:
E:\QtCode\cleanPackTest\main\lib_ceres\lib
测试文件在:
E:\QtCode\cleanPackTest\main\test_lib_ceres
自行取出加密
cvFileStorage 读写相机参数文件
cv::FileStorage fsSettings(config_file, cv::FileStorage::READ);
if(!fsSettings.isOpened())
{
std::cerr << "ERROR: Wrong path to settings" << std::endl;
return 0;
} else
{
std::cout << "READ CONFIG_FILE...\n";
}
std::string scan_topic_name;
std::string img_topic_name;
std::string bag_path;
std::string save_path;
fsSettings["scan_topic_name"] >> scan_topic_name;
fsSettings["img_topic_name"] >> img_topic_name;
fsSettings["savePath"] >> save_path;
fsSettings["bag_path"] >> bag_path;
配置文件
%YAML:1.0
#common parameters
savePath: "/home/hyj/all_ros_ws/LaserCamCal_ws/src/log/"
bag_path: "/home/hyj/all_ros_ws/LaserCamCal_ws/src/2019-07-12-11-36-17.bag"
scan_topic_name: "/scan"
img_topic_name: "/mynteye/left/image_raw"
# tag info
tag_type: 2 # 1: kalibr_tag, 2: apriltag
tag_size: 0.165 # tag size, unit meter
tag_spacing: 0.3 # tag spacing, only used in kalibr_tag. For details, please see kalibr tag description.
black_border: 1 # if you use kalibr_tag black_boarder = 2; if you use apriltag black_boarder = 1
#camera calibration
model_type: PINHOLE
camera_name: camera
image_width: 752
image_height: 480
distortion_parameters:
k1: 0.0
k2: 0.0
p1: 0.0
p2: 0.0
projection_parameters:
fx: 367.049931000148
fy: 366.94446918887405
cx: 368.7202381120387
cy: 241.13814795878562
相机类多个派生,三维坐标投影到相机平面等功能;
// Lift points from the image plane to the sphere
void liftSphere(const Eigen::Vector2d &p, Eigen::Vector3d &P) const;
//%output P
// Lift points from the image plane to the projective space
void liftProjective(const Eigen::Vector2d &p, Eigen::Vector3d &P) const;
//%output P
// Projects 3D points to the image plane (Pi function)
void spaceToPlane(const Eigen::Vector3d &P, Eigen::Vector2d &p) const;
//%output p
// Projects 3D points to the image plane (Pi function)
// and calculates jacobian
void spaceToPlane(const Eigen::Vector3d &P, Eigen::Vector2d &p,
Eigen::Matrix<double, 2, 3> &J) const;
//%output p
//%output J
void undistToPlane(const Eigen::Vector2d &p_u, Eigen::Vector2d &p) const;
//%output p