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

Method Perturb

examples/bal_problem.cc:293–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void BALProblem::Perturb(const double rotation_sigma,
294 const double translation_sigma,
295 const double point_sigma) {
296 CHECK_GE(point_sigma, 0.0);
297 CHECK_GE(rotation_sigma, 0.0);
298 CHECK_GE(translation_sigma, 0.0);
299 std::mt19937 prng;
300 std::normal_distribution<double> point_noise_distribution(0.0, point_sigma);
301 double* points = mutable_points();
302 if (point_sigma > 0) {
303 for (int i = 0; i < num_points_; ++i) {
304 PerturbPoint3(std::bind(point_noise_distribution, std::ref(prng)),
305 points + 3 * i);
306 }
307 }
308
309 std::normal_distribution<double> rotation_noise_distribution(0.0,
310 point_sigma);
311 std::normal_distribution<double> translation_noise_distribution(
312 0.0, translation_sigma);
313 for (int i = 0; i < num_cameras_; ++i) {
314 double* camera = mutable_cameras() + camera_block_size() * i;
315
316 double angle_axis[3];
317 double center[3];
318 // Perturb in the rotation of the camera in the angle-axis
319 // representation.
320 CameraToAngleAxisAndCenter(camera, angle_axis, center);
321 if (rotation_sigma > 0.0) {
322 PerturbPoint3(std::bind(rotation_noise_distribution, std::ref(prng)),
323 angle_axis);
324 }
325 AngleAxisAndCenterToCamera(angle_axis, center, camera);
326
327 if (translation_sigma > 0.0) {
328 PerturbPoint3(std::bind(translation_noise_distribution, std::ref(prng)),
329 camera + camera_block_size() - 6);
330 }
331 }
332}
333
334BALProblem::~BALProblem() {
335 delete[] point_index_;

Callers 1

SolveProblemFunction · 0.80

Calls 1

PerturbPoint3Function · 0.85

Tested by

no test coverage detected