|
39 | 39 | using namespace colmap; |
40 | 40 |
|
41 | 41 | BOOST_AUTO_TEST_CASE(TestBundleAdjustmentCostFunction) { |
42 | | - ceres::CostFunction* cost_function = |
| 42 | + std::unique_ptr<ceres::CostFunction> cost_function( |
43 | 43 | BundleAdjustmentCostFunction<SimplePinholeCameraModel>::Create( |
44 | | - Eigen::Vector2d::Zero()); |
| 44 | + Eigen::Vector2d::Zero())); |
45 | 45 | double qvec[4] = {1, 0, 0, 0}; |
46 | 46 | double tvec[3] = {0, 0, 0}; |
47 | 47 | double point3D[3] = {0, 0, 1}; |
@@ -69,10 +69,11 @@ BOOST_AUTO_TEST_CASE(TestBundleAdjustmentCostFunction) { |
69 | 69 | } |
70 | 70 |
|
71 | 71 | BOOST_AUTO_TEST_CASE(TestBundleAdjustmentConstantPoseCostFunction) { |
72 | | - ceres::CostFunction* cost_function = BundleAdjustmentConstantPoseCostFunction< |
73 | | - SimplePinholeCameraModel>::Create(ComposeIdentityQuaternion(), |
74 | | - Eigen::Vector3d::Zero(), |
75 | | - Eigen::Vector2d::Zero()); |
| 72 | + std::unique_ptr<ceres::CostFunction> cost_function( |
| 73 | + BundleAdjustmentConstantPoseCostFunction< |
| 74 | + SimplePinholeCameraModel>::Create(ComposeIdentityQuaternion(), |
| 75 | + Eigen::Vector3d::Zero(), |
| 76 | + Eigen::Vector2d::Zero())); |
76 | 77 | double point3D[3] = {0, 0, 1}; |
77 | 78 | double camera_params[3] = {1, 0, 0}; |
78 | 79 | double residuals[2]; |
@@ -134,9 +135,9 @@ BOOST_AUTO_TEST_CASE(TestBundleAdjustmentConstantPoint3DCostFunction) { |
134 | 135 | } |
135 | 136 |
|
136 | 137 | BOOST_AUTO_TEST_CASE(TestRigBundleAdjustmentCostFunction) { |
137 | | - ceres::CostFunction* cost_function = |
| 138 | + std::unique_ptr<ceres::CostFunction> cost_function( |
138 | 139 | RigBundleAdjustmentCostFunction<SimplePinholeCameraModel>::Create( |
139 | | - Eigen::Vector2d::Zero()); |
| 140 | + Eigen::Vector2d::Zero())); |
140 | 141 | double rig_qvec[4] = {1, 0, 0, 0}; |
141 | 142 | double rig_tvec[3] = {0, 0, -1}; |
142 | 143 | double rel_qvec[4] = {1, 0, 0, 0}; |
@@ -167,22 +168,23 @@ BOOST_AUTO_TEST_CASE(TestRigBundleAdjustmentCostFunction) { |
167 | 168 | } |
168 | 169 |
|
169 | 170 | BOOST_AUTO_TEST_CASE(TestRelativePoseCostFunction) { |
170 | | - ceres::CostFunction* cost_function = RelativePoseCostFunction::Create( |
171 | | - Eigen::Vector2d(0, 0), Eigen::Vector2d(0, 0)); |
| 171 | + std::unique_ptr<ceres::CostFunction> cost_function( |
| 172 | + RelativePoseCostFunction::Create(Eigen::Vector2d(0, 0), |
| 173 | + Eigen::Vector2d(0, 0))); |
172 | 174 | double qvec[4] = {1, 0, 0, 0}; |
173 | 175 | double tvec[3] = {0, 1, 0}; |
174 | 176 | double residuals[1]; |
175 | 177 | const double* parameters[2] = {qvec, tvec}; |
176 | 178 | BOOST_CHECK(cost_function->Evaluate(parameters, residuals, nullptr)); |
177 | 179 | BOOST_CHECK_EQUAL(residuals[0], 0); |
178 | 180 |
|
179 | | - cost_function = RelativePoseCostFunction::Create(Eigen::Vector2d(0, 0), |
180 | | - Eigen::Vector2d(1, 0)); |
| 181 | + cost_function.reset(RelativePoseCostFunction::Create(Eigen::Vector2d(0, 0), |
| 182 | + Eigen::Vector2d(1, 0))); |
181 | 183 | BOOST_CHECK(cost_function->Evaluate(parameters, residuals, nullptr)); |
182 | 184 | BOOST_CHECK_EQUAL(residuals[0], 0.5); |
183 | 185 |
|
184 | | - cost_function = RelativePoseCostFunction::Create(Eigen::Vector2d(0, 0), |
185 | | - Eigen::Vector2d(1, 1)); |
| 186 | + cost_function.reset(RelativePoseCostFunction::Create(Eigen::Vector2d(0, 0), |
| 187 | + Eigen::Vector2d(1, 1))); |
186 | 188 | BOOST_CHECK(cost_function->Evaluate(parameters, residuals, nullptr)); |
187 | 189 | BOOST_CHECK_EQUAL(residuals[0], 0.5); |
188 | 190 | } |
0 commit comments