diff options
Diffstat (limited to 'intern/libmv/libmv/simple_pipeline/intersect.cc')
-rw-r--r-- | intern/libmv/libmv/simple_pipeline/intersect.cc | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/intern/libmv/libmv/simple_pipeline/intersect.cc b/intern/libmv/libmv/simple_pipeline/intersect.cc index ddb713684a4..86efd26f778 100644 --- a/intern/libmv/libmv/simple_pipeline/intersect.cc +++ b/intern/libmv/libmv/simple_pipeline/intersect.cc @@ -22,11 +22,11 @@ #include "libmv/base/vector.h" #include "libmv/logging/logging.h" +#include "libmv/multiview/nviewtriangulation.h" #include "libmv/multiview/projection.h" #include "libmv/multiview/triangulation.h" -#include "libmv/multiview/nviewtriangulation.h" -#include "libmv/numeric/numeric.h" #include "libmv/numeric/levenberg_marquardt.h" +#include "libmv/numeric/numeric.h" #include "libmv/simple_pipeline/reconstruction.h" #include "libmv/simple_pipeline/tracks.h" @@ -38,12 +38,12 @@ namespace { class EuclideanIntersectCostFunctor { public: - EuclideanIntersectCostFunctor(const Marker &marker, - const EuclideanCamera &camera) + EuclideanIntersectCostFunctor(const Marker& marker, + const EuclideanCamera& camera) : marker_(marker), camera_(camera) {} - template<typename T> - bool operator()(const T *X, T *residuals) const { + template <typename T> + bool operator()(const T* X, T* residuals) const { typedef Eigen::Matrix<T, 3, 3> Mat3; typedef Eigen::Matrix<T, 3, 1> Vec3; @@ -60,14 +60,14 @@ class EuclideanIntersectCostFunctor { return true; } - const Marker &marker_; - const EuclideanCamera &camera_; + const Marker& marker_; + const EuclideanCamera& camera_; }; } // namespace -bool EuclideanIntersect(const vector<Marker> &markers, - EuclideanReconstruction *reconstruction) { +bool EuclideanIntersect(const vector<Marker>& markers, + EuclideanReconstruction* reconstruction) { if (markers.size() < 2) { return false; } @@ -78,7 +78,7 @@ bool EuclideanIntersect(const vector<Marker> &markers, vector<Mat34> cameras; Mat34 P; for (int i = 0; i < markers.size(); ++i) { - EuclideanCamera *camera = reconstruction->CameraForImage(markers[i].image); + EuclideanCamera* camera = reconstruction->CameraForImage(markers[i].image); P_From_KRt(K, camera->R, camera->t, &P); cameras.push_back(P); } @@ -103,19 +103,19 @@ bool EuclideanIntersect(const vector<Marker> &markers, // Add residual blocks to the problem. int num_residuals = 0; for (int i = 0; i < markers.size(); ++i) { - const Marker &marker = markers[i]; + const Marker& marker = markers[i]; if (marker.weight != 0.0) { - const EuclideanCamera &camera = + const EuclideanCamera& camera = *reconstruction->CameraForImage(marker.image); problem.AddResidualBlock( - new ceres::AutoDiffCostFunction< - EuclideanIntersectCostFunctor, - 2, /* num_residuals */ - 3>(new EuclideanIntersectCostFunctor(marker, camera)), + new ceres::AutoDiffCostFunction<EuclideanIntersectCostFunctor, + 2, /* num_residuals */ + 3>( + new EuclideanIntersectCostFunctor(marker, camera)), NULL, &X(0)); - num_residuals++; + num_residuals++; } } @@ -126,9 +126,9 @@ bool EuclideanIntersect(const vector<Marker> &markers, if (!num_residuals) { LG << "Skipping running minimizer with zero residuals"; - // We still add 3D point for the track regardless it was - // optimized or not. If track is a constant zero it'll use - // algebraic intersection result as a 3D coordinate. + // We still add 3D point for the track regardless it was + // optimized or not. If track is a constant zero it'll use + // algebraic intersection result as a 3D coordinate. Vec3 point = X.head<3>(); reconstruction->InsertPoint(markers[0].track, point); @@ -152,12 +152,12 @@ bool EuclideanIntersect(const vector<Marker> &markers, // Try projecting the point; make sure it's in front of everyone. for (int i = 0; i < cameras.size(); ++i) { - const EuclideanCamera &camera = + const EuclideanCamera& camera = *reconstruction->CameraForImage(markers[i].image); Vec3 x = camera.R * X + camera.t; if (x(2) < 0) { - LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image - << ": " << x.transpose(); + LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image << ": " + << x.transpose(); return false; } } @@ -173,35 +173,35 @@ namespace { struct ProjectiveIntersectCostFunction { public: - typedef Vec FMatrixType; + typedef Vec FMatrixType; typedef Vec4 XMatrixType; ProjectiveIntersectCostFunction( - const vector<Marker> &markers, - const ProjectiveReconstruction &reconstruction) - : markers(markers), reconstruction(reconstruction) {} + const vector<Marker>& markers, + const ProjectiveReconstruction& reconstruction) + : markers(markers), reconstruction(reconstruction) {} - Vec operator()(const Vec4 &X) const { + Vec operator()(const Vec4& X) const { Vec residuals(2 * markers.size()); residuals.setZero(); for (int i = 0; i < markers.size(); ++i) { - const ProjectiveCamera &camera = + const ProjectiveCamera& camera = *reconstruction.CameraForImage(markers[i].image); Vec3 projected = camera.P * X; projected /= projected(2); - residuals[2*i + 0] = projected(0) - markers[i].x; - residuals[2*i + 1] = projected(1) - markers[i].y; + residuals[2 * i + 0] = projected(0) - markers[i].x; + residuals[2 * i + 1] = projected(1) - markers[i].y; } return residuals; } - const vector<Marker> &markers; - const ProjectiveReconstruction &reconstruction; + const vector<Marker>& markers; + const ProjectiveReconstruction& reconstruction; }; } // namespace -bool ProjectiveIntersect(const vector<Marker> &markers, - ProjectiveReconstruction *reconstruction) { +bool ProjectiveIntersect(const vector<Marker>& markers, + ProjectiveReconstruction* reconstruction) { if (markers.size() < 2) { return false; } @@ -209,7 +209,7 @@ bool ProjectiveIntersect(const vector<Marker> &markers, // Get the cameras to use for the intersection. vector<Mat34> cameras; for (int i = 0; i < markers.size(); ++i) { - ProjectiveCamera *camera = reconstruction->CameraForImage(markers[i].image); + ProjectiveCamera* camera = reconstruction->CameraForImage(markers[i].image); cameras.push_back(camera->P); } @@ -232,16 +232,16 @@ bool ProjectiveIntersect(const vector<Marker> &markers, Solver solver(triangulate_cost); Solver::Results results = solver.minimize(params, &X); - (void) results; // TODO(keir): Ensure results are good. + (void)results; // TODO(keir): Ensure results are good. // Try projecting the point; make sure it's in front of everyone. for (int i = 0; i < cameras.size(); ++i) { - const ProjectiveCamera &camera = + const ProjectiveCamera& camera = *reconstruction->CameraForImage(markers[i].image); Vec3 x = camera.P * X; if (x(2) < 0) { - LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image - << ": " << x.transpose(); + LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image << ": " + << x.transpose(); } } |