61 double expected[
N][
N][2] = {
62 {{75.312500, -24.687500},
63 {338.982239, -62.035522},
64 {640.000000, -72.929688},
65 {941.017761, -62.035522},
66 {1204.687500, -24.687500}},
68 {{37.964478, 238.982239},
69 {323.664551, 223.664551},
70 {640.000000, 219.193420},
71 {956.335449, 223.664551},
72 {1242.035522, 238.982239}},
74 {{27.070312, 540.000000},
75 {319.193420, 540.000000},
76 {640.000000, 540.000000},
77 {960.806580, 540.000000},
78 {1252.929688, 540.000000}},
80 {{37.964478, 841.017761},
81 {323.664551, 856.335449},
82 {640.000000, 860.806580},
83 {956.335449, 856.335449},
84 {1242.035522, 841.017761}},
86 {{75.312500, 1104.687500},
87 {338.982239, 1142.035522},
88 {640.000000, 1152.929688},
89 {941.017761, 1142.035522},
90 {1204.687500, 1104.687500}},
98 double step = 1.0 / (
N - 1);
100 for (
int i = 0; i <
N; i++) {
101 for (
int j = 0; j <
N; j++) {
102 double normalized_x = j * step - 0.5, normalized_y = i * step - 0.5;
104 double distorted_x, distorted_y;
106 normalized_x, normalized_y, &distorted_x, &distorted_y);
108 EXPECT_NEAR(expected[i][j][0], distorted_x, 1
e-6);
109 EXPECT_NEAR(expected[i][j][1], distorted_y, 1
e-6);
117 double expected[
N][
N][2] = {
118 {{-0.524482, -0.437069},
119 {-0.226237, -0.403994},
120 {0.031876, -0.398446},
121 {0.293917, -0.408218},
122 {0.632438, -0.465028}},
124 {{-0.493496, -0.189173},
125 {-0.219052, -0.179936},
126 {0.030975, -0.178107},
127 {0.283742, -0.181280},
128 {0.574557, -0.194335}},
130 {{-0.488013, 0.032534},
131 {-0.217537, 0.031077},
132 {0.030781, 0.030781},
133 {0.281635, 0.031293},
134 {0.566344, 0.033314}},
136 {{-0.498696, 0.257660},
137 {-0.220424, 0.244041},
138 {0.031150, 0.241409},
139 {0.285660, 0.245985},
140 {0.582670, 0.265629}},
142 {{-0.550617, 0.532263},
143 {-0.230399, 0.477255},
144 {0.032380, 0.469510},
145 {0.299986, 0.483311},
146 {0.684740, 0.584043}},
154 double step_x = 1280.0 / (
N - 1), step_y = 1080.0 / (
N - 1);
156 for (
int i = 0; i <
N; i++) {
157 for (
int j = 0; j <
N; j++) {
158 double distorted_x = j * step_x, distorted_y = i * step_y;
160 double normalized_x, normalized_y;
162 distorted_x, distorted_y, &normalized_x, &normalized_y);
164 EXPECT_NEAR(expected[i][j][0], normalized_x, 1
e-6);
165 EXPECT_NEAR(expected[i][j][1], normalized_y, 1
e-6);
178 for (
double y = 0; y < 1000; y += 100) {
179 for (
double x = 0; x < 1000; x += 100) {
180 double normalized_x, normalized_y;
186 EXPECT_NEAR(x, xp, 1
e-8) <<
"y: " <<
y;
187 EXPECT_NEAR(y, yp, 1
e-8) <<
"x: " <<
x;
188 LG <<
"Error x: " << (x - xp);
189 LG <<
"Error y: " << (y - yp);
195 const int w = 101, h = 101;
199 DrawLine(0.0, h / 2.0,
w - 1, h / 2.0, 1.0, &image);
200 DrawLine(0.0, h / 4.0,
w - 1, h / 4.0, 1.0, &image);
201 DrawLine(0.0, h / 4.0 * 3.0,
w - 1.0, h / 4.0 * 3.0, 1.0, &image);
202 DrawLine(
w / 2.0, 0.0,
w / 2.0, h - 1.0, 1.0, &image);
203 DrawLine(
w / 4.0, 0.0,
w / 4.0, h - 1.0, 1.0, &image);
204 DrawLine(
w / 4.0 * 3.0, 0.0,
w / 4.0 * 3.0, h - 1.0, 1.0, &image);
217 distorted_image.
Data());
219 for (
int x = 0; x < image.Width(); ++
x) {
220 for (
int y = 0; y < image.Height(); ++
y) {
227 const int w = 101, h = 101;
231 DrawLine(0.0, h / 2.0,
w - 1, h / 2.0, 1.0, &image);
232 DrawLine(0.0, h / 4.0,
w - 1, h / 4.0, 1.0, &image);
233 DrawLine(0.0, h / 4.0 * 3.0,
w - 1.0, h / 4.0 * 3.0, 1.0, &image);
234 DrawLine(
w / 2.0, 0.0,
w / 2.0, h - 1.0, 1.0, &image);
235 DrawLine(
w / 4.0, 0.0,
w / 4.0, h - 1.0, 1.0, &image);
236 DrawLine(
w / 4.0 * 3.0, 0.0,
w / 4.0 * 3.0, h - 1.0, 1.0, &image);
249 distorted_image.
Data());
251 for (
int x = 0; x < image.Width(); ++
x) {
252 for (
int y = 0; y < image.Height(); ++
y) {