资源简介
基于VISUALSTUDIO2013OPENCV2.4.10下的双目摄像机标定立体匹配矫正最后实现三维重建功能
代码片段和文件信息
#include“opcv.h“
//初始化棋盘角点数据信息
int initCornerData(int nImages cv::Size imageSize cv::Size boardSize float squareWidth)
{
cornerDatas.nImages = nImages;
cornerDatas.imageSize = imageSize;
cornerDatas.boardSize = boardSize;
cornerDatas.nPoints = nImages*boardSize.width*boardSize.height;
cornerDatas.nPointsPerImage = boardSize.width*boardSize.height;
cornerDatas.objectPoints.resize(nImages vector(cornerDatas.nPointsPerImage cv::Point3f(0 0 0)));
cornerDatas.imagePointsl.resize(nImages vector(cornerDatas.nPointsPerImage cv::Point2f(0 0)));
cornerDatas.imagePointsr.resize(nImages vector(cornerDatas.nPointsPerImage cv::Point2f(0 0)));
//计算角点的世界坐标值
int i j k n;
for (i = 0; i < nImages; i++)
{
n = 0;
for (j = 0; j < boardSize.height; j++)
for (k = 0; k < boardSize.width; k++)
cornerDatas.objectPoints[i][n++] = cv::Point3f(j*squareWidth k*squareWidth 0);
}
return 1;
}
//检测棋盘角点
int detectCorners(cv::Mat& imgl cv::Mat& imgr int imageCount)
{
bool stereoMode = true;
if (!(!imgl.empty())*(!imgr.empty()))
{
stereoMode = false;
}
// 提取当前棋盘对应的角点坐标子矩阵
vector& cornersl = cornerDatas.imagePointsl[imageCount];
vector& cornersr = cornerDatas.imagePointsr[imageCount];
bool foundl = false;
bool foundr = true;
int flags = CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE;
// 寻找棋盘及其角点
if (stereoMode)
{
foundl = findChessboardCorners(imgl cornerDatas.boardSize cornersl flags);
foundr = findChessboardCorners(imgr cornerDatas.boardSize cornersr flags);
}
else
{
if (!imgl.empty())
foundl = findChessboardCorners(imgl cornerDatas.boardSize cornersl flags);
if (!imgr.empty())
foundr = findChessboardCorners(imgr cornerDatas.boardSize cornersr flags);
}
// 若左右视图都成功检测到所有角点
// 则将检测到的角点坐标精确化
if (foundl && foundr)
{
//转换为灰度图
cv::Mat grayl grayr;
cvtColor(imgl grayl CV_RGB2GRAY);
if (stereoMode)
cvtColor(imgr grayr CV_RGB2GRAY);
//计算角点的精确坐标
cv::Size regionSize(2 2);
cornerSubPix(grayl cornersl regionSize cv::Size(-1 -1) cv::TermCriteria(cv::TermCriteria::EPS | cv::TermCriteria::MAX_ITER 30 0.01));
if (stereoMode)
cornerSubPix(grayr cornersr regionSize cv::Size(-1 -1) cv::TermCriteria(cv::TermCriteria::EPS | cv::TermCriteria::MAX_ITER 30 0.01));
}
// 显示检测到的角点
if (stereoMode)
{
drawChessboardCorners(imgl cornerDatas.boardSize cornersl foundl);
drawChessboardCorners(imgr cornerDatas.boardSize cornersr foundr);
}
else
{
if (!imgl.empty())
drawChessboardCorners(imgl cornerDatas.boardSize cornersl foundl);
if (!imgr.empty())
drawChessboardCorners(imgr cornerDatas.boardSize cornersr foundr);
}
if (stereoMode && foundl && foundr)
return 1;
else
return 0;
}
//执行双目摄像机标定若每个摄像机尚未标定,则首先进行单目标定,再进行双目标定
int calibrateStereoCamera(bool cameraUncalibrated)
{
if (cameraUn
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-01-29 18:19 binocularvision2\
目录 0 2016-01-29 18:16 binocularvision2\binocularvision2\
文件 16121856 2016-01-29 18:19 binocularvision2\binocularvision2.sdf
文件 994 2016-01-15 17:07 binocularvision2\binocularvision2.sln
文件 35328 2016-01-29 18:19 binocularvision2\binocularvision2.v12.suo
文件 5202 2016-01-16 16:01 binocularvision2\binocularvision2\binocularvision2.vcxproj
文件 1342 2016-01-16 15:50 binocularvision2\binocularvision2\binocularvision2.vcxproj.filters
目录 0 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\
文件 2280 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.log
目录 0 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\
文件 166 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\binocularvision2.lastbuildstate
文件 1570 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\cl.command.1.tlog
文件 38676 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\CL.read.1.tlog
文件 1674 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\CL.write.1.tlog
文件 2188 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\li
文件 5108 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\li
文件 572 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\binocularvision2.tlog\li
文件 882972 2016-01-20 11:20 binocularvision2\binocularvision2\Debug\initCornerData.obj
文件 242970 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\main.obj
文件 871424 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\vc120.idb
文件 1650688 2016-01-29 11:29 binocularvision2\binocularvision2\Debug\vc120.pdb
文件 23815 2016-01-29 17:58 binocularvision2\binocularvision2\initCornerData.cpp
文件 485 2016-01-16 17:27 binocularvision2\binocularvision2\initialboard.h
文件 6575 2016-01-29 18:16 binocularvision2\binocularvision2\main.cpp
文件 1865 2016-01-16 17:21 binocularvision2\binocularvision2\opcv.h
文件 2229 2016-01-29 17:57 binocularvision2\binocularvision2\touwen.h
目录 0 2016-01-20 11:20 binocularvision2\Debug\
文件 201728 2016-01-29 11:29 binocularvision2\Debug\binocularvision2.exe
文件 860860 2016-01-29 11:29 binocularvision2\Debug\binocularvision2.ilk
文件 2772992 2016-01-29 11:29 binocularvision2\Debug\binocularvision2.pdb
- 上一篇:声发射技术教材 应用于监测
- 下一篇:吴冬梅+张玉杰DSP技术与应用
相关资源
- 国外的基于matalb的双目视觉标定的程
- 基于opencv的双目测距代码+文章
- 基于双目视觉的轮式机器人动态避障
- 双目视觉 实验图片集
- 双目视觉工程答辩
- 双目标定以及双目测距程序.rar
- 双目立体标定与测量
- 武汉大学摄影测量 图像理解与计算机
- opencv双目视觉棋盘格标定,特征匹配
- Stereo Vision Algorithms and Applications:双目
- 双目视觉移动机器人SLAM系统
- 基于HALCON的双目立体视觉系统实现.
- 基于双目视觉的深度计算和三维重建
- 基于DM642的机器人双目视觉系统设计
- SLAM十四讲、双目视觉里程计、麻省理
- 基于SIFT特征点的双目视觉定位
- 双目视觉特征点匹配三维重建
- 基于EmguCV的标定和匹配
- 双目视觉3d成像
- 论文研究-基于双目视觉的三维人脸重
- halcon 双目视觉原理解密
- opencv写的双目视觉摄像机标定和三维
评论
共有 条评论