MCPcopy Create free account
hub / github.com/ceres-solver/ceres-solver / WriteToPLYFile

Method WriteToPLYFile

examples/bal_problem.cc:180–214  ·  view source on GitHub ↗

Write the problem to a PLY file for inspection in Meshlab or CloudCompare.

Source from the content-addressed store, hash-verified

178
179// Write the problem to a PLY file for inspection in Meshlab or CloudCompare.
180void BALProblem::WriteToPLYFile(const std::string& filename) const {
181 std::ofstream of(filename.c_str());
182
183 of << "ply" << '\n'
184 << "format ascii 1.0" << '\n'
185 << "element vertex " << num_cameras_ + num_points_ << '\n'
186 << "property float x" << '\n'
187 << "property float y" << '\n'
188 << "property float z" << '\n'
189 << "property uchar red" << '\n'
190 << "property uchar green" << '\n'
191 << "property uchar blue" << '\n'
192 << "end_header" << std::endl;
193
194 // Export extrinsic data (i.e. camera centers) as green points.
195 double angle_axis[3];
196 double center[3];
197 for (int i = 0; i < num_cameras(); ++i) {
198 const double* camera = cameras() + camera_block_size() * i;
199 CameraToAngleAxisAndCenter(camera, angle_axis, center);
200 of << center[0] << ' ' << center[1] << ' ' << center[2] << " 0 255 0"
201 << '\n';
202 }
203
204 // Export the structure (i.e. 3D Points) as white points.
205 const double* points = parameters_ + camera_block_size() * num_cameras_;
206 for (int i = 0; i < num_points(); ++i) {
207 const double* point = points + i * point_block_size();
208 for (int j = 0; j < point_block_size(); ++j) {
209 of << point[j] << ' ';
210 }
211 of << "255 255 255\n";
212 }
213 of.close();
214}
215
216void BALProblem::CameraToAngleAxisAndCenter(const double* camera,
217 double* angle_axis,

Callers 1

SolveProblemFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected