资源简介
利用C++实现,可实现任意角度的透视变换。
代码片段和文件信息
#include“my_qtproject_api.h“
#include
#include
#include
using namespace cv;
using namespace std;
float rad(int x){
return x*CV_PI/180;
}
Mat calcpoint2f(const Mat&imgint wint hint anglexint angleyint anglezint fov){
float z=sqrt(w*w+h*h)/2/tan(rad(fov/2));
vector>rx={
{1000}
{0cos(rad(anglex))-sin(rad(anglex))0}
{0-sin(rad(anglex))cos(rad(anglex))0}
{0001}
};
vector>ry={
{cos(rad(angley))0sin(rad(angley))0}
{0100}
{-sin(rad(angley))0cos(rad(angley))0}
{0001}
};
vector>rz={
{cos(rad(anglez))sin(rad(anglez))00}
{-sin(rad(anglez))cos(rad(anglez))00}
{0010}
{0001}
};
Mat m_rx=cv::Mat(44CV_32FC1);
Mat m_ry=cv::Mat(44CV_32FC1);
Mat m_rz=cv::Mat(44CV_32FC1);
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
m_rx.at(ij)=rx[i][j];
m_ry.at(ij)=ry[i][j];
m_rz.at(ij)=rz[i][j];
}
}
Mat m_r=cv::Mat(44CV_32FC1);
// m_r=m_rx*m_ry*m_rz;
m_r=m_rx*m_ry;
//generate four points
vector pcenter={h/2w/200};
Mat m_pcenter=cv::Mat(14CV_32FC1);
for(int i=0;i<4;i++)
m_pcenter.at(0i)=pcenter[i];
vector>basepoint={
{0000}
{w000}
{0h00}
{wh00}
};
Mat m_base=cv::Mat(44CV_32FC1);
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)
m_
- 上一篇:达内科技 c++ 课件与笔记
- 下一篇:狄杰斯卡尔算法最短路径算法实现
评论
共有 条评论