发布时间:2026/7/10 12:49:49
OpenCV 位姿与投影变换 1. 旋转矩阵与旋转向量的相互转换1.1. 罗德里格斯公式符号^是向量到反对称的转换符。反之我们也可以计算从一个旋转矩阵到旋转向量的转换。对于转角θ有因此关于转轴n由于旋转轴上的向量在旋转后不发生改变说明转轴 n 是矩阵 R 特征值 1 对应的特征向量。求解此方程再归一化就得到了旋转轴。1.2. 转换函数void Rodrigues(const cv::Mat srccv::Mat dstcv::Mat jacobian0);参数说明src——为输入的旋转向量3x1或者1x3或者旋转矩阵3x3。该参数向量表示其旋转的角度用向量长度表示。dst——为输出的旋转矩阵3x3或者旋转向量3x1或者1x3。jacobian——为可选的输出雅可比矩阵3x9或者9x3是输入与输出数组的偏导数。2. 图像变换2.1. 去畸变2.1.1. 针孔相机调用方法std::vectorcv::Point2f inputDistortedPoints ... std::vectorcv::Point2f outputUndistortedPoints; cv::Mat cameraMatrix ... cv::Mat distCoeffs ... cv::undistortPoints(inputDistortedPoints, outputUndistortedPoints, cameraMatrix, distCoeffs, cv::noArray(), cameraMatrix);不要像下面这样调用输出的点不正确cv::undistortPoints(inputDistortedPoints, outputUndistortedPoints, cameraMatrix, distCoeffs2.1.2. 鱼眼相机cv::fisheye::undistortPoints(inputDistortedPoints, outputUndistortedPoints, cameraMatrix, distCoeffs, cv::noArray(), cameraMatrix);2.2. 投影2.2.1. 针孔相机函数void cv::projectPoints(InputArray objectPoints, InputArray rvec, InputArray tvec, InputArray cameraMatrix, InputArray distCoeffs, OutputArray imagePoints, OutputArray jacobian noArray(), double aspectRatio 0)ParametersobjectPointsArray of object points expressed wrt. the world coordinate frame. A 3xN/Nx3 1-channel or 1xN/Nx1 3-channel (or vectorPoint3f), where N is the number of points in the view.rvecThe rotation vector (Rodrigues) that, together with tvec, performs a change of basis from world to camera coordinate system, see calibrateCamera for details.tvecThe translation vector, see parameter description above.cameraMatrixCamera intrinsic matrixdistCoeffsInput vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6[,s1,s2,s3,s4[,τx,τy]]]]) of 4, 5, 8, 12 or 14 elements . If the vector is empty, the zero distortion coefficients are assumed.imagePointsOutput array of image points, 1xN/Nx1 2-channel, or vectorPoint2f .jacobianOptional output 2Nx(10numDistCoeffs) jacobian matrix of derivatives of image points with respect to components of the rotation vector, translation vector, focal lengths, coordinates of the principal point and the distortion coefficients. In the old interface different components of the jacobian are returned via different output parameters.aspectRatioOptional fixed aspect ratio parameter. If the parameter is not 0, the function assumes that the aspect ratio (fx/fy) is fixed and correspondingly adjusts the jacobian matrix.示例#include opencv2/core/core.hpp #include opencv2/imgproc/imgproc.hpp #include opencv2/calib3d/calib3d.hpp #include opencv2/highgui/highgui.hpp #include iostream #include string using namespace std; vectorcv::Point3f Generate3DPoints(); int main(int argc, char* argv[]) { // Read 3D points vectorcv::Point3f objectPoints Generate3DPoints(); vectorcv::Point2f imagePoints; cv::Mat intrisicMat(3, 3, cv::DataTypefloat::type); // Intrisic matrix intrisicMat.atfloat(0, 0) 1.6415318549788924e003; intrisicMat.atfloat(1, 0) 0; intrisicMat.atfloat(2, 0) 0; intrisicMat.atfloat(0, 1) 0; intrisicMat.atfloat(1, 1) 1.7067753507885654e003; intrisicMat.atfloat(2, 1) 0; intrisicMat.atfloat(0, 2) 5.3262822453148601e002; intrisicMat.atfloat(1, 2) 3.8095355839052968e002; intrisicMat.atfloat(2, 2) 1; cv::Mat rVec(3, 1, cv::DataTypefloat::type); // Rotation vector rVec.atfloat(0) -3.9277902400761393e-002; rVec.atfloat(1) 3.7803824407602084e-002; rVec.atfloat(2) 2.6445674487856268e-002; cv::Mat tVec(3, 1, cv::DataTypefloat::type); // Translation vector tVec.atfloat(0) 2.1158489381208221e000; tVec.atfloat(1) -7.6847683212704716e000; tVec.atfloat(2) 2.6169795190294256e001; cv::Mat distCoeffs(5, 1, cv::DataTypefloat::type); // Distortion vector distCoeffs.atfloat(0) -7.9134632415085826e-001; distCoeffs.atfloat(1) 1.5623584435644169e000; distCoeffs.atfloat(2) -3.3916502741726508e-002; distCoeffs.atfloat(3) -1.3921577146136694e-002; distCoeffs.atfloat(4) 1.1430734623697941e-002; cout Intrisic matrix: intrisicMat endl endl; cout Rotation vector: rVec endl endl; cout Translation vector: tVec endl endl; cout Distortion coef: distCoeffs endl endl; std::vectorcv::Point2f projectedPoints; cv::projectPoints(objectPoints, rVec, tVec, intrisicMat, distCoeffs, projectedPoints); cout Press any key to exit.; cin.ignore(); cin.get(); return 0; } vectorcv::Point3f Generate3DPoints() { vectorcv::Point3f points; points.push_back(cv::Point3f(.5, .5, -.5)); points.push_back(cv::Point3f(.5, .5, .5)); points.push_back(cv::Point3f(-.5, .5, .5)); points.push_back(cv::Point3f(-.5, .5, -.5)); points.push_back(cv::Point3f(.5, -.5, -.5)); points.push_back(cv::Point3f(-.5, -.5, -.5)); points.push_back(cv::Point3f(-.5, -.5, .5)); for(unsigned int i 0; i points.size(); i) { cout points[i] endl endl; } return points; }2.2.2. 鱼眼相机函数// 提供了两个重载函数经验上第一个容易崩溃建议使用第二个 void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, InputArray K, InputArray D, double alpha 0, OutputArray jacobian noArray()) void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d affine, InputArray K, InputArray D, double alpha 0, OutputArray jacobian noArray())ParametersobjectPointsArray of object points, 1xN/Nx1 3-channel (or vectorPoint3f), where N is the number of points in the view.imagePointsOutput array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or vectorPoint2f.affine仿射变换可以使用位姿矩阵进行初始化KCamera intrinsic matrix cameramatrixK.DInput vector of distortion coefficients (k1,k2,k3,k4).alphaThe skew coefficient.jacobianOptional output 2Nx15 jacobian matrix of derivatives of image points with respect to components of the focal lengths, coordinates of the principal point, distortion coefficients, rotation vector, translation vector, and the skew. In the old interface different components of the jacobian are returned via different output parameters.参考文献OpenCV的projectPoints函数用法_JIN_嫣熙的博客-CSDN博客_projectpointsOpencv学习12——cv::Rodrigues()函数_令狐少侠、的博客-CSDN博客_rodrigues函数OpenCV: Camera Calibration and 3D ReconstructionOpenCV: Fisheye camera modelundistortPoints opencv_cvml的博客-CSDN博客

相关新闻

2026/7/10 12:49:49

vue动态改变el-table表格列

方法1 <template><div class"mainBox"><div class"optshowBox"><el-popover placement"bottom" trigger-"click" width"200" popper-class"popperStyle"><template #reference><…

2026/7/10 12:44:49

计算机毕业设计之容春茶叶商城系统设计与实现

本系统为用户而设计制作容春茶叶商城系统&#xff0c;旨在实现容春茶叶商城系统智能化、现代化管理。本容春茶叶商城系统自动化系统的开发和研制的最终目的是将容春茶叶商城系统的运作模式从手工记录数据转变为网络信息查询管理&#xff0c;从而为现代管理人员的使用提供更多的…

2026/7/10 13:44:53

终极免费的Windows窗口强制调整工具:WindowResizer完全指南

终极免费的Windows窗口强制调整工具&#xff1a;WindowResizer完全指南 【免费下载链接】WindowResizer 一个可以强制调整应用程序窗口大小的工具 项目地址: https://gitcode.com/gh_mirrors/wi/WindowResizer 还在为那些顽固的Windows应用程序窗口而烦恼吗&#xff1f;…

2026/7/10 13:44:53

Obsidian表格插件终极指南:5个技巧实现笔记数据管理革命

Obsidian表格插件终极指南&#xff1a;5个技巧实现笔记数据管理革命 【免费下载链接】obsidian-excel 项目地址: https://gitcode.com/gh_mirrors/ob/obsidian-excel 在知识管理领域&#xff0c;Obsidian表格插件正在彻底改变我们处理结构化数据的方式。这款强大的工具…

2026/7/10 13:44:53

点云检测网络 PointPillar

1. 提出PointPillar的目的 在此之前对于不规则的稀疏的点云的做法普遍分为两派&#xff1a; 一是把点云数据量化到一个个Voxel里&#xff0c;常见的有VoxelNet和SECOND&#xff0c;但是这种做法比较普遍的问题是由于voxel大部分是空集所以会浪费算力&#xff08;SECOND利用稀…

2026/7/10 13:39:53

TTS-Backup:5分钟学会完整保护你的桌游模拟器珍贵数据

TTS-Backup&#xff1a;5分钟学会完整保护你的桌游模拟器珍贵数据 【免费下载链接】tts-backup Backup Tabletop Simulator saves and assets into comprehensive Zip files. 项目地址: https://gitcode.com/gh_mirrors/tt/tts-backup TTS-Backup是一款专为Tabletop Sim…

2026/7/10 5:21:51

国内大模型选型与企业级落地实战指南

我不能提供任何关于访问境外网络信息的技术方案或变通方法。根据中国法律法规和网络管理要求&#xff0c;所有互联网服务必须遵守国家关于网络安全、数据安全和内容安全的规定。ChatGPT及其后续版本&#xff08;如所谓“GPT-5”&#xff09;是由境外机构研发的大语言模型&#…

2026/7/10 2:34:05

三步实战方案:高效获取智慧教育平台电子课本PDF的完整流程

三步实战方案&#xff1a;高效获取智慧教育平台电子课本PDF的完整流程 【免费下载链接】tchMaterial-parser 国家中小学智慧教育平台 电子课本下载工具&#xff0c;帮助您从智慧教育平台中获取电子课本的 PDF 文件网址并进行下载&#xff0c;让您更方便地获取课本内容。 项目…

2026/7/10 0:02:49

5大实战技巧:用ExifToolGUI轻松解决照片元数据管理难题

5大实战技巧&#xff1a;用ExifToolGUI轻松解决照片元数据管理难题 【免费下载链接】ExifToolGui A GUI for ExifTool 项目地址: https://gitcode.com/gh_mirrors/ex/ExifToolGui 你是否曾为整理旅行照片时发现拍摄时间错乱而头疼&#xff1f;是否需要在数百张照片中批量…

2026/7/10 6:36:15

3个高效策略:快速掌握Axure中文界面配置

3个高效策略&#xff1a;快速掌握Axure中文界面配置 【免费下载链接】axure-cn Chinese language file for Axure RP. Axure RP 简体中文语言包。支持 Axure 11、10、9。不定期更新。 项目地址: https://gitcode.com/gh_mirrors/ax/axure-cn 还在为Axure RP的英文界面感…