1 Star 0 Fork 28

周娟生 / Camera Calibration

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
undistort.cpp 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
#include "undistort.h"
bool CUndistort::readParams()
{
ifstream in;
in.open(calibResultPath+"calibResult.txt", ios::in);
in>>K.at<float>(0, 0);
in>>K.at<float>(1, 1);
in>>K.at<float>(0, 2);
in>>K.at<float>(1, 2);
#ifdef CV
in >> discoeff.at<float>(0, 0);
in >> discoeff.at<float>(1, 0);
in >> discoeff.at<float>(2, 0);
in >> discoeff.at<float>(3, 0);
in >> discoeff.at<float>(4, 0);
#elif defined FISHEYE
in >> discoeff.at<float>(0, 0);
in >> discoeff.at<float>(1, 0);
in >> discoeff.at<float>(2, 0);
in >> discoeff.at<float>(3, 0);
#endif
in.close();
return true;
}
bool CUndistort::undistProcess()
{
//***************У****************//
R=Mat::eye(Size(3, 3),CV_32FC1);
Mat mapx, mapy;
Mat srcImg=imread(srcImgPath);
Mat dstImg;
#ifdef CV
cv::initUndistortRectifyMap(K, discoeff, R, K, srcImg.size(),CV_32FC1, mapx, mapy);
#elif defined FISHEYE
cv::fisheye::initUndistortRectifyMap(K, discoeff,R, K, srcImg.size(), CV_32FC1, mapx, mapy);
#endif
remap(srcImg, dstImg, mapx, mapy, CV_INTER_LINEAR);
cv::resize(dstImg, dstImg, cv::Size(), 0.25, 0.25, CV_INTER_LINEAR);
cv::namedWindow("show", 1);
imshow("show", dstImg);
waitKey(0);
return true;
}
void CUndistort::run()
{
bool readSuccess=readParams();
if (!readSuccess)
{
cout << "read Params Failed!" << endl;
getchar();
}
undistProcess();
}
C++
1
https://gitee.com/zhou-juansheng/camera-calibration.git
git@gitee.com:zhou-juansheng/camera-calibration.git
zhou-juansheng
camera-calibration
Camera Calibration
master

搜索帮助