日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OpenCV的projectPoints函数用法

發(fā)布時(shí)間:2025/3/21 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OpenCV的projectPoints函数用法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

函數(shù)cvProjectPoints2通過給定的內(nèi)參數(shù)和外參數(shù)計(jì)算三維點(diǎn)投影到二維圖像平面上的坐標(biāo)。?

#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;vector<cv::Point3f> Generate3DPoints();int main(int argc, char* argv[]) {// Read 3D pointsvector<cv::Point3f> objectPoints = Generate3DPoints();vector<cv::Point2f> imagePoints;cv::Mat intrisicMat(3, 3, cv::DataType<float>::type); // Intrisic matrixintrisicMat.at<float>(0, 0) = 1.6415318549788924e+003;intrisicMat.at<float>(1, 0) = 0;intrisicMat.at<float>(2, 0) = 0;intrisicMat.at<float>(0, 1) = 0;intrisicMat.at<float>(1, 1) = 1.7067753507885654e+003;intrisicMat.at<float>(2, 1) = 0;intrisicMat.at<float>(0, 2) = 5.3262822453148601e+002;intrisicMat.at<float>(1, 2) = 3.8095355839052968e+002;intrisicMat.at<float>(2, 2) = 1;cv::Mat rVec(3, 1, cv::DataType<float>::type); // Rotation vectorrVec.at<float>(0) = -3.9277902400761393e-002;rVec.at<float>(1) = 3.7803824407602084e-002;rVec.at<float>(2) = 2.6445674487856268e-002;cv::Mat tVec(3, 1, cv::DataType<float>::type); // Translation vectortVec.at<float>(0) = 2.1158489381208221e+000;tVec.at<float>(1) = -7.6847683212704716e+000;tVec.at<float>(2) = 2.6169795190294256e+001;cv::Mat distCoeffs(5, 1, cv::DataType<float>::type); // Distortion vectordistCoeffs.at<float>(0) = -7.9134632415085826e-001;distCoeffs.at<float>(1) = 1.5623584435644169e+000;distCoeffs.at<float>(2) = -3.3916502741726508e-002;distCoeffs.at<float>(3) = -1.3921577146136694e-002;distCoeffs.at<float>(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::vector<cv::Point2f> projectedPoints;cv::projectPoints(objectPoints, rVec, tVec, intrisicMat, distCoeffs, projectedPoints);/*for (unsigned int i = 0; i < projectedPoints.size(); ++i){cout << "Image point: " << imagePoints[i] << " Projected to " << projectedPoints[i] << endl;}*/cout << "Press any key to exit.";cin.ignore();cin.get();return 0; }vector<cv::Point3f> Generate3DPoints() {vector<cv::Point3f> points;float x, y, z;x = .5; y = .5; z = -.5;points.push_back(cv::Point3f(x, y, z));x = .5; y = .5; z = .5;points.push_back(cv::Point3f(x, y, z));x = -.5; y = .5; z = .5;points.push_back(cv::Point3f(x, y, z));x = -.5; y = .5; z = -.5;points.push_back(cv::Point3f(x, y, z));x = .5; y = -.5; z = -.5;points.push_back(cv::Point3f(x, y, z));x = -.5; y = -.5; z = -.5;points.push_back(cv::Point3f(x, y, z));x = -.5; y = -.5; z = .5;points.push_back(cv::Point3f(x, y, z));for(unsigned int i = 0; i < points.size(); ++i){ cout << points[i] << endl << endl;}return points; }

參考:http://www.itkeyword.com/doc/8898489402460001x144/opencvs-projectpoints-function

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的OpenCV的projectPoints函数用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。