Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 1 src/glomap/controllers/global_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "glomap/estimators/global_rotation_averaging.h"
#include "glomap/estimators/relpose_estimation.h"
#include "glomap/estimators/view_graph_calibration.h"
#include "glomap/types.h"

#include "colmap/scene/database.h"

Expand Down
11 changes: 6 additions & 5 deletions 11 src/glomap/estimators/global_rotation_averaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace {
double RelAngleError(double angle_12, double angle_1, double angle_2) {
double est = (angle_2 - angle_1) - angle_12;

while (est >= EIGEN_PI) est -= TWO_PI;
while (est >= EIGEN_PI) est -= 2 * EIGEN_PI;

while (est < -EIGEN_PI) est += TWO_PI;
while (est < -EIGEN_PI) est += 2 * EIGEN_PI;

// Inject random noise if the angle is too close to the boundary to break the
// possible balance at the local minima
Expand Down Expand Up @@ -525,11 +525,12 @@ bool RotationEstimator::SolveL1Regression(

// Check the residual. If it is small, stop
// TODO: strange bug for the L1 solver: update norm state constant
constexpr double kEps = 1e-12;
if (ComputeAverageStepSize(frames) <
options_.l1_step_convergence_threshold ||
std::abs(last_norm - curr_norm) < EPS) {
if (std::abs(last_norm - curr_norm) < EPS)
LOG(INFO) << "std::abs(last_norm - curr_norm) < EPS";
std::abs(last_norm - curr_norm) < kEps) {
if (std::abs(last_norm - curr_norm) < kEps)
LOG(INFO) << "std::abs(last_norm - curr_norm) < " << kEps;
iteration++;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion 2 src/glomap/math/rigid3d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Eigen::Vector3d RotationToAngleAxis(const Eigen::Matrix3d& rot) {

Eigen::Matrix3d AngleAxisToRotation(const Eigen::Vector3d& aa_vec) {
double aa_norm = aa_vec.norm();
if (aa_norm > EPS) {
if (aa_norm > 1e-12) {
return Eigen::AngleAxis<double>(aa_norm, aa_vec.normalized())
.toRotationMatrix();
} else {
Expand Down
22 changes: 11 additions & 11 deletions 22 src/glomap/math/two_view_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,25 @@ double SampsonError(const Eigen::Matrix3d& E,
double SampsonError(const Eigen::Matrix3d& E,
const Eigen::Vector3d& x1,
const Eigen::Vector3d& x2) {
Eigen::Vector3d Ex1 = E * x1 / (EPS + x1[2]);
Eigen::Vector3d Etx2 = E.transpose() * x2 / (EPS + x2[2]);

double C = Ex1.dot(x2);
double Cx = Ex1.head(2).squaredNorm();
double Cy = Etx2.head(2).squaredNorm();
double r2 = C * C / (Cx + Cy);

return r2;
const Eigen::Vector3d Ex1 = E * x1 / x1[2];
const Eigen::Vector3d Etx2 = E.transpose() * x2 / x2[2];
const double C = Ex1.dot(x2);
const double denom = Ex1.head(2).squaredNorm() + Etx2.head(2).squaredNorm();
if (denom == 0) {
return std::numeric_limits<double>::max();
}
return C * C / denom;
}

double HomographyError(const Eigen::Matrix3d& H,
const Eigen::Vector2d& x1,
const Eigen::Vector2d& x2) {
constexpr double kEps = 1e-12;
Eigen::Vector3d Hx1 = H * x1.homogeneous();
Eigen::Vector2d Hx1_norm = Hx1.head(2) / (EPS + Hx1[2]);
Eigen::Vector2d Hx1_norm = Hx1.head(2) / (kEps + Hx1[2]);
double r2 = (Hx1_norm - x2).squaredNorm();

return r2;
}

} // namespace glomap
} // namespace glomap
2 changes: 1 addition & 1 deletion 2 src/glomap/processors/image_pair_inliers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ double ImagePairInliers::ScoreErrorFundamental() {

bool status = false;
for (auto i = 0; i < 3; i++) {
if ((epipole(i) > EPS) || (epipole(i) < -EPS)) {
if (std::abs(epipole(i)) > 1e-12) {
status = true;
break;
}
Expand Down
19 changes: 8 additions & 11 deletions 19 src/glomap/processors/track_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ int TrackFilter::FilterTracksByReprojection(
for (auto& [image_id, feature_id] : track.observations) {
const Image& image = images.at(image_id);
Eigen::Vector3d pt_calc = image.CamFromWorld() * track.xyz;
if (pt_calc(2) < EPS) continue;
constexpr double kEps = 1e-12;
Comment thread
ahojnnes marked this conversation as resolved.
if (pt_calc(2) < kEps) continue;

double reprojection_error = max_reprojection_error;
if (in_normalized_image) {
Expand All @@ -26,7 +27,7 @@ int TrackFilter::FilterTracksByReprojection(

Eigen::Vector2d pt_reproj = pt_calc.head(2) / pt_calc(2);
reprojection_error =
(pt_reproj - feature_undist.head(2) / (feature_undist(2) + EPS))
(pt_reproj - feature_undist.head(2) / (feature_undist(2) + kEps))
.norm();
} else {
Eigen::Vector2d pt_dist;
Expand Down Expand Up @@ -62,21 +63,17 @@ int TrackFilter::FilterTracksByAngle(
double thres_uncalib = std::cos(DegToRad(max_angle_error * 2));
for (auto& [track_id, track] : tracks) {
std::vector<Observation> observation_new;
for (auto& [image_id, feature_id] : track.observations) {
for (const auto& [image_id, feature_id] : track.observations) {
const Image& image = images.at(image_id);
// const Camera& camera = image.camera;
const Eigen::Vector3d& feature_undist =
image.features_undist.at(feature_id);
Eigen::Vector3d pt_calc = image.CamFromWorld() * track.xyz;
if (pt_calc(2) < EPS) continue;

pt_calc = pt_calc.normalized();
double thres_cam = (cameras.at(image.camera_id).has_prior_focal_length)
const Eigen::Vector3d pt_calc = (image.CamFromWorld() * track.xyz).normalized();
const double thres_cam = (cameras.at(image.camera_id).has_prior_focal_length)
? thres
: thres_uncalib;

if (pt_calc.dot(feature_undist) > thres_cam) {
observation_new.emplace_back(std::make_pair(image_id, feature_id));
observation_new.emplace_back(image_id, feature_id);
}
}
if (observation_new.size() != track.observations.size()) {
Expand Down Expand Up @@ -126,4 +123,4 @@ int TrackFilter::FilterTrackTriangulationAngle(
return counter;
}

} // namespace glomap
} // namespace glomap
2 changes: 1 addition & 1 deletion 2 src/glomap/processors/view_graph_manipulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void ViewGraphManipulater::DecomposeRelPose(
image_pair.config = two_view_geometry.config;
image_pair.cam2_from_cam1 = two_view_geometry.cam2_from_cam1;

if (image_pair.cam2_from_cam1.translation.norm() > EPS) {
if (image_pair.cam2_from_cam1.translation.norm() > 1e-12) {
image_pair.cam2_from_cam1.translation =
image_pair.cam2_from_cam1.translation.normalized();
}
Expand Down
13 changes: 0 additions & 13 deletions 13 src/glomap/types.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
#pragma once

#include "colmap/util/logging.h"

#include <iostream>
#include <limits>
#include <string>
#include <vector>

#include <Eigen/Core>

namespace glomap {

constexpr double EPS = 1e-12;
constexpr double HALF_PI = 3.141592653589793238462643383279502884L / 2;
constexpr double TWO_PI = 2 * 3.141592653589793238462643383279502884L;

struct InlierThresholdOptions {
// Thresholds for 3D-2D matches
double max_angle_error = 1.; // in degree, for global positioning
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.