mvs-texturing icon indicating copy to clipboard operation
mvs-texturing copied to clipboard

Has anyone gotten this to compile on windows (VS2019)?

Open syberspaz opened this issue 3 years ago • 8 comments

I've been able to compile mve, but I'm having significant trouble getting mvs-texturing to compile in VS2019. Any suggestions? a few things I've noticed so far,

  • VS2019 for some reason doesn't like having OpenMP for loops with unsigned size_t vars
  • somehow it cannot deduce the type for multi_gauss_unnormalized() in calculate_data_costs.cpp
  • for some reason, it cannot find load_nvm_bundle even though I'm linking with mve_d.lib and mve_util_d.lib

Error output:

  • 1>tex.lib(generate_texture_views.obj) : error LNK2019: unresolved external symbol "class std::shared_ptr<class mve::Bundle> __cdecl mve::load_nvm_bundle(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::vector<struct mve::NVMCameraInfo,class std::allocator<struct mve::NVMCameraInfo> > *)" (?load_nvm_bundle@mve@@YA?AV?$shared_ptr@VBundle@mve@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@PEAV?$vector@UNVMCameraInfo@mve@@V?$allocator@UNVMCameraInfo@mve@@@std@@@3@@Z) referenced in function "void __cdecl tex::from_nvm_scene(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::vector<class tex::TextureView,class std::allocator<class tex::TextureView> > *,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?from_nvm_scene@tex@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAV?$vector@VTextureView@tex@@V?$allocator@VTextureView@tex@@@std@@@3@0@Z) 1>C:\Users\hogue\Documents\GitHub\mvs-texturing\build\apps\texrecon\Debug\texrecon.exe : fatal error LNK1120: 1 unresolved externals 1>Done building project "texrecon.vcxproj" -- FAILED.

syberspaz avatar Jun 10 '21 17:06 syberspaz

Hi @syberspaz, AFAIK Visual Studio is currently stuck on OpenMP 2.0 which only supports signed loop variables but apparently Microsoft is working on improving their OpenMP support according to a recent blog entry [1]. You could try the -openmp:llvm command-line option if you have the VS 16.9 preview release.

Otherwise, it's been a while since I've compiled mvs-texturing on Windows but maybe you'll find the following two commits helpful which contain changes I had to make to get it to compile with Visual Studio: https://github.com/andre-schulz/mvs-texturing/commit/b267b54543db694ed2aa026780f7e420e74ae864 https://github.com/andre-schulz/mvs-texturing/commit/91f4a8407cc07c8691c12c668a3399e3272d8ba0

[1] https://devblogs.microsoft.com/cppblog/improved-openmp-support-for-cpp-in-visual-studio/

andre-schulz avatar Jun 10 '21 18:06 andre-schulz

thanks, for some reason its the load_nvm_bundle() function and the multi_gauss_unnormalized functions that are tripping me up at the moment..... I was able to get around the openmp by disabling the openMP entirely ....

syberspaz avatar Jun 10 '21 18:06 syberspaz

as for the multi_gauss_normalized issue, in the "tex" project, I'm getting the compile error below. The particular code snippet that is relevant is:

for (std::size_t row = 0; row < infos->size(); ++row) { Eigen::RowVector3d color = mve_to_eigen(infos->at(row).mean_color).cast(); double gauss_value = multi_gauss_unnormalized(color, var_mean, covariance_inv); is_inlier[row] = (gauss_value >= gauss_rejection_threshold ? 1 : 0); }

I'm not sure why this call is causing an issue, intellisense can find the function and I can peek to find the definition:

template <typename T, int N> T const multi_gauss_unnormalized(Eigen::Matrix<T, 1, N> const & X, Eigen::Matrix<T, 1, N> const & mu, Eigen::Matrix<T, N, N> const & covariance_inv) { Eigen::Matrix<T, 1, N> mean_removed = X - mu; return std::exp(T(-0.5) * mean_removed * covariance_inv * mean_removed.adjoint()); }

Strange.

1>C:\Users\hogue\Documents\GitHub\mvs-texturing\libs\tex\calculate_data_costs.cpp(102,34): error C2672: 'multi_gauss_unnormalized': no matching overloaded function found 1>C:\Users\hogue\Documents\GitHub\mvs-texturing\libs\tex\calculate_data_costs.cpp(102,90): error C2784: 'const T multi_gauss_unnormalized(const Eigen::Matrix<T,1,N,0|true&&_Cols!=1?Eigen::RowMajor:_Cols==1&&false?Eigen::ColMajor:Eigen::ColMajor,1,_Cols> &,const Eigen::Matrix<T,1,N,0|true&&_Cols!=1?Eigen::RowMajor:_Cols==1&&false?Eigen::ColMajor:Eigen::ColMajor,1,_Cols> &,const Eigen::Matrix<T,N,N,0|_Rows==1&&_Cols!=1?Eigen::RowMajor:_Cols==1&&_Rows!=1?Eigen::ColMajor:Eigen::ColMajor,_Rows,_Cols> &)': could not deduce template argument for 'const Eigen::Matrix<T,1,N,0|true&&_Cols!=1?Eigen::RowMajor:_Cols==1&&false?Eigen::ColMajor:Eigen::ColMajor,1,_Cols> &' from 'Eigen::RowVector3d' 1>C:\Users\hogue\Documents\GitHub\mvs-texturing\libs\tex\util.h(61): message : see declaration of 'multi_gauss_unnormalized' 1>C:\Users\hogue\Documents\GitHub\mvs-texturing\libs\tex\calculate_data_costs.cpp(218,44): warning C4838: conversion from 'short' to 'uint16_t' requires a narrowing conversion 1>Done building project "tex.vcxproj" -- FAILED.

syberspaz avatar Jun 10 '21 19:06 syberspaz

The second commit I've linked contains a possible fix for that. Have you tried passing the template parameters explicitly? For example: double gauss_value = multi_gauss_unnormalized<double, 3>(color, var_mean, covariance_inv);

andre-schulz avatar Jun 10 '21 20:06 andre-schulz

aha! Thanks! yes, explicitly providing the template parameters solved that particular issue... oh C++.....

still running into the load_nvm_bundle issue: I wonder if its a name mangling issue.......

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "class std::shared_ptr<class mve::Bundle> __cdecl mve::load_nvm_bundle(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::vector<struct mve::NVMCameraInfo,class std::allocator<struct mve::NVMCameraInfo> > *)" (?load_nvm_bundle@mve@@YA?AV?$shared_ptr@VBundle@mve@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@PEAV?$vector@UNVMCameraInfo@mve@@V?$allocator@UNVMCameraInfo@mve@@@std@@@3@@Z) referenced in function "void __cdecl tex::from_nvm_scene(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::vector<class tex::TextureView,class std::allocator<class tex::TextureView> > *,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?from_nvm_scene@tex@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAV?$vector@VTextureView@tex@@V?$allocator@VTextureView@tex@@@std@@@3@0@Z) texrecon C:\Users\hogue\Documents\GitHub\mvs-texturing\build\apps\texrecon\tex.lib(generate_texture_views.obj) 1

syberspaz avatar Jun 10 '21 20:06 syberspaz

In tex.lib : generate_texture_views.cpp, the relevant snippet is:

mve::Bundle::Ptr bundle = mve::load_nvm_bundle(nvm_file, &nvm_cams);

which is declared in bundle_io.h as:

/**

  • Loads an NVM bundle file while providing NVM specific information.
  • Docs: http://homes.cs.washington.edu/~ccwu/vsfm/doc.html#nvm
  • This function provides a bundle with cameras where the focal length is in
  • VisualSFM conventions, NOT MVE conventions. To convert to focal length to
  • MVE conventions, it must be divided by the maximum image dimension. / Bundle::Ptr load_nvm_bundle (std::string const& filename, std::vector<NVMCameraInfo> camera_info = nullptr);

Aha! i think I've found it. The MVE that mvs-texturing is using looks to be different than the MVE that I've compiled to on my system..... The one on my system doesn't have an "NVMCameraInfo" but rather an "AdditionalCameraInfo" struct. Now to fix!

syberspaz avatar Jun 10 '21 20:06 syberspaz

hacky hacky, but it let's it compile:

MVE_NAMESPACE_BEGIN typedef struct AdditionalCameraInfo NVMCameraInfo;

now..... does it work.....

syberspaz avatar Jun 10 '21 20:06 syberspaz

Yes. With some changes. Check this OpenDroneMap branch that compiles on Windows. https://github.com/OpenDroneMap/mvs-texturing/tree/262

pierotofy avatar Sep 27 '21 19:09 pierotofy