Skip to content

Commit

Permalink
update readme.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
oneLOH committed May 16, 2024
1 parent 54446c5 commit f8eeebf
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 40 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,20 @@ endif()
add_executable(run_matching src/run_matching.cc)
target_link_libraries(run_matching xrsfm)

# add_executable(run_reconstruction src/run_reconstruction.cc)
# target_link_libraries(run_reconstruction xrsfm)
add_executable(run_reconstruction src/run_reconstruction.cc)
target_link_libraries(run_reconstruction xrsfm)

# add_executable(run_triangulation src/run_triangulation.cc)
# target_link_libraries(run_triangulation xrsfm)
add_executable(run_triangulation src/run_triangulation.cc)
target_link_libraries(run_triangulation xrsfm)

# add_executable(unpack_collect_data src/unpack_collect_data.cc)
# target_link_libraries(unpack_collect_data xrsfm)
add_executable(unpack_collect_data src/unpack_collect_data.cc)
target_link_libraries(unpack_collect_data xrsfm)

# add_executable(estimate_scale src/estimate_scale.cc)
# target_link_libraries(estimate_scale xrsfm apriltag)
add_executable(estimate_scale src/estimate_scale.cc)
target_link_libraries(estimate_scale xrsfm apriltag)

# add_executable(rec_1dsfm src/rec_1dsfm.cc)
# target_link_libraries(rec_1dsfm xrsfm)
add_executable(rec_1dsfm src/rec_1dsfm.cc)
target_link_libraries(rec_1dsfm xrsfm)

add_executable(rec_kitti src/rec_kitti.cc)
target_link_libraries(rec_kitti xrsfm)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nvidia/cuda:10.2-devel-ubuntu18.04
FROM nvidia/cuda:12.1.0-devel-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
2 changes: 1 addition & 1 deletion docs/en/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Run reconsturction stage with the following command line
"init_id1" and "init_id2" indicates two frames for the initialization of SfM.
In general, these two frames can be set to 0 and 5.

The format of output binary files is is consistent with COLMAP, you can use colmap gui to view the reconstruction result.
You can view the reconstruction results using ```./bin/xrsfm_gui```. The file format is the same as the well-known open-source project COLMAP. You can also use COLMAP's graphical user interface to view the reconstruction results of this project.

### 3. Estimate scale with apriltag (Optional)
Input: images, reconstruction results
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ XRSfM支持顺序匹配("sequential")、基于检索的匹配("retrieval")和基
"init_id1" and "init_id2" 是可选的输入参数,指定重建阶段的初始帧,当不输入该参数时,程序将会自行选择初始帧。

输出的重建结果由三部分组成“cameras.bin”,“images.bin”,"points.bin"。
文件格式与知名的开源工作COLMAP相同,用户可以使用COLMAP的图像用户界面查看本项目的重建结果
使用```./bin/xrsfm_gui```可以查看重建结果,文件格式与知名的开源工作COLMAP相同,也可以使用COLMAP的图像用户界面查看本项目的重建结果

### 3. 尺度估计(可选)
输入: 图像文件夹,重建结果
Expand Down
11 changes: 4 additions & 7 deletions src/base/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ class Camera {
}
Camera(int _id, double fxy, double cx, double cy) {
id_ = _id;
// model_id_ = 0;
// params_ = {fxy, cx, cy};
model_id_ = 2;
params_ = {fxy, cx, cy, 0};
std::cout << params_.size() << std::endl;
is_valid = true;
}

Expand Down Expand Up @@ -88,8 +85,8 @@ inline void ImageToNormalized(const Camera &c, const Eigen::Vector2d &p2d,
CAMERA_MODEL_CASES
#undef CAMERA_MODEL_CASE

std::cout << "ERROR: (ImageToNormalized) unsupported model type: "
<< c.model_id_ << "\n";
printf("ERROR: (ImageToNormalized) unsupported model type: %d\n",
c.model_id_);
exit(-1);
}

Expand All @@ -104,8 +101,8 @@ inline void NormalizedToImage(const Camera &c, const Eigen::Vector2d &p2d_n,
CAMERA_MODEL_CASES
#undef CAMERA_MODEL_CASE

std::cout << "ERROR: (NormalizedToImage) unsupported model type: "
<< c.model_id_ << "\n";
printf("ERROR: (NormalizedToImage) unsupported model type: %d",
int(c.model_id_));
exit(-1);
}

Expand Down
1 change: 0 additions & 1 deletion src/base/camera_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ inline void IterativeUndistortion(const double *params, double *xy) {
Eigen::Vector2d xy_plus;

for (size_t i = 0; i < kNumIterations; ++i) {
// std::cout << i << " " << kNumIterations << std::endl;
const double step0 = std::max(std::numeric_limits<double>::epsilon(),
std::abs(kRelStepSize * x(0)));
const double step1 = std::max(std::numeric_limits<double>::epsilon(),
Expand Down
2 changes: 1 addition & 1 deletion src/colmap/ransac/combination_sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <numeric>

#include "random.h"
#include "util/math.h"
#include "math.h"

namespace colmap {

Expand Down
File renamed without changes.
8 changes: 5 additions & 3 deletions src/colmap/ui/model_viewer_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <Eigen/Eigen>
#include "model_viewer_widget.h"
#include "util/math.h"

#define SELECTION_BUFFER_IMAGE_IDX 0
#define SELECTION_BUFFER_POINT_IDX 1
Expand All @@ -52,6 +51,10 @@ const Eigen::Vector4f kZAxisColor(0.0f, 0.0f, 0.9f, 0.5f);
namespace xrsfm {
namespace {

double RadToDeg(const double rad) {
return rad * 57.29577951308232286464772187173366546630859375;
}

// Generate unique index from RGB color in the range [0, 256^3].
inline size_t RGBToIndex(const uint8_t r, const uint8_t g, const uint8_t b) {
return static_cast<size_t>(r) + static_cast<size_t>(g) * 256 +
Expand Down Expand Up @@ -369,8 +372,7 @@ void ModelViewerWidget::RotateView(const float x, const float y,
// First shift to rotation center, then rotate and shift back.
model_view_matrix_.translate(rot_center(0), rot_center(1),
rot_center(2));
model_view_matrix_.rotate(colmap::RadToDeg(angle), axis(0), axis(1),
axis(2));
model_view_matrix_.rotate(RadToDeg(angle), axis(0), axis(1), axis(2));
model_view_matrix_.translate(-rot_center(0), -rot_center(1),
-rot_center(2));
update();
Expand Down
2 changes: 1 addition & 1 deletion src/estimate_scale.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <fstream>

#include "base/camera.h"
#include "base/camera.hpp"
#include "base/map.h"
#include "geometry/track_processor.h"
#include "optimization/ba_solver.h"
Expand Down
6 changes: 2 additions & 4 deletions src/feature/feature_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ void FeatureExtract(const std::string &image_dir_path,
const cv::Mat image = cv::imread(image_dir_path + frame.name,
cv::IMREAD_IGNORE_ORIENTATION);
if (image.rows == 0) {
std::cout << "Can't read " << image_dir_path + frame.name
<< std::endl;
std::cout << "ERROR: fail to read image: "
<< image_dir_path + frame.name << std::endl;
exit(0);
}

image_size.push_back(ImageSize(image.cols, image.rows));

#ifndef USE_ORB
// std::cout << image_dir_path + frame.name << std::endl;
sift.ExtractUINT8(image, frame.keypoints_, frame.uint_descs_);
// std::cout << i << " " << frame.uint_descs_.rows() << std::endl;
#else
orb(image, cv::Mat(), frame.keypoints_, frame.orb_descs_);
#endif
Expand Down
3 changes: 0 additions & 3 deletions src/geometry/error_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ bool ErrorDetector::IsGoodRelativePose(const Map &map, const FramePair &fp,
num_matches);

if (ratio < ratio_th) {
// std::cout << frame1.tcw.q.coeffs().transpose() << " " <<
// frame1.tcw.t.transpose() << std::endl;nn

return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/track_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ int Point3dProcessor::TriangulateFramePoint(Map &map, const int frame_id,
if (!cor_frame.registered)
continue;
if (cor_frame.track_ids_.size() <= t_p2d_id) {
std::cout << "bad" << t_frame_id << " " << t_p2d_id
<< std::endl;
printf("Error: frame %d index out of bounds %d %d\n",
t_frame_id, t_p2d_id, int(cor_frame.track_ids_.size()));
exit(0);
}
observations.emplace_back(t_frame_id, t_p2d_id);
Expand Down
21 changes: 19 additions & 2 deletions src/optimization/ba_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@
#include "ba_solver.h"

#include "cost_factor_ceres.h"
#include "util/math.h"
#include "utility/timer.h"
#include "geometry/triangulate_light.h"

namespace xrsfm {

template <typename T>
T Percentile(const std::vector<T> &elems, const double p) {
CHECK(!elems.empty());
CHECK_GE(p, 0);
CHECK_LE(p, 100);

const int idx = static_cast<int>(std::round(p / 100 * (elems.size() - 1)));
const size_t percentile_idx =
std::max(0, std::min(static_cast<int>(elems.size() - 1), idx));

std::vector<T> ordered_elems = elems;
std::nth_element(ordered_elems.begin(),
ordered_elems.begin() + percentile_idx,
ordered_elems.end());

return ordered_elems.at(percentile_idx);
}

void PrintSolverSummary(const ceres::Solver::Summary &summary) {
std::cout << std::right << std::setw(16) << "Residuals : ";
std::cout << std::left << summary.num_residuals_reduced << std::endl;
Expand Down Expand Up @@ -466,7 +483,7 @@ std::vector<int> FindLocalBundle(const int frame_id, Map &map,

// Calculate the triangulation angle at a certain percentile.
const double kTriangulationAnglePercentile = 75;
tri_angle = colmap::Percentile(
tri_angle = Percentile(
CalculateTriangulationAnglesLight(
proj_center, proj_center_overlap, shared_points3D),
kTriangulationAnglePercentile);
Expand Down
1 change: 0 additions & 1 deletion src/rec_1dsfm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void PreProcess(const std::string bin_path, Map &map) {
}

for (int i = 0; i < cameras.size(); ++i) {
std::cout << i << " " << cameras.size() << std::endl;
auto &camera = cameras[i];
// camera.log();
// if distortion parameters of the camera are not estimated, the camera
Expand Down
4 changes: 2 additions & 2 deletions src/tag/tag_extract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
}

#include "base/map.h"
#include "base/camera.h"
#include "base/camera.hpp"
#include "geometry/track_processor.h"
#include "optimization/ba_solver.h"
#include "optimization/cost_factor_ceres.h"
Expand Down Expand Up @@ -257,7 +257,7 @@ void tag_refine(std::string image_dir, std::string map_dir,

ceres::Solve(solver_options, &problem, &summary);
std::cout << summary.BriefReport() << "\n";
std::cout << scale << std::endl;
std::cout << "scale :" << scale << std::endl;

// resize map
for (auto &[id, frame] : map.frame_map_) {
Expand Down

0 comments on commit f8eeebf

Please sign in to comment.