-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdistortion.h
More file actions
37 lines (30 loc) · 960 Bytes
/
Copy pathdistortion.h
File metadata and controls
37 lines (30 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <d3d11.h>
#include <DirectXMath.h>
#include <vector>
#include <array>
struct UndistortVertex {
DirectX::XMFLOAT3 Pos; // Position in NDC [-1, 1]
DirectX::XMFLOAT2 Tex; // UV coords [0, 1] for the distorted source texture
};
struct CameraParameters {
double coeffs[20];
};
struct CameraIntrinsics {
double cx, fx, cy, fy;
};
DirectX::XMFLOAT2 get_distorted_point(double x, double y, const CameraParameters& params);
void create_undistortion_mesh(
int textureWidth, int textureHeight,
float zoomFactor,
const CameraIntrinsics& intrinsics,
const CameraParameters& params,
std::vector<UndistortVertex>& outVertices,
std::vector<DWORD>& outIndices,
DWORD meshDensityX = 256,
DWORD meshDensityY = 256
);
void create_default_mesh(
int imageWidth, int imageHeight,
int textureWidth, int textureHeight,
std::vector<UndistortVertex>& out_vertices, std::vector<DWORD>& out_indices);