NANA
warp.hpp
浏览该文件的文档.
1#pragma once
16#include <NANA\core.hpp>
17#include "geometrytypes.hpp"
18
19namespace NANA {
20namespace ComputerGeometry {
21
24
25
26
39template<typename _Tp>
40void warpAffinePoint(const Matrix& M,const PointXY_<_Tp> & src, PointXY_<_Tp>&dst ) {
41 NA_Assert((M.m_rows == 2) && (M.m_cols == 3));
42 NAFLOAT* pdata = M.m_data;
43 dst.x = pdata[0] * src.x + pdata[1] * src.y + pdata[2];
44 pdata += M.m_step;
45 dst.y = pdata[0] * src.x + pdata[1] * src.y + pdata[2];
46 return ;
47}
48
49
64template<typename _Tp>
65void warpPerspectivePoint2D(const Matrix& M, const PointXY_<_Tp>& src, PointXY_<_Tp>& dst) {
66 NA_Assert((M.m_rows == 3) && (M.m_cols == 3));
67 NAFLOAT* pdata = M.m_data;
68
69 dst.x = pdata[0] * src.x + pdata[1] * src.y + pdata[2];
70 pdata += M.m_step;
71 dst.y = pdata[0] * src.x + pdata[1] * src.y + pdata[2];
72 pdata += M.m_step;
73 NAFLOAT w = pdata[0] * src.x + pdata[1] * src.y + pdata[2];
74 dst.x /= w;
75 dst.y /= w;
76 return;
77}
78
79
80
81
82
84
85
86
87}
88}
89
90
91
简单矩阵类
Definition: matrix.h:31
int m_rows
行数
Definition: matrix.h:290
int m_cols
列数
Definition: matrix.h:292
int m_step
步长
Definition: matrix.h:294
实现必须的几何类型
#define NA_Assert(expr)
当表达式非法,抛出异常
Definition: error.h:56
void warpPerspectivePoint2D(const Matrix &M, const PointXY_< _Tp > &src, PointXY_< _Tp > &dst)
实现点集的透视变换矩阵 透视变换矩阵大小:
Definition: warp.hpp:65
void warpAffinePoint(const Matrix &M, const PointXY_< _Tp > &src, PointXY_< _Tp > &dst)
对当前点集进行放射变换
Definition: warp.hpp:40