Skip to content

Commit

Permalink
Replaced GSL simplex/lmfit with nlopt optimizer
Browse files Browse the repository at this point in the history
Replaced image loading routines with CImg. Now PPMs are supported properly, with optional support for PNG and TIFF
Replaced BLAS/LAPACK with Eigen
Updated internal jpeg library and miniBoost
CMake-system now supports system boost, jpeg and other libraries if available.
Replaced pthread with tinycthread to get rid of pthread.dll on Windows
  • Loading branch information
rhiestan committed Jan 16, 2015
1 parent 851aaf4 commit 26cf8e4
Show file tree
Hide file tree
Showing 6,319 changed files with 402,342 additions and 1,338,330 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Main modification:
- cross platform compilation Linux, Windows => CMake build system generator.
- added bug fix from Nghia Ho.
- make PLY, PSET, PATCH export faster and optional.
- Replaced GSL simplex/lmfit with nlopt optimizer
- Replaced image loading routines with CImg. Now PPMs are supported properly, with optional support for PNG and TIFF
- Replaced BLAS/LAPACK with Eigen
- Updated internal jpeg library and miniBoost
- CMake-system now supports system boost, jpeg and other libraries if available.
- Replaced pthread with tinycthread to get rid of pthread.dll on Windows

Authors :
[Original code author] Yasutaka Furukawa http://www.cs.washington.edu/homes/furukawa/
Expand Down
15 changes: 12 additions & 3 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ Date : 13 July 2011

Windows => Use precompiled binary, or compile it with VS2008/2010 (Express or pro, Pro will allow you to enable Opemp in CMVS)
=> Use CMake GUI in order to generate the Visual Studio project file (in ./program you will find the main CMakeLists.txt).
=> To compile windows 64 binary => edit the ./program/CMakeLists.txt and set WIN64_PTHREAD to true

Linux => use makefile in program/main.
Setup in makefile the library path to clapack directory if necessary (in order find clapack/clapack.h, clapack/f2c.h, and graclus at compile time)

Or use CMake build system :
=> Install the following libraries : jpeg gsl lapack boost boost-graph pthread
=> Install the following libraries : jpeg boost boost-graph
$ mkdir OutputLinux
$ cd OutputLinux
$ cmake . ..
Expand All @@ -51,3 +49,14 @@ What have been done on native Yasutaka Furukawa source code :
- memoize pow(2,X)
- Change GSL simplex to lmfit.

- Replaced GSL simplex/lmfit with nlopt optimizer

- Replaced image loading routines with CImg. Now PPMs are supported properly, with optional support for PNG and TIFF

- Replaced BLAS/LAPACK with Eigen

- Updated internal jpeg library and miniBoost

- CMake-system now supports system boost, jpeg and other libraries if available.

- Replaced pthread with tinycthread to get rid of pthread.dll on Windows
Binary file modified binariesWin-Linux/Win32-VS2010/cmvs.exe
Binary file not shown.
Binary file modified binariesWin-Linux/Win32-VS2010/genOption.exe
Binary file not shown.
Binary file modified binariesWin-Linux/Win32-VS2010/pmvs2.exe
Binary file not shown.
Binary file removed binariesWin-Linux/Win32-VS2010/pthread.dll
Binary file not shown.
Binary file modified binariesWin-Linux/Win64-VS2010/cmvs.exe
Binary file not shown.
Binary file modified binariesWin-Linux/Win64-VS2010/genOption.exe
Binary file not shown.
Binary file removed binariesWin-Linux/Win64-VS2010/msvcr80.dll
Binary file not shown.
Binary file modified binariesWin-Linux/Win64-VS2010/pmvs2.exe
Binary file not shown.
Binary file removed binariesWin-Linux/Win64-VS2010/pthreadVC2.dll
Binary file not shown.
Binary file added binariesWin-Linux/mac_osx_fat/cmvs
Binary file not shown.
Binary file added binariesWin-Linux/mac_osx_fat/genOption
Binary file not shown.
Binary file added binariesWin-Linux/mac_osx_fat/pmvs2
Binary file not shown.
110 changes: 65 additions & 45 deletions program/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,86 @@
# Second draft 24 sept 2010
# Third draft (linux) 12 oct 2010
# 28 july 2014 Make VisualStudio Win32/Win64 detection automatic
# 15.01.2015 Added tinycthread, nlopt, CImg, removed BLAS, LAPACK, GSL, lmfit, winpthread (R. Hiestand)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(CMVS-PMVS2 C CXX)

IF(WIN32)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/program/base/image
${CMAKE_SOURCE_DIR}/program/base/numeric
${CMAKE_SOURCE_DIR}/program/base/pmvs
${CMAKE_SOURCE_DIR}/thirdParty/
${CMAKE_SOURCE_DIR}/thirdParty/graclus1.2/metisLib
${CMAKE_SOURCE_DIR}/thirdParty/nlopt-2.4.2/api
${CMAKE_SOURCE_DIR}/thirdParty/cimg
${CMAKE_SOURCE_DIR}/thirdParty/tinycthread
)

SET(ADDITIONAL_WIN_INCLUDES
./thirdParty/miniBoost
./thirdParty/pthread/include
./thirdParty/jpeg)
# Threads
FIND_PACKAGE(Threads REQUIRED)
SET(PMVS_LIBRARIES ${PMVS_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

ENDIF(WIN32)
# Eigen
SET( EIGEN3_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdParty/Eigen )
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${EIGEN3_INCLUDE_DIR}/cmake" )
FIND_PACKAGE(Eigen3 3.0.0 REQUIRED)
MESSAGE("Found Eigen ${EIGEN3_VERSION}")
INCLUDE_DIRECTORIES( ${EIGEN3_INCLUDE_DIR} )

INCLUDE_DIRECTORIES(
./program/base/image
./program/base/numeric
./program/base/pmvs
# Boost
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost)
IF(Boost_FOUND)
message("Using system boost library: ${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ELSE(Boost_FOUND)
message("No system boost library found, using internal version")
SET(PMVS_USE_INTERNAL_BOOST TRUE)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/thirdParty/miniBoost)
ENDIF(Boost_FOUND)

./thirdParty/
./thirdParty/gsl-1.13/include
# http://eris.liralab.it/iCub/downloads/packages/windows/msvc9/
./thirdParty/graclus1.2/metisLib
./thirdParty/lmfit-3.2/lib
${ADDITIONAL_WIN_INCLUDES}
)

IF(WIN32)
# JPEG
FIND_PACKAGE(JPEG)
IF(JPEG_FOUND)
message("Using system JPEG library: ${JPEG_LIBRARIES}")
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
SET(PMVS_LIBRARIES ${PMVS_LIBRARIES} ${JPEG_LIBRARIES})
ELSE(JPEG_FOUND)
message("No system JPEG library found, using internal version")
SET(PMVS_USE_INTERNAL_JPEG TRUE)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/thirdParty/jpeg)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/thirdParty/jpeg) # For jconfig.h
SET(PMVS_LIBRARIES ${PMVS_LIBRARIES} jpeg)
ENDIF(JPEG_FOUND)

IF (${CMAKE_CL_64})
SET(WIN64_PTHREAD true)
ELSE (${CMAKE_CL_64})
SET(WIN64_PTHREAD false)
ENDIF (${CMAKE_CL_64})

IF(WIN64_PTHREAD)
SET(PTHREAD_LIB ${CMAKE_SOURCE_DIR}/thirdParty/pthreadVC2.lib)
ELSE(WIN64_PTHREAD)
SET(PTHREAD_LIB ${CMAKE_SOURCE_DIR}/thirdParty/pthread.lib)
ENDIF(WIN64_PTHREAD)
SET(PRECOMPILED_LIBS ${PTHREAD_LIB})
# ZLIB
#FIND_PACKAGE(ZLIB REQUIRED)
#INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})

ELSE(WIN32)
# PNG
FIND_PACKAGE(PNG)
IF(PNG_FOUND)
message("PNG library found, enabling support: ${PNG_LIBRARIES}")
ADD_DEFINITIONS(-DPMVS_HAVE_PNG)
INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIRS})
SET(PMVS_LIBRARIES ${PMVS_LIBRARIES} ${PNG_LIBRARIES})
ENDIF(PNG_FOUND)

FIND_LIBRARY(LAPACK_LIB NAMES lapack)
FIND_LIBRARY(GSL_LIB NAMES gsl)
FIND_LIBRARY(GSLCBLAS_LIB NAMES gslcblas)
FIND_PACKAGE(JPEG REQUIRED)
FIND_PACKAGE(BLAS REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Boost REQUIRED)
SET(PRECOMPILED_LIBS
${JPEG_LIBRARY}
${LAPACK_LIB}
${GSL_LIB}
${GSLCBLAS_LIB}
${BLAS_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
# TIFF
FIND_PACKAGE(TIFF)
IF(TIFF_FOUND)
message("TIFF library found, enabling support: ${TIFF_LIBRARIES}")
ADD_DEFINITIONS(-DPMVS_HAVE_TIFF)
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
SET(PMVS_LIBRARIES ${PMVS_LIBRARIES} ${TIFF_LIBRARIES})
ENDIF(TIFF_FOUND)

ENDIF (WIN32)

ADD_SUBDIRECTORY(base)
ADD_SUBDIRECTORY(main)
Expand Down
25 changes: 12 additions & 13 deletions program/base/cmvs/bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace CMVS;
Cbundle::Cbundle(void) {
m_CPU = 8;
m_junit = 100;
pthread_rwlock_init(&m_lock, NULL);
mtx_init(&m_lock, mtx_plain | mtx_recursive);
m_debug = 0;
m_puf = NULL;
m_ptree = NULL;
Expand Down Expand Up @@ -665,7 +665,7 @@ void Cbundle::mergeSfMPThread(void) {
const int tenth = (int)m_coords.size() / 10;
while (1) {
int pid = -1;
pthread_rwlock_wrlock(&m_lock);
mtx_lock(&m_lock);
if (!m_jobs.empty()) {
pid = m_jobs.front();
m_jobs.pop_front();
Expand All @@ -675,7 +675,7 @@ void Cbundle::mergeSfMPThread(void) {
if (m_count % tenth == 0)
cerr << '*' << flush;
++m_count;
pthread_rwlock_unlock(&m_lock);
mtx_unlock(&m_lock);
if (pid == -2)
continue;
if (pid == -1)
Expand Down Expand Up @@ -704,7 +704,7 @@ void Cbundle::mergeSfMPThread(void) {
}

// Now lock and try to register
pthread_rwlock_wrlock(&m_lock);
mtx_lock(&m_lock);
// If the main one is removed, over... waste.
if (m_merged[pid] == 0) {
m_merged[pid] = 1;
Expand All @@ -716,13 +716,13 @@ void Cbundle::mergeSfMPThread(void) {
}
}
}
pthread_rwlock_unlock(&m_lock);
mtx_unlock(&m_lock);
}
}

void* Cbundle::mergeSfMPThreadTmp(void* arg) {
int Cbundle::mergeSfMPThreadTmp(void* arg) {
((Cbundle*)arg)->mergeSfMPThread();
return NULL;
return 0;
}

void Cbundle::mergeSfMP(void) {
Expand Down Expand Up @@ -764,12 +764,11 @@ void Cbundle::mergeSfMP(void) {
m_jobs.push_back(order[p]);

m_count = 0;
vector<pthread_t> threads(m_CPU);
vector<thrd_t> threads(m_CPU);
for (int c = 0; c < m_CPU; ++c)
pthread_create(&threads[c], NULL,
mergeSfMPThreadTmp, (void*)this);
thrd_create(&threads[c], &mergeSfMPThreadTmp, (void*)this);
for (int c = 0; c < m_CPU; ++c)
pthread_join(threads[c], NULL);
thrd_join(threads[c], NULL);

int newpnum = 0;
// Mapping from m_pnum to new id for reps
Expand Down Expand Up @@ -920,12 +919,12 @@ void Cbundle::setCluster(const int p) {
m_sfms2[p].m_satisfied = 1;

// update m_lacks
pthread_rwlock_wrlock(&m_lock);
mtx_lock(&m_lock);
for (int i = 0; i < (int)m_visibles[p].size(); ++i) {
const int image = m_visibles[p][i];
--m_lacks[image];
}
pthread_rwlock_unlock(&m_lock);
mtx_unlock(&m_lock);
}
}

Expand Down
6 changes: 3 additions & 3 deletions program/base/cmvs/bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "../stann/sfcnn.hpp"
#include "../numeric/mat3.h"
#include "../image/photoSetS.h"
#include <pthread.h>
#include "tinycthread.h"

namespace CMVS {

Expand Down Expand Up @@ -152,7 +152,7 @@ class Cbundle {
void mergeSfM(void);
void mergeSfMP(void);
void mergeSfMPThread(void);
static void* mergeSfMPThreadTmp(void* arg);
static int mergeSfMPThreadTmp(void* arg);

std::vector<char> m_merged;

Expand Down Expand Up @@ -259,7 +259,7 @@ class Cbundle {
//----------------------------------------------------------------------
// Threads
int m_CPU;
pthread_rwlock_t m_lock;
mtx_t m_lock;
std::list<int> m_jobs;
int m_junit;
int m_thread;
Expand Down
1 change: 1 addition & 0 deletions program/base/image/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include "../numeric/vec4.h"
#include "../numeric/mat4.h"
#include "../numeric/mat3.h"
Expand Down
Loading

0 comments on commit 26cf8e4

Please sign in to comment.