Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcseacave committed Apr 6, 2016
2 parents e1fa524 + f4829f4 commit b3cebcb
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 37 deletions.
34 changes: 20 additions & 14 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Required tools:
Windows compilation
-------------------

Visual Studion 2008 or newer is supported. Please not that the development is done mainly on Windows, so this platform build is tested the most.
Visual Studion 2008 or newer is supported. Please note that the development is done mainly on Windows, so this platform build is tested the most. The latest pre-built binaries for fast testing can be download from [here](https://github.com/cdcseacave/openMVS_sample/releases/latest).

```
# Make a toplevel directory for deps & build & src somewhere:
Expand All @@ -43,7 +43,7 @@ cd build
# Run CMake:
cmake . ../src -DCMAKE_BUILD_TYPE=RELEASE -DEIGEN_DIR="../OpenMVS/Eigen" -DOPENCV_DIR="../OpenMVS/OpenCV" -DCERES_DIR="../OpenMVS/Ceres" -DCGAL_DIR="../OpenMVS/CGAL" -DVCG_DIR="../OpenMVS/VCG"
# Open the solution and build it in MSVC
# Open the solution in MSVC and build it
```

-----------------
Expand All @@ -55,7 +55,7 @@ Linux compilation
```
#Prepare and empty machine for building:
sudo apt-get update -qq && sudo apt-get install -qq
sudo apt-get -y install git mercurial subversion cmake libpng-dev libjpeg-dev libtiff-dev libglu1-mesa-dev
sudo apt-get -y install git subversion cmake libpng-dev libjpeg-dev libtiff-dev libglu1-mesa-dev
main_path=`pwd`
#Eigen (Required)
Expand Down Expand Up @@ -87,29 +87,35 @@ git clone https://github.com/cdcseacave/openMVS.git openMVS
mkdir openMVS_build && cd openMVS_build
cmake . ../openMVS -DCMAKE_BUILD_TYPE=Release -DVCG_DIR="$main_path/vcglib"
#If you want to use OpenMVS as shared library, add to the cmake command:
#If you want to use OpenMVS as shared library, add to the CMake command:
-DBUILD_SHARED_LIBS=ON
#Install OpenMVS library (optional):
sudo make install
make && sudo make install
```

--------------------
Mac OS X compilation
--------------------

Not tested, any help testing on this platform is welcome.
Install dependencies, run CMake and make.

```
# Install dependencies using [MacPorts](http://www.macports.org):
sudo port install opencv boost cgal ceres-solver eigen3
#Install dependencies
brew install opencv boost cgal eigen ceres-solver
svn checkout svn://svn.code.sf.net/p/vcg/code/trunk/vcglib vcglib
main_path=`pwd`
# Getting the OpenMVS sources:
#Getting the OpenMVS sources:
git clone https://github.com/cdcseacave/openMVS.git
# Build
mkdir bin
cd bin
cmake . <OpenMVS_path> -DCMAKE_BUILD_TYPE=RELEASE -DVCG_DIR="<vcglib_path>" -DCGAL_DIR="/opt/local/share/CGAL" -DCERES_DIR="/opt/local/share/Ceres"
make -j4
#Build OpenMVS
mkdir openMVS_build && cd openMVS_build
cmake . ../openMVS -DCMAKE_BUILD_TYPE=Release -DVCG_DIR="$main_path/vcglib"
#If you want to use OpenMVS as shared library, add to the CMake command:
-DBUILD_SHARED_LIBS=ON
#Install OpenMVS library (optional):
make && sudo make install
```
9 changes: 6 additions & 3 deletions apps/ReconstructMesh/ReconstructMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ unsigned nSmoothMesh;
unsigned nArchiveType;
int nProcessPriority;
unsigned nMaxThreads;
String strExportType;
String strConfigFileName;
boost::program_options::variables_map vm;
} // namespace OPT
Expand All @@ -76,6 +77,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
("help,h", "produce this help message")
("working-folder,w", boost::program_options::value<std::string>(&WORKING_FOLDER), "working directory (default current directory)")
("config-file,c", boost::program_options::value<std::string>(&OPT::strConfigFileName)->default_value(APPNAME _T(".cfg")), "file name containing program options")
("export-type", boost::program_options::value<std::string>(&OPT::strExportType)->default_value(_T("ply")), "file type used to export the 3D scene (ply or obj)")
("archive-type", boost::program_options::value<unsigned>(&OPT::nArchiveType)->default_value(2), "project archive type: 0-text, 1-binary, 2-compressed binary")
("process-priority", boost::program_options::value<int>(&OPT::nProcessPriority)->default_value(-1), "process priority (below normal by default)")
("max-threads", boost::program_options::value<unsigned>(&OPT::nMaxThreads)->default_value(0), "maximum number of threads (0 for using all available cores)")
Expand Down Expand Up @@ -159,6 +161,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
}
if (OPT::strInputFileName.IsEmpty())
return false;
OPT::strExportType = OPT::strExportType.ToLower() == _T("obj") ? _T(".obj") : _T(".ply");

// initialize optional options
Util::ensureValidPath(OPT::strOutputFileName);
Expand Down Expand Up @@ -240,7 +243,7 @@ int main(int argc, LPCTSTR* argv)
#if TD_VERBOSE != TD_VERBOSE_OFF
if (VERBOSITY_LEVEL > 2) {
// dump raw mesh
scene.mesh.Save(MAKE_PATH_SAFE(Util::getFullFileName(OPT::strOutputFileName) + _T("_raw.ply")));
scene.mesh.Save(MAKE_PATH_SAFE(Util::getFullFileName(OPT::strOutputFileName)+_T("_raw")+OPT::strExportType));
}
#endif
} else {
Expand All @@ -256,10 +259,10 @@ int main(int argc, LPCTSTR* argv)
// save the final mesh
const String baseFileName(MAKE_PATH_SAFE(Util::getFullFileName(OPT::strOutputFileName)));
scene.Save(baseFileName+_T(".mvs"), (ARCHIVE_TYPE)OPT::nArchiveType);
scene.mesh.Save(baseFileName+_T(".ply"));
scene.mesh.Save(baseFileName+OPT::strExportType);
#if TD_VERBOSE != TD_VERBOSE_OFF
if (VERBOSITY_LEVEL > 2)
scene.ExportCamerasMLP(baseFileName+_T(".mlp"), baseFileName+_T(".ply"));
scene.ExportCamerasMLP(baseFileName+_T(".mlp"), baseFileName+OPT::strExportType);
#endif
}

Expand Down
7 changes: 5 additions & 2 deletions apps/RefineMesh/RefineMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ bool bUseCUDA;
unsigned nArchiveType;
int nProcessPriority;
unsigned nMaxThreads;
String strExportType;
String strConfigFileName;
boost::program_options::variables_map vm;
} // namespace OPT
Expand All @@ -85,6 +86,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
("help,h", "produce this help message")
("working-folder,w", boost::program_options::value<std::string>(&WORKING_FOLDER), "working directory (default current directory)")
("config-file,c", boost::program_options::value<std::string>(&OPT::strConfigFileName)->default_value(APPNAME _T(".cfg")), "file name containing program options")
("export-type", boost::program_options::value<std::string>(&OPT::strExportType)->default_value(_T("ply")), "file type used to export the 3D scene (ply or obj)")
("archive-type", boost::program_options::value<unsigned>(&OPT::nArchiveType)->default_value(2), "project archive type: 0-text, 1-binary, 2-compressed binary")
("process-priority", boost::program_options::value<int>(&OPT::nProcessPriority)->default_value(-1), "process priority (below normal by default)")
("max-threads", boost::program_options::value<unsigned>(&OPT::nMaxThreads)->default_value(0), "maximum number of threads (0 for using all available cores)")
Expand Down Expand Up @@ -174,6 +176,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
}
if (OPT::strInputFileName.IsEmpty())
return false;
OPT::strExportType = OPT::strExportType.ToLower() == _T("obj") ? _T(".obj") : _T(".ply");

// initialize optional options
Util::ensureValidPath(OPT::strOutputFileName);
Expand Down Expand Up @@ -257,10 +260,10 @@ int main(int argc, LPCTSTR* argv)
// save the final mesh
const String baseFileName(MAKE_PATH_SAFE(Util::getFullFileName(OPT::strOutputFileName)));
scene.Save(baseFileName+_T(".mvs"), (ARCHIVE_TYPE)OPT::nArchiveType);
scene.mesh.Save(baseFileName+_T(".ply"));
scene.mesh.Save(baseFileName+OPT::strExportType);
#if TD_VERBOSE != TD_VERBOSE_OFF
if (VERBOSITY_LEVEL > 2)
scene.ExportCamerasMLP(baseFileName+_T(".mlp"), baseFileName+_T(".ply"));
scene.ExportCamerasMLP(baseFileName+_T(".mlp"), baseFileName+OPT::strExportType);
#endif

Finalize();
Expand Down
7 changes: 5 additions & 2 deletions apps/TextureMesh/TextureMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ unsigned nOrthoMapResolution;
unsigned nArchiveType;
int nProcessPriority;
unsigned nMaxThreads;
String strExportType;
String strConfigFileName;
boost::program_options::variables_map vm;
} // namespace OPT
Expand All @@ -77,6 +78,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
("help,h", "produce this help message")
("working-folder,w", boost::program_options::value<std::string>(&WORKING_FOLDER), "working directory (default current directory)")
("config-file,c", boost::program_options::value<std::string>(&OPT::strConfigFileName)->default_value(APPNAME _T(".cfg")), "file name containing program options")
("export-type", boost::program_options::value<std::string>(&OPT::strExportType)->default_value(_T("ply")), "file type used to export the 3D scene (ply or obj)")
("archive-type", boost::program_options::value<unsigned>(&OPT::nArchiveType)->default_value(2), "project archive type: 0-text, 1-binary, 2-compressed binary")
("process-priority", boost::program_options::value<int>(&OPT::nProcessPriority)->default_value(-1), "process priority (below normal by default)")
("max-threads", boost::program_options::value<unsigned>(&OPT::nMaxThreads)->default_value(0), "maximum number of threads (0 for using all available cores)")
Expand Down Expand Up @@ -158,6 +160,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
}
if (OPT::strInputFileName.IsEmpty())
return false;
OPT::strExportType = OPT::strExportType.ToLower() == _T("obj") ? _T(".obj") : _T(".ply");

// initialize optional options
Util::ensureValidPath(OPT::strOutputFileName);
Expand Down Expand Up @@ -229,10 +232,10 @@ int main(int argc, LPCTSTR* argv)

// save the final mesh
scene.Save(baseFileName+_T(".mvs"), (ARCHIVE_TYPE)OPT::nArchiveType);
scene.mesh.Save(baseFileName+_T(".ply"));
scene.mesh.Save(baseFileName+OPT::strExportType);
#if TD_VERBOSE != TD_VERBOSE_OFF
if (VERBOSITY_LEVEL > 2)
scene.ExportCamerasMLP(baseFileName+_T(".mlp"), baseFileName+_T(".ply"));
scene.ExportCamerasMLP(baseFileName+_T(".mlp"), baseFileName+OPT::strExportType);
#endif
}

Expand Down
15 changes: 9 additions & 6 deletions libs/Common/MemFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

// D E F I N E S ///////////////////////////////////////////////////

#define MEMFILE_GROWSIZE 4096


namespace SEACAVE {

Expand Down Expand Up @@ -66,7 +64,7 @@ class GENERAL_API MemFile : public IOStream {
virtual bool setSize(size_f_t newSize) {
ASSERT(newSize >= 0);
if (newSize > m_sizeBuffer)
setMaxSize(newSize+MEMFILE_GROWSIZE);
setMaxSize(newSize);
m_size = newSize;
if (m_pos > m_size)
m_pos = m_size;
Expand All @@ -82,7 +80,12 @@ class GENERAL_API MemFile : public IOStream {
}

virtual bool setMaxSize(size_f_t newSize) {
ASSERT(newSize > 0);
ASSERT(newSize > m_sizeBuffer);
// grow by 50% or at least to minNewVectorSize
const size_f_t expoSize(m_sizeBuffer + (m_sizeBuffer>>1));
if (newSize < expoSize)
newSize = expoSize;
// allocate a larger chunk of memory, copy the data and delete the old chunk
BYTE* const tmp(m_buffer);
m_buffer = new BYTE[(size_t)newSize];
if (!m_buffer) {
Expand All @@ -107,8 +110,8 @@ class GENERAL_API MemFile : public IOStream {

virtual bool ensureSize(size_f_t extraSize) {
const size_f_t newSize = m_size + extraSize;
if (m_sizeBuffer < newSize)
return setMaxSize(newSize+MEMFILE_GROWSIZE);
if (newSize > m_sizeBuffer)
return setMaxSize(newSize);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libs/Common/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@ const Timer::Type Timer::ms_fTimeFactor = GetSysTimeFactor();

Timer::Type Timer::GetTimeFactor()
{
return ms_fTimeFactor * GetSysTime();
return ms_fTimeFactor;
}
/*----------------------------------------------------------------*/
19 changes: 12 additions & 7 deletions libs/IO/OBJ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ObjModel::MaterialLib::MaterialLib()
{
}

bool ObjModel::MaterialLib::Save(const String& prefix) const
bool ObjModel::MaterialLib::Save(const String& prefix, bool texLossless) const
{
std::ofstream out((prefix+".mtl").c_str());
if (!out.good())
Expand All @@ -60,17 +60,19 @@ bool ObjModel::MaterialLib::Save(const String& prefix) const
for (int_t i = 0; i < (int_t)materials.size(); ++i) {
const Material& mat = materials[i];
// save material description
if (mat.diffuse_name.IsEmpty())
const_cast<String&>(mat.diffuse_name) = prefix+"_"+mat.name+"_map_Kd.png";
out << "newmtl " << mat.name << "\n"
<< "Ka 1.000000 1.000000 1.000000" << "\n"
<< "Kd " << mat.Kd.r << " " << mat.Kd.g << " " << mat.Kd.b << "\n"
<< "Ks 0.000000 0.000000 0.000000" << "\n"
<< "Tr 1.000000" << "\n"
<< "illum 1" << "\n"
<< "Ns 1.000000" << "\n"
<< "map_Kd " << mat.diffuse_name << "\n";
<< "Ns 1.000000" << "\n";
// save material maps
if (mat.diffuse_map.empty())
continue;
if (mat.diffuse_name.IsEmpty())
const_cast<String&>(mat.diffuse_name) = prefix+"_"+mat.name+"_map_Kd."+(texLossless?"png":"jpg");
out << "map_Kd " << mat.diffuse_name << "\n";
const bool bRet(mat.diffuse_map.Save(mat.diffuse_name));
#ifdef OBJ_USE_OPENMP
#pragma omp critical
Expand Down Expand Up @@ -117,10 +119,13 @@ bool ObjModel::MaterialLib::Load(const String& fileName)

// S T R U C T S ///////////////////////////////////////////////////

bool ObjModel::Save(const String& fileName, unsigned precision) const
bool ObjModel::Save(const String& fileName, unsigned precision, bool texLossless) const
{
if (vertices.empty())
return false;

const String prefix(Util::getFileName(fileName));
if (!material_lib.Save(prefix))
if (!material_lib.Save(prefix, texLossless))
return false;

std::ofstream out((prefix + ".obj").c_str());
Expand Down
4 changes: 2 additions & 2 deletions libs/IO/OBJ.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class IO_API ObjModel {
MaterialLib();

// Saves the material lib to a .mtl file and all textures of its materials with the given prefix name
bool Save(const String& prefix) const;
bool Save(const String& prefix, bool texLossless=false) const;
// Loads the material lib from a .mtl file and all textures of its materials with the given file name
bool Load(const String& fileName);
};
Expand Down Expand Up @@ -93,7 +93,7 @@ class IO_API ObjModel {
ObjModel() {}

// Saves the obj model to an .obj file, its material lib and the materials with the given file name
bool Save(const String& fileName, unsigned precision=6) const;
bool Save(const String& fileName, unsigned precision=6, bool texLossless=false) const;
// Loads the obj model from an .obj file, its material lib and the materials with the given file name
bool Load(const String& fileName);

Expand Down

0 comments on commit b3cebcb

Please sign in to comment.