Blender V4.3
modal_solver_test.cc
Go to the documentation of this file.
1// Copyright (c) 2013 libmv authors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to
5// deal in the Software without restriction, including without limitation the
6// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7// sell copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19// IN THE SOFTWARE.
20
22
26#include "testing/testing.h"
27
28#include <stdio.h>
29
30namespace libmv {
31
32TEST(ModalSolver, SyntheticCubeSceneMotion) {
33 double kTolerance = 1e-8;
34
36 intrinsics.SetFocalLength(658.286, 658.286);
37 intrinsics.SetPrincipalPoint(480.0, 270.0);
38 intrinsics.SetRadialDistortion(0.0, 0.0, 0.0);
39
40 Marker markers[] = {
41 {1, 0, 212.172775, 354.713538, 1.0},
42 {2, 0, 773.468399, 358.735306, 1.0},
43 {1, 1, 62.415197, 287.905354, 1.0},
44 {2, 1, 619.103336, 324.402537, 1.0},
45 {1, 2, 206.847939, 237.567925, 1.0},
46 {2, 2, 737.496986, 247.881383, 1.0},
47 {1, 3, 351.743889, 316.415906, 1.0},
48 {2, 3, 908.779621, 290.703617, 1.0},
49 {1, 4, 232.941413, 54.265443, 1.0},
50 {2, 4, 719.444847, 63.062531, 1.0},
51 {1, 5, 96.391611, 119.283537, 1.0},
52 {2, 5, 611.413136, 160.890715, 1.0},
53 {1, 6, 363.444958, 150.838144, 1.0},
54 {2, 6, 876.374531, 114.916206, 1.0},
55 };
56 int num_markers = sizeof(markers) / sizeof(Marker);
57
59 for (int i = 0; i < num_markers; i++) {
60 double x = markers[i].x, y = markers[i].y;
61 intrinsics.InvertIntrinsics(x, y, &x, &y);
62 tracks.Insert(markers[i].image, markers[i].track, x, y);
63 }
64
71 &intrinsics,
72 NULL);
73
74 Mat3 expected_rotation;
75 // clang-format off
76 expected_rotation << 0.98215101743472, 0.17798354937546, 0.06083777694542,
77 -0.16875283983360, 0.97665300495333, -0.13293376908719,
78 -0.08307742172243, 0.12029448893171, 0.98925597189636;
79 // clang-format on
80
81 Mat3& first_camera_R = reconstruction.CameraForImage(1)->R;
82 Mat3& second_camera_R = reconstruction.CameraForImage(2)->R;
83
84 EXPECT_TRUE(Mat3::Identity().isApprox(first_camera_R, kTolerance));
85 EXPECT_TRUE(expected_rotation.isApprox(second_camera_R, kTolerance));
86}
87
88} // namespace libmv
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void SetFocalLength(double focal_x, double focal_y)
void InvertIntrinsics(double image_x, double image_y, double *normalized_x, double *normalized_y) const override
void SetRadialDistortion(double k1, double k2, double k3)
ProjectiveCamera * CameraForImage(int image)
Returns a pointer to the camera corresponding to image.
#define NULL
const vector< Marker > & markers
const ProjectiveReconstruction & reconstruction
Definition intersect.cc:198
@ BUNDLE_NO_TRANSLATION
Definition bundle.h:118
void ModalSolver(const Tracks &tracks, EuclideanReconstruction *reconstruction, ProgressUpdateCallback *update_callback)
@ BUNDLE_NO_INTRINSICS
Definition bundle.h:100
Eigen::Matrix< double, 3, 3 > Mat3
Definition numeric.h:72
TEST(PolynomialCameraIntrinsics2, ApplyOnFocalCenter)
void EuclideanBundleCommonIntrinsics(const Tracks &tracks, const int bundle_intrinsics, const int bundle_constraints, EuclideanReconstruction *reconstruction, CameraIntrinsics *intrinsics, BundleEvaluation *evaluation)
Definition bundle.cc:661
ListBase tracks
Definition tracking.cc:70