资源简介

配置好相关库 代码直接可用 (多线程读取图像并显示)

资源截图

代码片段和文件信息

#include “calibration.h“
#include “utils.h“
#include “global.h“
#include 
#include 

void loadCameraParams(cv::Mat &cameraMatrix cv::Mat &distCoeffs)
{
cv::FileStorage fs(“..\\build\\camera.yaml“ cv::FileStorage::READ);

    fs [“camera_matrix“] >> cameraMatrix;
    fs [“distortion_coefficients“] >> distCoeffs;
}

cv::Mat calibrator(cv::Mat &view)
{

#if 1
vector imageList;
/*static */bool bLoadCameraParams = false;
static bool bInitMap = false;
static cv::Mat cameraMatrix distCoeffs map1 map2;
static cv::Mat newCameraMatrix;

cv::Mat rview;
cv::Size imageSizenewImageSize;
/*static */double cameraMatrix_1 = 0cameraMatrix_2 = 0cameraMatrix_3 = 0cameraMatrix_4 = 0;
/*static */double distCoeffs_1 = 0 distCoeffs_2 = 0 distCoeffs_3 = 0 distCoeffs_4 = 0 distCoeffs_5 = 0;

if(view.empty() || view.cols == 0 || view.rows == 0)
return cv::Mat();

imageSize.width = view.cols;
imageSize.height = view.rows;

//  newImageSize.width = 1.5*imageSize.width;
//  newImageSize.height = 1.5*imageSize.height;

newImageSize.width = imageSize.width;
newImageSize.height = imageSize.height;

if(bLoadCameraParams == false)
{
loadCameraParams(cameraMatrix distCoeffs);
bLoadCameraParams = true;
cameraMatrix_1 = cameraMatrix.at(00);
cameraMatrix_2 = cameraMatrix.at(02);
cameraMatrix_3 = cameraMatrix.at(11);
cameraMatrix_4 = cameraMatrix.at(12);

distCoeffs_1 = distCoeffs.at(00);
distCoeffs_2 = distCoeffs.at(10);
distCoeffs_3 = distCoeffs.at(20);
distCoeffs_4 = distCoeffs.at(30);
distCoeffs_5 = distCoeffs.at(40);
}

int middleValue = 100; // 100;

if(bLoadCameraParams == true)
{
cameraMatrix.at(0 0) = (camera_matrix_1_MIN - middleValue) * 1.0 / middleValue * cameraMatrix_1;
cameraMatrix.at(0 2) = (camera_matrix_2_MIN - middleValue) * 1.0 / middleValue * cameraMatrix_2;
cameraMatrix.at(1 1) = (camera_matrix_3_MIN - middleValue) * 1.0 / middleValue * cameraMatrix_3;
cameraMatrix.at(1 2) = (camera_matrix_4_MIN - middleValue) * 1.0 / middleValue * cameraMatrix_4;

distCoeffs.at(0 0) = (distortion_coeff_1_MIN - middleValue) * 1.0 / middleValue * distCoeffs_1;
distCoeffs.at(1 0) = (distortion_coeff_1_MIN - middleValue) * 1.0 / middleValue * distCoeffs_2;
distCoeffs.at(2 0) = (distortion_coeff_1_MIN - middleValue) * 1.0 / middleValue * distCoeffs_3;
distCoeffs.at(3 0) = (distortion_coeff_1_MIN - middleValue) * 1.0 / middleValue * distCoeffs_4;
distCoeffs.at(4 0) = (distortion_coeff_1_MIN - middleValue) * 1.0 / middleValue * distCoeffs_5;
}

// SHOW_TICK();

// 省了15ms左右的消耗
// if (bInitMap == false)
{
newCameraMatrix = cv::getOptimalNewCameraMatrix(cameraMatrix distCoeffs imageSize
1 newImageSize 0);
cv::initUndi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-31 12:54  calibrationRT\
     目录           0  2018-03-31 12:56  calibrationRT\Debug\
     目录           0  2018-03-21 19:24  calibrationRT\build\
     文件         791  2015-12-18 16:49  calibrationRT\build\HKVISION_DEBUG_32.props
     文件         791  2015-12-17 14:53  calibrationRT\build\HKVISION_DEBUG_64.props
     文件       19522  2016-02-24 18:29  calibrationRT\build\camera.yaml
     文件       19530  2016-01-27 23:35  calibrationRT\build\camera_nofisheye.yaml
     文件       19523  2016-01-03 15:32  calibrationRT\build\camerabk.yaml
     文件        1540  2016-01-05 16:46  calibrationRT\build\opencv3_32.props
     文件        1559  2015-12-17 14:53  calibrationRT\build\opencv3_64.props
     文件        1559  2015-12-17 14:53  calibrationRT\build\opencv3_debug_32.props
     文件        1559  2018-03-22 22:21  calibrationRT\build\opencv3_x86.props
     文件       18513  2015-12-17 14:53  calibrationRT\build\param.png
     目录           0  2018-03-25 12:29  calibrationRT\caliRt\
     目录           0  2018-03-22 21:48  calibrationRT\caliRt\Debug\
     文件        2221  2016-02-24 16:18  calibrationRT\caliRt\Debug\caliRt.Build.CppClean.log
     文件          15  2018-03-22 21:48  calibrationRT\caliRt\Debug\caliRt.log
     目录           0  2018-03-21 21:28  calibrationRT\caliRt\Debug\caliRt.tlog\
     文件      355336  2018-03-22 21:48  calibrationRT\caliRt\Debug\caliRt.tlog\CL.read.1.tlog
     文件       11566  2018-03-22 21:48  calibrationRT\caliRt\Debug\caliRt.tlog\CL.write.1.tlog
     文件         214  2018-03-21 21:29  calibrationRT\caliRt\Debug\caliRt.tlog\caliRt.lastbuildstate
     文件        9146  2018-03-22 21:48  calibrationRT\caliRt\Debug\caliRt.tlog\cl.command.1.tlog
     文件        4770  2018-03-21 21:30  calibrationRT\caliRt\Debug\caliRt.tlog\link.command.1.tlog
     文件       10252  2018-03-21 21:30  calibrationRT\caliRt\Debug\caliRt.tlog\link.read.1.tlog
     文件        2094  2018-03-21 21:30  calibrationRT\caliRt\Debug\caliRt.tlog\link.write.1.tlog
     文件           0  2018-03-21 21:29  calibrationRT\caliRt\Debug\caliRt.tlog\unsuccessfulbuild
     文件      276613  2018-03-21 21:30  calibrationRT\caliRt\Debug\calibration.obj
     文件      260176  2018-03-21 21:30  calibrationRT\caliRt\Debug\global.obj
     文件      532674  2018-03-22 21:48  calibrationRT\caliRt\Debug\main.obj
     文件      746040  2018-03-21 21:30  calibrationRT\caliRt\Debug\readCamera.obj
     文件      201857  2018-03-21 21:30  calibrationRT\caliRt\Debug\utils.obj
............此处省略47个文件信息

评论

共有 条评论