mapillary / OpenSfM

Open source Structure-from-Motion pipeline
https://www.opensfm.org/
BSD 2-Clause "Simplified" License
3.4k stars 858 forks source link

Errors running "python setup.py build" and "bin/opensfm_run_all data/berlin"on MacOS High Sierra #272

Closed Wotipati closed 6 years ago

Wotipati commented 6 years ago

I got errors at running "python setup.py build" and "bin/opensfm_run_all data/berlin" on MacOS.

I am on MacOS High Sierra 10.13.2, Python 2.7.13 and Opencv 2.4.12.

Here is the full log:

➜  OpenSfM git:(master) python setup.py build
Configuring...
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
-- Looking for dgemm_
-- Looking for dgemm_ - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- A library with BLAS API found.
-- Looking for cheev_
-- Looking for cheev_ - found
-- A library with LAPACK API found.
-- A library with BLAS API found.
-- Found AMD library: /usr/local/lib/libamd.dylib
-- Found AMD header in: /usr/local/include
-- Found CAMD library: /usr/local/lib/libcamd.dylib
-- Found CAMD header in: /usr/local/include
-- Found COLAMD library: /usr/local/lib/libcolamd.dylib
-- Found COLAMD header in: /usr/local/include
-- Found CCOLAMD library: /usr/local/lib/libccolamd.dylib
-- Found CCOLAMD header in: /usr/local/include
-- Found CHOLMOD library: /usr/local/lib/libcholmod.dylib
-- Found CHOLMOD header in: /usr/local/include
-- Found CXSPARSE library: /usr/local/lib/libcxsparse.dylib
-- Found SuiteSparseQR library: /usr/local/lib/libspqr.dylib
-- Found SuiteSparseQR header in: /usr/local/include
-- Found Intel Thread Building Blocks (TBB) library: /usr/local/lib/libtbb.dylib, assuming SuiteSparseQR was compiled with TBB.
-- Found Intel Thread Building Blocks (TBB) Malloc library: /usr/local/lib/libtbbmalloc.dylib
-- Found SuiteSparse_config library: /usr/local/lib/libsuitesparseconfig.dylib
-- Found SuiteSparse_config header in: /usr/local/include
-- Found METIS library: /usr/local/lib/libmetis.dylib.
-- Found SuiteSparse: TRUE (found version "5.1.2")
-- Found Eigen: /usr/local/include/eigen3 (found version "3.3.4")
-- Found ceres: /usr/local/lib/libceres.dylib
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.1
-- Found Gflags: /usr/local/include
-- Found Glog: /usr/local/include
CMake Warning at /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:801 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:49 (find_package)

-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   python
Using boost/python/numpy.
CMake Warning at /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:801 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:59 (find_package)

CMake Warning at /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:801 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:59 (find_package)

-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   python
--   numpy
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.10")
-- Found PythonInterp: /Users/wotipati/anaconda3/envs/py27/bin/python2.7 (found version "2.7.13")
-- Found NumPy: version "1.9.3" /Users/wotipati/anaconda3/envs/py27/lib/python2.7/site-packages/numpy/core/include
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   csfm

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/wotipati/Desktop/Morishima_Lab/OpenSfM/cmake_build
Compiling extension...
Scanning dependencies of target akaze
Scanning dependencies of target gtest
Scanning dependencies of target vl
[  4%] Building CXX object CMakeFiles/gtest.dir/third_party/gtest/gmock_gtest_all.cc.o
[  4%] Building CXX object CMakeFiles/gtest.dir/third_party/gtest/gmock_main.cc.o
[  6%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/aib.c.o
[  8%] Building CXX object CMakeFiles/akaze.dir/third_party/akaze/lib/AKAZE.cpp.o
[ 10%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/array.c.o
[ 12%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/covdet.c.o
[ 14%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/dsift.c.o
/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/src/third_party/vlfeat/vl/dsift.c:265:26: warning: using floating point absolute
      value function 'fabsf' when argument is of integer type [-Wabsolute-value]
    *kerIter++ = (1.0F - fabsf(x) / binSize) *
                         ^
/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/src/third_party/vlfeat/vl/dsift.c:265:26: note: use function 'abs' instead
    *kerIter++ = (1.0F - fabsf(x) / binSize) *
                         ^~~~~
                         abs
[ 16%] Building CXX object CMakeFiles/akaze.dir/third_party/akaze/lib/fed.cpp.o
1 warning generated.
[ 18%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/fisher.c.o
[ 20%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/generic.c.o
[ 22%] Building CXX object CMakeFiles/akaze.dir/third_party/akaze/lib/nldiffusion_functions.cpp.o
[ 24%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/getopt_long.c.o
[ 26%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/gmm.c.o
[ 28%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/hikmeans.c.o
[ 30%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/hog.c.o
[ 32%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/homkermap.c.o
[ 34%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/host.c.o
[ 36%] Building CXX object CMakeFiles/akaze.dir/third_party/akaze/lib/utils.cpp.o
[ 38%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/ikmeans.c.o
[ 40%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/imopv.c.o
[ 42%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/imopv_sse2.c.o
[ 44%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/kdtree.c.o
[ 46%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/kmeans.c.o
[ 48%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/lbp.c.o
[ 51%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/liop.c.o
[ 53%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/mathop.c.o
[ 55%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/mathop_avx.c.o
[ 57%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/mathop_sse2.c.o
[ 59%] Linking CXX static library libakaze.a
[ 59%] Built target akaze
[ 63%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/pgm.c.o
[ 63%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/mser.c.o
/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/src/third_party/vlfeat/vl/pgm.c:236:6: warning: logical not is only applied to the
      left hand side of this comparison [-Wlogical-not-parentheses]
  if(! max_value >= 65536) {
     ^           ~~
/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/src/third_party/vlfeat/vl/pgm.c:236:6: note: add parentheses after the '!' to
      evaluate the comparison first
  if(! max_value >= 65536) {
     ^
       (                 )
/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/src/third_party/vlfeat/vl/pgm.c:236:6: note: add parentheses around left hand side
      expression to silence this warning
  if(! max_value >= 65536) {
     ^
     (          )
/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/src/third_party/vlfeat/vl/pgm.c:236:18: warning: comparison of constant 65536 with
      boolean expression is always false [-Wtautological-constant-out-of-range-compare]
  if(! max_value >= 65536) {
     ~~~~~~~~~~~ ^  ~~~~~
2 warnings generated.
[ 65%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/quickshift.c.o
[ 67%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/random.c.o
[ 69%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/rodrigues.c.o
[ 71%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/scalespace.c.o
[ 73%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/sift.c.o
[ 75%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/slic.c.o
[ 77%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/stringop.c.o
[ 79%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/svm.c.o
[ 81%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/svmdataset.c.o
[ 83%] Building C object CMakeFiles/vl.dir/third_party/vlfeat/vl/vlad.c.o
[ 85%] Linking C static library libvl.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libvl.a(mathop_avx.c.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libvl.a(mathop_avx.c.o) has no symbols
[ 85%] Built target vl
Scanning dependencies of target csfm
[ 87%] Building CXX object CMakeFiles/csfm.dir/csfm.cc.o
[ 89%] Linking CXX static library libgtest.a
[ 89%] Built target gtest
Scanning dependencies of target testing_main
[ 91%] Building CXX object CMakeFiles/testing_main.dir/testing_main.cc.o
[ 93%] Linking CXX static library libtesting_main.a
[ 93%] Built target testing_main
Scanning dependencies of target depthmap_test
[ 95%] Building CXX object CMakeFiles/depthmap_test.dir/depthmap_test.cc.o
[ 97%] Linking CXX executable depthmap_test
[ 97%] Built target depthmap_test
[100%] Linking CXX shared library /Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/csfm.so
[100%] Built target csfm
Building package
running build
running build_py
creating build
creating build/lib
creating build/lib/opensfm
copying opensfm/geo.py -> build/lib/opensfm
copying opensfm/config.py -> build/lib/opensfm
copying opensfm/geotag_from_gpx.py -> build/lib/opensfm
copying opensfm/reconstruction.py -> build/lib/opensfm
copying opensfm/align.py -> build/lib/opensfm
copying opensfm/sensors.py -> build/lib/opensfm
copying opensfm/transformations.py -> build/lib/opensfm
copying opensfm/log.py -> build/lib/opensfm
copying opensfm/dense.py -> build/lib/opensfm
copying opensfm/multiview.py -> build/lib/opensfm
copying opensfm/io.py -> build/lib/opensfm
copying opensfm/__init__.py -> build/lib/opensfm
copying opensfm/features.py -> build/lib/opensfm
copying opensfm/types.py -> build/lib/opensfm
copying opensfm/mesh.py -> build/lib/opensfm
copying opensfm/matching.py -> build/lib/opensfm
copying opensfm/dataset.py -> build/lib/opensfm
copying opensfm/context.py -> build/lib/opensfm
copying opensfm/exif.py -> build/lib/opensfm
copying opensfm/video.py -> build/lib/opensfm
copying opensfm/unionfind.py -> build/lib/opensfm
creating build/lib/opensfm/commands
copying opensfm/commands/compute_depthmaps.py -> build/lib/opensfm/commands
copying opensfm/commands/extract_metadata.py -> build/lib/opensfm/commands
copying opensfm/commands/export_openmvs.py -> build/lib/opensfm/commands
copying opensfm/commands/export_ply.py -> build/lib/opensfm/commands
copying opensfm/commands/undistort.py -> build/lib/opensfm/commands
copying opensfm/commands/create_submodels.py -> build/lib/opensfm/commands
copying opensfm/commands/__init__.py -> build/lib/opensfm/commands
copying opensfm/commands/mesh.py -> build/lib/opensfm/commands
copying opensfm/commands/export_visualsfm.py -> build/lib/opensfm/commands
copying opensfm/commands/match_features.py -> build/lib/opensfm/commands
copying opensfm/commands/reconstruct.py -> build/lib/opensfm/commands
copying opensfm/commands/export_geocoords.py -> build/lib/opensfm/commands
copying opensfm/commands/detect_features.py -> build/lib/opensfm/commands
copying opensfm/commands/create_tracks.py -> build/lib/opensfm/commands
copying opensfm/commands/align_submodels.py -> build/lib/opensfm/commands
creating build/lib/opensfm/large
copying opensfm/large/tools.py -> build/lib/opensfm/large
copying opensfm/large/__init__.py -> build/lib/opensfm/large
copying opensfm/large/metadataset.py -> build/lib/opensfm/large
copying opensfm/csfm.so -> build/lib/opensfm
creating build/lib/opensfm/data
copying opensfm/data/sensor_data.json -> build/lib/opensfm/data
running build_scripts
creating build/scripts-2.7
copying bin/opensfm_run_all -> build/scripts-2.7
copying and adjusting bin/opensfm -> build/scripts-2.7
changing mode of build/scripts-2.7/opensfm from 644 to 755

➜  OpenSfM git:(master) bin/opensfm_run_all data/berlin
Traceback (most recent call last):
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/bin/opensfm", line 10, in <module>
    from opensfm import commands
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/commands/__init__.py", line 2, in <module>
    import extract_metadata
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/commands/extract_metadata.py", line 5, in <module>
    from opensfm import dataset
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/dataset.py", line 11, in <module>
    from opensfm import io
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/io.py", line 10, in <module>
    from opensfm import features
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/features.py", line 7, in <module>
    import csfm
ImportError: dlopen(/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/csfm.so, 2): Symbol not found: __ZN2cv7imwriteERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERKNS_11_InputArrayERKNS0_6vectorIiNS4_IiEEEE
  Referenced from: /Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/csfm.so
  Expected in: flat namespace
 in /Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/csfm.so

Do you have any solutions?

paulinus commented 6 years ago

From

Symbol not found: __ZN2cv7imwriteERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERKNS_11_InputArrayERKNS0_6vectorIiNS4_IiEEEE

i guess that there is a problem with opencv linking. How did you install opencv?

Wotipati commented 6 years ago

Dear @paulinus. Thank you for your prompt reply.

Yes, I did install opencv using anaconda. Here is my environment.

I did run the scripts in this environment.

(py27) ➜  OpenSfM git:(master) conda list
# packages in environment at /Users/wotipati/anaconda3/envs/py27:
#
decorator                 4.2.1                    py27_0
intel-openmp              2018.0.0             h8158457_8
jpeg                      9b                   he5867d9_2
libgfortran               3.0.1                h93005f0_2
libpng                    1.6.30                        1
mkl                       2018.0.1             hfbd8650_4
networkx                  2.1                      py27_0
numpy                     1.9.3            py27hb3dd696_3
opencv                    2.4.12               np19py27_0    https://conda.binstar.org/jjhelmus
openssl                   1.0.2l                        0
pip                       9.0.1                    py27_1
pyproj                    1.9.5.1                  py27_0
python                    2.7.13                        0
readline                  6.2                           2
setuptools                27.2.0                   py27_0
sqlite                    3.13.0                        0
tk                        8.5.18                        0
wheel                     0.29.0                   py27_0
zlib                      1.2.8                         3

Best regards

paulinus commented 6 years ago

I've never tried the opencv version that comes with conda. Note that we use OpenCV from the C code also. I'm not sure how things get linked to the conda version. Can you check the directory that is being used to link opencv with the command

grep OpenCV cmake_build/CMakeCache.txt

?

Wotipati commented 6 years ago

These are results.

(py27) ➜  OpenSfM git:(master) grep OpenCV cmake_build/CMakeCache.txt

//Path where debug 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_DBG:PATH=
//Path where release 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_OPT:PATH=
OpenCV_CONFIG_PATH:FILEPATH=/Users/wotipati/anaconda3/envs/py27/share/OpenCV
//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=/Users/wotipati/anaconda3/envs/py27/share/OpenCV
//Path where debug OpenCV libraries are located
OpenCV_LIB_DIR_DBG:PATH=
//Path where release OpenCV libraries are located
OpenCV_LIB_DIR_OPT:PATH=
//ADVANCED property for variable: OpenCV_3RDPARTY_LIB_DIR_DBG
OpenCV_3RDPARTY_LIB_DIR_DBG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_3RDPARTY_LIB_DIR_OPT
OpenCV_3RDPARTY_LIB_DIR_OPT-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_CONFIG_PATH
OpenCV_CONFIG_PATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_LIB_DIR_DBG
OpenCV_LIB_DIR_DBG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_LIB_DIR_OPT
OpenCV_LIB_DIR_OPT-ADVANCED:INTERNAL=1
Wotipati commented 6 years ago

I did uninstall OpenCV installed with conda and installed OpenCV using homebrew.

brew install opencv

But, when I run "bin/opensfm_run_all data/berlin", I got import error about opencv. Here is the log.

$ OpenSfM git:(master) bin/opensfm_run_all data/berlin
Traceback (most recent call last):
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/bin/opensfm", line 10, in <module>
    from opensfm import commands
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/commands/__init__.py", line 2, in <module>
    import extract_metadata
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/commands/extract_metadata.py", line 5, in <module>
    from opensfm import dataset
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/dataset.py", line 9, in <module>
    import cv2
ImportError: No module named cv2 

$  OpenSfM git:(master) grep OpenCV cmake_build/CMakeCache.txt

//Path where debug 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_DBG:PATH=
//Path where release 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_OPT:PATH=
OpenCV_CONFIG_PATH:FILEPATH=/Users/wotipati/anaconda3/envs/py27/share/OpenCV
//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=/usr/local/share/OpenCV
//Path where debug OpenCV libraries are located
OpenCV_LIB_DIR_DBG:PATH=
//Path where release OpenCV libraries are located
OpenCV_LIB_DIR_OPT:PATH=
//Details about finding OpenCV
FIND_PACKAGE_MESSAGE_DETAILS_OpenCV:INTERNAL=[/usr/local][v3.4.0()]
//ADVANCED property for variable: OpenCV_3RDPARTY_LIB_DIR_DBG
OpenCV_3RDPARTY_LIB_DIR_DBG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_3RDPARTY_LIB_DIR_OPT
OpenCV_3RDPARTY_LIB_DIR_OPT-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_CONFIG_PATH
OpenCV_CONFIG_PATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_LIB_DIR_DBG
OpenCV_LIB_DIR_DBG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OpenCV_LIB_DIR_OPT
OpenCV_LIB_DIR_OPT-ADVANCED:INTERNAL=1

How do we use OpenCV from the C code ?

paulinus commented 6 years ago

Ok, to use the version of OpenCV, you need to do two things.

First, make sure that python can find the packages installed by brew. You can do it by running

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

After that, you should not get the ImportError: No module named cv2.

Second, rebuild OpenSfM so that the build uses the new OpenCV version. Run

cd path_to_OpenSfM
rm -rf build cmake_build   # make sure you are at the right path before running this.
python setup.py build
Wotipati commented 6 years ago

I'm sorry to bother you over and over.

Following your advice, I did

$ export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
$ cd path_to_OpenSfM
$ rm -rf build cmake_build 
$ python setup.py build

After that, I run

$ bin/opensfm_run_all data/berlin

But, I got import error about loky.

Here is the log.

 $  OpenSfM git:(master) grep OpenCV cmake_build/CMakeCache.txt

//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=/usr/local/share/OpenCV
//Details about finding OpenCV
FIND_PACKAGE_MESSAGE_DETAILS_OpenCV:INTERNAL=[/usr/local][v3.4.0()]

$   OpenSfM git:(master) bin/opensfm_run_all data/berlin
Traceback (most recent call last):
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/bin/opensfm", line 10, in <module>
    from opensfm import commands
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/commands/__init__.py", line 2, in <module>
    import extract_metadata
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/commands/extract_metadata.py", line 5, in <module>
    from opensfm import dataset
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/dataset.py", line 11, in <module>
    from opensfm import io
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/io.py", line 10, in <module>
    from opensfm import features
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/features.py", line 9, in <module>
    from opensfm import context
  File "/Users/wotipati/Desktop/Morishima_Lab/OpenSfM/opensfm/context.py", line 8, in <module>
    from loky import get_reusable_executor
ImportError: No module named loky

Then, I tried install loky

$ pip install loky

But I got Error.

$  OpenSfM git:(master) pip install loky
zsh: /Users/wotipati/anaconda3/envs/py27/bin/pip: bad interpreter: /anaconda/envs/py27/bin/python: no such file or directory
Failed to import the site module
Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x!
     PYTHONPATH is currently: "/usr/local/lib/python2.7/site-packages:"
     You should `unset PYTHONPATH` to fix this.

I can't find same probrem in your issue. Do you have any solutions?

Best regards,

Wotipati commented 6 years ago

I installed anaconda and Python 3 before.

So in my environment, default python interpreter is Python 3.

$ python
Python 3.6.3 |Anaconda, Inc.| (default, Oct  6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

On the other hand, since OpenSfM require Python 2, I set up virtual environment with anaconda. In this environment, I can use Python2.

(py27) $ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>

Is it likely to be the cause of the problem?

paulinus commented 6 years ago

When you tried installing loky, were you using python 2?

Wotipati commented 6 years ago

Dear @paulinus When I tried installing loky, I used Python 2.

I made a new virtual environment with anaconda and retried running OpenSfM. And then, it succeeded !!!

I'm sorry for confusing you. Thank you so much for your quick and polite response.

Here is my history. I couldn't understand the cause of that after all, but I hope it will help an anaconda user.

# After install OpenCV and Open GV ... 

$ conda create -n py27 python=2.7     # creating a new environment with specific version of Python
$ source activate py27                # activate the new environment

$ export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH  # add python path to use OpenCV and OpenGV

# install some packages using pip
# These packages are installed to activated environment(this case: py27) 

$ pip install loky
$ pip install networkx
$ pip install pyproj
$ pip install pyyaml
$ pip install exifread
$ pip install xmltodict

# Running
$ bin/opensfm_run_all data/berlin
paulinus commented 6 years ago

happy that it worked!