8000 Modularize executable main functions into separate sources by ahojnnes · Pull Request #1160 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Modularize executable main functions into separate sources #1160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2021
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
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions src/base/reconstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,7 @@ void Reconstruction::ImportPLY(const std::string& path) {
}
}

void Reconstruction::ImportPLY(const std::vector<PlyPoint> &ply_points)
{
void Reconstruction::ImportPLY(const std::vector<PlyPoint>& ply_points) {
points3D_.clear();
points3D_.reserve(ply_points.size());
for (const auto& ply_point : ply_points) {
Expand Down Expand Up @@ -995,18 +994,17 @@ bool Reconstruction::ExportCam(const std::string& path,
<< std::endl;
return false;
}
Eigen::Vector3d proj_center = image.ProjectionCenter();
Eigen::Matrix3d rot_mtx = image.RotationMatrix();
double max_size = std::max(camera.Width(), camera.Height());

const Eigen::Matrix3d rot_mat = image.RotationMatrix();
const double max_image_size = std::max(camera.Width(), camera.Height());
file << image.Tvec(0) << " " << image.Tvec(1) << " " << image.Tvec(2) << " "
<< rot_mtx(0, 0) << " " << rot_mtx(0, 1) << " " << rot_mtx(0, 2) << " "
<< rot_mtx(1, 0) << " " << rot_mtx(1, 1) << " " << rot_mtx(1, 2) << " "
<< rot_mtx(2, 0) << " " << rot_mtx(2, 1) << " " << rot_mtx(2, 2)
<< rot_mat(0, 0) << " " << rot_mat(0, 1) << " " << rot_mat(0, 2) << " "
<< rot_mat(1, 0) << " " << rot_mat(1, 1) << " " << rot_mat(1, 2) << " "
<< rot_mat(2, 0) << " " << rot_mat(2, 1) << " " << rot_mat(2, 2)
<< std::endl;
file << camera.MeanFocalLength() / max_size << " " << k1 << " " << k2 << " 1.0 "
<< camera.PrincipalPointX() / camera.Width() << " "
file << camera.MeanFocalLength() / max_image_size << " " << k1 << " " << k2
<< " 1.0 " << camera.PrincipalPointX() / camera.Width() << " "
<< camera.PrincipalPointY() / camera.Height() << std::endl;
file.close();
}

return true;
Expand Down Expand Up @@ -1055,7 +1053,8 @@ bool Reconstruction::ExportRecon3D(const std::string& path,
k1 = -1 * camera.Params(RadialCameraModel::extra_params_idxs[0]);
k2 = -1 * camera.Params(RadialCameraModel::extra_params_idxs[1]);
} else {
std::cout << "WARNING: Recon3D only supports `SIMPLE_RADIAL` and `RADIAL` camera model."
std::cout << "WARNING: Recon3D only supports `SIMPLE_RADIAL` and "
"`RADIAL` camera model."
<< std::endl;
return false;
}
Expand All @@ -1064,8 +1063,10 @@ bool Reconstruction::ExportRecon3D(const std::string& path,
1.0 / (double)std::max(camera.Width(), camera.Height());
synth_file << scale * camera.MeanFocalLength() << " " << k1 << " " << k2
<< std::endl;
synth_file << QuaternionToRotationMatrix(NormalizeQuaternion(image.Qvec())) << std::endl;
synth_file << image.Tvec(0) << " " << image.Tvec(1) << " " << image.Tvec(2) << std::endl;
synth_file << QuaternionToRotationMatrix(NormalizeQuaternion(image.Qvec()))
<< std::endl;
synth_file << image.Tvec(0) << " " << image.Tvec(1) << " " << image.Tvec(2)
<< std::endl;

image_id_to_idx_[image_id] = image_idx;
image_list_file << image.Name() << std::endl
Expand All @@ -1080,8 +1081,10 @@ bool Reconstruction::ExportRecon3D(const std::string& path,
// Write point info
for (const auto& point3D : points3D_) {
auto& p = point3D.second;
synth_file << p.XYZ()(0) << " " << p.XYZ()(1) << " " << p.XYZ()(2) << std::endl;
synth_file << (int)p.Color(0) << " " << (int)p.Color(1) << " " << (int)p.Color(2) << std::endl;
synth_file << p.XYZ()(0) << " " << p.XYZ()(1) << " " << p.XYZ()(2)
<< std::endl;
synth_file << (int)p.Color(0) << " " << (int)p.Color(1) << " "
<< (int)p.Color(2) << std::endl;

std::ostringstream line;

Expand Down Expand Up @@ -1146,7 +1149,7 @@ bool Reconstruction::ExportBundler(const std::string& path,
k1 = 0.0;
k2 = 0.0;
} else if (camera.ModelId() == SimplePinholeCameraModel::model_id ||
camera.ModelId() == PinholeCameraModel::model_id) {
camera.ModelId() == PinholeCameraModel::model_id) {
k1 = 0.0;
k2 = 0.0;
} else if (camera.ModelId() == SimpleRadialCameraModel::model_id) {
Expand Down
18 changes: 9 additions & 9 deletions src/base/scene_clustering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@ void SceneClustering::PartitionFlatCluster(
// We do the process sequentially for each image to ensure that at
// least we get the best matches firat
for (int i = 0; i < options_.branching; ++i) {
auto& orig_images = root_cluster_->child_clusters[i].image_ids;
auto& orig_image_ids = root_cluster_->child_clusters[i].image_ids;
std::set<int> cluster_images(
root_cluster_->child_clusters[i].image_ids.begin(),
root_cluster_->child_clusters[i].image_ids.end());
const int max_size = cluster_images.size() + options_.image_overlap;
const size_t max_size = cluster_images.size() + options_.image_overlap;
// check up to all the desired matches
for (int j = 0;
j < options_.num_image_matches && cluster_images.size() < max_size;
for (size_t j = 0; j < static_cast<size_t>(options_.num_image_matches) &&
cluster_images.size() < max_size;
++j) {
for (auto im_id : orig_images) {
const auto& images = related_images[im_id];
for (const image_t image_id : orig_image_ids) {
const auto& images = related_images[image_id];
if (j >= images.size()) {
continue;
}
Expand All @@ -241,9 +241,9 @@ void SceneClustering::PartitionFlatCluster(
}
}
}
orig_images.clear();
orig_images.insert(orig_images.end(), cluster_images.begin(),
cluster_images.end());
orig_image_ids.clear();
orig_image_ids.insert(orig_image_ids.end(), cluster_images.begin(),
cluster_images.end());
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/exe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@ if(IS_MSVC)
add_compile_options("/bigobj")
endif()

COLMAP_ADD_EXECUTABLE(colmap_exe colmap.cc)
COLMAP_ADD_EXECUTABLE(colmap_exe
colmap.cc
database.cc
feature.cc
gui.cc
image.cc
model.cc
mvs.cc
sfm.cc
vocab_tree.cc)
set_target_properties(colmap_exe PROPERTIES OUTPUT_NAME colmap)
Loading
0