From 31ae2cc0e92d90bb821103181eba9b55571bcf6d Mon Sep 17 00:00:00 2001 From: pmoulon Date: Tue, 12 May 2015 10:13:03 +0200 Subject: [PATCH] Export camera position --- src/software/SfM/main_ComputeSfM_DataColor.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/software/SfM/main_ComputeSfM_DataColor.cpp b/src/software/SfM/main_ComputeSfM_DataColor.cpp index fdc44af81a..eb7abe5260 100644 --- a/src/software/SfM/main_ComputeSfM_DataColor.cpp +++ b/src/software/SfM/main_ComputeSfM_DataColor.cpp @@ -127,6 +127,17 @@ void ColorizeTracks( } } +/// Export camera poses positions as a Vec3 vector +void GetCameraPositions(const SfM_Data & sfm_data, std::vector & vec_camPosition) +{ + const Poses & poses = sfm_data.getPoses(); + for (Poses::const_iterator iterPose = poses.begin(); + iterPose != poses.end(); ++iterPose) + { + vec_camPosition.push_back(iterPose->second.center()); + } +} + // Convert from a SfM_Data format to another int main(int argc, char **argv) { @@ -162,11 +173,12 @@ int main(int argc, char **argv) } // Compute the scene structure color - std::vector vec_3dPoints, vec_tracksColor; + std::vector vec_3dPoints, vec_tracksColor, vec_camPosition; ColorizeTracks(sfm_data, vec_3dPoints, vec_tracksColor); + GetCameraPositions(sfm_data, vec_camPosition); // Export the SfM_Data scene in the expected format - if (plyHelper::exportToPly(vec_3dPoints,std::vector(), sOutputPLY_Out, &vec_tracksColor)) + if (plyHelper::exportToPly(vec_3dPoints, vec_camPosition, sOutputPLY_Out, &vec_tracksColor)) { return EXIT_SUCCESS; }