diff options
Diffstat (limited to 'intern/libmv/libmv/simple_pipeline/camera_intrinsics_test.cc')
-rw-r--r-- | intern/libmv/libmv/simple_pipeline/camera_intrinsics_test.cc | 129 |
1 files changed, 74 insertions, 55 deletions
diff --git a/intern/libmv/libmv/simple_pipeline/camera_intrinsics_test.cc b/intern/libmv/libmv/simple_pipeline/camera_intrinsics_test.cc index 96d35a29ef8..cfcc2d16682 100644 --- a/intern/libmv/libmv/simple_pipeline/camera_intrinsics_test.cc +++ b/intern/libmv/libmv/simple_pipeline/camera_intrinsics_test.cc @@ -22,10 +22,10 @@ #include <iostream> -#include "testing/testing.h" #include "libmv/image/image.h" #include "libmv/image/image_drawing.h" #include "libmv/logging/logging.h" +#include "testing/testing.h" namespace libmv { @@ -59,26 +59,36 @@ TEST(PolynomialCameraIntrinsics, ApplyIntrinsics) { const int N = 5; double expected[N][N][2] = { - { {75.312500, -24.687500}, {338.982239, -62.035522}, - {640.000000, -72.929688}, {941.017761, -62.035522}, - {1204.687500, -24.687500}}, - - { {37.964478, 238.982239}, {323.664551, 223.664551}, - {640.000000, 219.193420}, {956.335449, 223.664551}, - {1242.035522, 238.982239}}, - - { {27.070312, 540.000000}, {319.193420, 540.000000}, - {640.000000, 540.000000}, {960.806580, 540.000000}, - {1252.929688, 540.000000}}, - - { {37.964478, 841.017761}, {323.664551, 856.335449}, - {640.000000, 860.806580}, {956.335449, 856.335449}, - {1242.035522, 841.017761}}, - - { {75.312500, 1104.687500}, {338.982239, 1142.035522}, - {640.000000, 1152.929688}, {941.017761, 1142.035522}, - {1204.687500, 1104.687500}} - }; + {{75.312500, -24.687500}, + {338.982239, -62.035522}, + {640.000000, -72.929688}, + {941.017761, -62.035522}, + {1204.687500, -24.687500}}, + + {{37.964478, 238.982239}, + {323.664551, 223.664551}, + {640.000000, 219.193420}, + {956.335449, 223.664551}, + {1242.035522, 238.982239}}, + + {{27.070312, 540.000000}, + {319.193420, 540.000000}, + {640.000000, 540.000000}, + {960.806580, 540.000000}, + {1252.929688, 540.000000}}, + + {{37.964478, 841.017761}, + {323.664551, 856.335449}, + {640.000000, 860.806580}, + {956.335449, 856.335449}, + {1242.035522, 841.017761}}, + + {{75.312500, 1104.687500}, + {338.982239, 1142.035522}, + {640.000000, 1152.929688}, + {941.017761, 1142.035522}, + {1204.687500, 1104.687500}}, + }; PolynomialCameraIntrinsics intrinsics; intrinsics.SetFocalLength(1300.0, 1300.0); @@ -89,12 +99,11 @@ TEST(PolynomialCameraIntrinsics, ApplyIntrinsics) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { - double normalized_x = j * step - 0.5, - normalized_y = i * step - 0.5; + double normalized_x = j * step - 0.5, normalized_y = i * step - 0.5; double distorted_x, distorted_y; - intrinsics.ApplyIntrinsics(normalized_x, normalized_y, - &distorted_x, &distorted_y); + intrinsics.ApplyIntrinsics( + normalized_x, normalized_y, &distorted_x, &distorted_y); EXPECT_NEAR(expected[i][j][0], distorted_x, 1e-6); EXPECT_NEAR(expected[i][j][1], distorted_y, 1e-6); @@ -106,43 +115,51 @@ TEST(PolynomialCameraIntrinsics, InvertIntrinsics) { const int N = 5; double expected[N][N][2] = { - { {-0.524482, -0.437069}, {-0.226237, -0.403994}, - { 0.031876, -0.398446}, { 0.293917, -0.408218}, - { 0.632438, -0.465028}}, - - { {-0.493496, -0.189173}, {-0.219052, -0.179936}, - { 0.030975, -0.178107}, { 0.283742, -0.181280}, - { 0.574557, -0.194335}}, - - { {-0.488013, 0.032534}, {-0.217537, 0.031077}, - { 0.030781, 0.030781}, { 0.281635, 0.031293}, - { 0.566344, 0.033314}}, - - { {-0.498696, 0.257660}, {-0.220424, 0.244041}, - { 0.031150, 0.241409}, { 0.285660, 0.245985}, - { 0.582670, 0.265629}}, - - { {-0.550617, 0.532263}, {-0.230399, 0.477255}, - { 0.032380, 0.469510}, { 0.299986, 0.483311}, - { 0.684740, 0.584043}} - }; + {{-0.524482, -0.437069}, + {-0.226237, -0.403994}, + {0.031876, -0.398446}, + {0.293917, -0.408218}, + {0.632438, -0.465028}}, + + {{-0.493496, -0.189173}, + {-0.219052, -0.179936}, + {0.030975, -0.178107}, + {0.283742, -0.181280}, + {0.574557, -0.194335}}, + + {{-0.488013, 0.032534}, + {-0.217537, 0.031077}, + {0.030781, 0.030781}, + {0.281635, 0.031293}, + {0.566344, 0.033314}}, + + {{-0.498696, 0.257660}, + {-0.220424, 0.244041}, + {0.031150, 0.241409}, + {0.285660, 0.245985}, + {0.582670, 0.265629}}, + + {{-0.550617, 0.532263}, + {-0.230399, 0.477255}, + {0.032380, 0.469510}, + {0.299986, 0.483311}, + {0.684740, 0.584043}}, + }; PolynomialCameraIntrinsics intrinsics; intrinsics.SetFocalLength(1300.0, 1300.0); intrinsics.SetPrincipalPoint(600.0, 500.0); intrinsics.SetRadialDistortion(-0.2, -0.1, -0.05); - double step_x = 1280.0 / (N - 1), - step_y = 1080.0 / (N - 1); + double step_x = 1280.0 / (N - 1), step_y = 1080.0 / (N - 1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { - double distorted_x = j * step_x, - distorted_y = i * step_y; + double distorted_x = j * step_x, distorted_y = i * step_y; double normalized_x, normalized_y; - intrinsics.InvertIntrinsics(distorted_x, distorted_y, - &normalized_x, &normalized_y); + intrinsics.InvertIntrinsics( + distorted_x, distorted_y, &normalized_x, &normalized_y); EXPECT_NEAR(expected[i][j][0], normalized_x, 1e-6); EXPECT_NEAR(expected[i][j][1], normalized_y, 1e-6); @@ -190,10 +207,11 @@ TEST(PolynomialCameraIntrinsics, IdentityDistortBuffer) { FloatImage distorted_image(h, w); intrinsics.SetImageSize(w, h); intrinsics.SetFocalLength(10.0, 10.0); - intrinsics.SetPrincipalPoint((double) w / 2.0, (double) h / 2.0); + intrinsics.SetPrincipalPoint((double)w / 2.0, (double)h / 2.0); intrinsics.SetRadialDistortion(0.0, 0.0, 0.0); intrinsics.DistortBuffer(image.Data(), - image.Width(), image.Height(), + image.Width(), + image.Height(), 0.0, image.Depth(), distorted_image.Data()); @@ -221,10 +239,11 @@ TEST(PolynomialCameraIntrinsics, IdentityUndistortBuffer) { FloatImage distorted_image(h, w); intrinsics.SetImageSize(w, h); intrinsics.SetFocalLength(10.0, 10.0); - intrinsics.SetPrincipalPoint((double) w / 2.0, (double) h / 2.0); + intrinsics.SetPrincipalPoint((double)w / 2.0, (double)h / 2.0); intrinsics.SetRadialDistortion(0.0, 0.0, 0.0); intrinsics.UndistortBuffer(image.Data(), - image.Width(), image.Height(), + image.Width(), + image.Height(), 0.0, image.Depth(), distorted_image.Data()); |