opencv相机标定

主要是参照opencv2那本书,注视写的都很详细,方便以后查找!
CameraCalibrator.h头文件

#include <iostream>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
class CameraCalibrator 
{
private:
    // 输入点
    //位于世界坐标的点
    std::vector<std::vector<cv::Point3f>> objectPoints;
    //像素坐标的点
    std::vector<std::vector<cv::Point2f>> imagePoints;

    std::vector<cv::Mat> rvecs, tvecs;

    // 输出矩阵,内参数阵和畸变系数真
    cv::Mat cameraMatrix;
    cv::Mat distCoeffs;
    cv::Mat cameraRotation ;//保存外参数矩阵
    cv::Mat cameraTranslation ;//保存平移量
    // 标定的方式
    int flag;
    // 用于图像去畸变
    cv::Mat map1,map2; 
    bool mustInitUndistort;

public:
    CameraCalibrator() : flag(0), mustInitUndistort(true) {};

    // 打开棋盘图像并提取角点
    int addChessboardPoints(const std::vector<std::string>& filelist, cv::Size & boardSize);

    void addPoints(const std::vector<cv::Point2f>& imageCorners, const std::vector<cv::Point3f>& objectCorners);

    double calibrate(cv::Size &imageSize);

    void setCalibrationFlag(bool radial8CoeffEnabled=false, bool tangentialParamEnabled=false);

    cv::Mat CameraCalibrator::remap(const cv::Mat &image);

    //获取指定棋盘格的外方位矩阵
    void CalExtrinx(int i) ;  

    //获得相机的内参数矩阵
    cv::Mat getCameraExtrinsic(){
  return cameraRotation ;}
    void saveRotation(std::string str) ;

    //获取相机的内参数矩阵
    cv::Mat getCameraMatrix() { return cameraMatrix; }

    //保存相机的内参数矩阵
    void saveCameraMatrix(std::string str) ;

    //获得指定棋盘格的平移量
    cv::Mat getTranslations(){ return cameraTranslation ;} 

    //保存平移量
    void saveTranslations(std::string str) ;

    //获取相机的畸变系数
    cv::Mat getDistCoeffs()   { return distCoeffs; }

    void printMatrix(const cv::Mat matrix) ;

    //读取棋盘格列表
    void readImagelist(const 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值