Skip to content

Commit

Permalink
Merge branch 'develop' into develop_2.0
Browse files Browse the repository at this point in the history
Conflicts:
	src/software/SfM/export/main_ExportCameraFrustums.cpp
  • Loading branch information
pmoulon committed Oct 20, 2021
2 parents 081fc96 + 14d69ed commit a196ceb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SfM [1], GlobalSfM [4] or Tracks [2]`:

```
@inproceedings{moulon2016openmvg,
title={Openmvg: Open multiple view geometry},
title={Open{MVG}: Open multiple view geometry},
author={Moulon, Pierre and Monasse, Pascal and Perrot, Romuald and Marlet, Renaud},
booktitle={International Workshop on Reproducible Research in Pattern Recognition},
pages={60--74},
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/multiview/translation_averaging_solver_softl1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool solve_translations_problem_softl1
// - relative translation scales (one per group)
// - relative rotations

std::vector<double> vec_translations(relative_info_count*3, 1.0);
std::vector<double> vec_translations(nb_poses*3, 1.0);
const unsigned nb_scales = vec_relative_group_estimates.size();
std::vector<double> vec_scales(nb_scales, 1.0);

Expand Down Expand Up @@ -232,7 +232,7 @@ bool solve_translations_problem_softl1
cpt = 0;
for (unsigned int i = 0; i < nb_poses; ++i, cpt+=3)
{
translations[i] << vec_translations[cpt], vec_translations[cpt+1], vec_translations[cpt+2];
translations[i] = Eigen::Map<Eigen::Vector3d>(&vec_translations[cpt]);
}
return true;
}
Expand Down
11 changes: 9 additions & 2 deletions src/software/SfM/export/main_ExportCameraFrustums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ int main(int argc, char **argv)

std::string sSfM_Data_Filename;
std::string sOutFile = "";
double z_near = -1.;
double z_far = -1.;

cmd.add( make_option('i', sSfM_Data_Filename, "input_file") );
cmd.add( make_option('o', sOutFile, "output_file") );
cmd.add( make_option('n', z_near, "z_near") );
cmd.add( make_option('f', z_far, "z_far") );
cmd.add( make_switch('c', "colorize") );

try {
Expand All @@ -44,7 +48,10 @@ int main(int argc, char **argv)
std::cerr << "Usage: " << argv[0] << '\n'
<< "[-i|--input_file] path to a SfM_Data scene\n"
<< "[-o|--output_file] PLY file to store the camera frustums as triangle meshes.\n"
<< "[-c|--colorize] Colorize the camera frustums.";
<< "[-n|--z_near] 'optional' distance of the near camera plane\n"
<< "[-f|--z_far] 'optional' distance of the far camera plane\n"
<< "[-c|--colorize] 'optional' colorize the camera frustums.\n"
<< std::endl;

OPENMVG_LOG_ERROR << s;
return EXIT_FAILURE;
Expand All @@ -66,7 +73,7 @@ int main(int argc, char **argv)
const bool colorize = cmd.used('c');

// If sfm_data have not structure, cameras are displayed as tiny normalized cones
const Frustum_Filter frustum_filter(sfm_data);
const Frustum_Filter frustum_filter(sfm_data, z_near, z_far);
if (!sOutFile.empty())
{
if (frustum_filter.export_Ply(sOutFile, colorize))
Expand Down
21 changes: 17 additions & 4 deletions src/software/SfM/export/main_openMVGSpherical2Cubic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ int main(int argc, char *argv[]) {
std::string s_sfm_data_filename;
std::string s_out_dir = "";
int force_recompute_images = 1;
int size_cubic_images = 1024;

cmd.add( make_option('i', s_sfm_data_filename, "sfmdata") );
cmd.add( make_option('o', s_out_dir, "outdir") );
cmd.add( make_option('f', force_recompute_images, "force_compute_cubic_images") );
cmd.add( make_option('s', size_cubic_images, "size-cubic-images") );

try {
if (argc == 1) throw std::string("Invalid command line parameter.");
Expand All @@ -50,6 +52,8 @@ int main(int argc, char *argv[]) {
<< "[-i|--sfmdata] filename, the SfM_Data file to convert\n"
<< "[-o|--outdir path]\n"
<< "[-f|--force_recompute_images] (default 1)\n"
<< "[-s|--size-cubic-images] (default 1024) pixel size of the resulting cubic images, "
<< "non-positive values will automatically scale the output based on the input"
<< std::endl;

std::cerr << s << std::endl;
Expand All @@ -58,6 +62,10 @@ int main(int argc, char *argv[]) {

OPENMVG_LOG_INFO << "force_recompute_images = " << force_recompute_images;

std::cout << "size_cubic_images = ";
if(size_cubic_images > 0) std::cout << size_cubic_images << std::endl;
else std::cout << "auto" << std::endl;

// Create output dir
if (!stlplus::folder_exists(s_out_dir))
stlplus::folder_create(s_out_dir);
Expand All @@ -72,10 +80,6 @@ int main(int argc, char *argv[]) {
SfM_Data sfm_data_out; // the sfm_data that stores the cubical image list
sfm_data_out.s_root_path = s_out_dir;

const int cubic_image_size = 1024;
const openMVG::cameras::Pinhole_Intrinsic pinhole_camera =
spherical::ComputeCubicCameraIntrinsics(cubic_image_size);

// Convert every spherical view to cubic views
{
system::LoggerProgress my_progress_bar(
Expand All @@ -85,6 +89,10 @@ int main(int argc, char *argv[]) {
const Poses & poses = sfm_data.GetPoses();
const Landmarks & structure = sfm_data.GetLandmarks();

openMVG::cameras::Pinhole_Intrinsic pinhole_camera;
if(size_cubic_images > 0)
pinhole_camera = spherical::ComputeCubicCameraIntrinsics(size_cubic_images);

// generate views and camera poses for each new views
int error_status = 0;
#pragma omp parallel for shared(error_status) if(error_status < 1)
Expand Down Expand Up @@ -113,6 +121,11 @@ int main(int argc, char *argv[]) {
continue;
}

if(size_cubic_images <= 0) {
const int auto_cubic_size = spherical_image.Height()/2;
pinhole_camera = spherical::ComputeCubicCameraIntrinsics(auto_cubic_size);
}

const std::array<Mat3,6> rot_matrix = spherical::GetCubicRotations();

// when cubical image computation is needed
Expand Down

0 comments on commit a196ceb

Please sign in to comment.