vislearn/ngransac

error: ‘findEssentialMat’ is not a member of ‘cv’

Closed this issue · 6 comments

/home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:7:2: warning: #warning "Including torch/torch.h for C++ extensions is deprecated. Please include torch/extension.h" [-Wcpp]
 #warning \
  ^~~~~~~
ngransac.cpp: In function ‘double find_essential_mat(at::Tensor, at::Tensor, int, int, float, at::Tensor, at::Tensor, at::Tensor)’:
ngransac.cpp:98:19: error: ‘findEssentialMat’ is not a member of ‘cv’
   cv::Mat E = cv::findEssentialMat(minSet1, minSet2, K, cv::RANSAC, 0.01, 1.0, mask);
                   ^~~~~~~~~~~~~~~~
ngransac.cpp:98:19: note: suggested alternative: ‘findFundamentalMat’
   cv::Mat E = cv::findEssentialMat(minSet1, minSet2, K, cv::RANSAC, 0.01, 1.0, mask);
                   ^~~~~~~~~~~~~~~~
                   findFundamentalMat
error: command 'gcc' failed with exit status 1
from setuptools import setup
from torch.utils.cpp_extension import CppExtension, BuildExtension
import os

opencv_inc_dir = '/home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/include/opencv4' # directory containing OpenCV header files
opencv_lib_dir = '/home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib' # directory containing OpenCV library files
Traceback (most recent call last):
  File "ngransac_demo.py", line 10, in <module>
    import ngransac
ImportError: /home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages/ngransac-0.0.0-py3.6-linux-x86_64.egg/ngransac.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN2cv5errorEiRKSsPKcS3_i
spple@spple:~/ngransac-master/ngransac$ ~/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/bin/python setup.py install
running install
running bdist_egg
running egg_info
writing ngransac.egg-info/PKG-INFO
writing dependency_links to ngransac.egg-info/dependency_links.txt
writing top-level names to ngransac.egg-info/top_level.txt
reading manifest file 'ngransac.egg-info/SOURCES.txt'
writing manifest file 'ngransac.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.6/ngransac.cpython-36m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
creating stub loader for ngransac.cpython-36m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/ngransac.py to ngransac.cpython-36.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying ngransac.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ngransac.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ngransac.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ngransac.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
__pycache__.ngransac.cpython-36: module references __file__
creating 'dist/ngransac-0.0.0-py3.6-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing ngransac-0.0.0-py3.6-linux-x86_64.egg
removing '/home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages/ngransac-0.0.0-py3.6-linux-x86_64.egg' (and everything under it)
creating /home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages/ngransac-0.0.0-py3.6-linux-x86_64.egg
Extracting ngransac-0.0.0-py3.6-linux-x86_64.egg to /home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages
ngransac 0.0.0 is already the active version in easy-install.pth

Installed /home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages/ngransac-0.0.0-py3.6-linux-x86_64.egg
Processing dependencies for ngransac==0.0.0
Finished processing dependencies for ngransac==0.0.0
spple@spple:~/ngransac-master/ngransac$ ~/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/bin/python
Python 3.6.7 | packaged by conda-forge | (default, Jul  2 2019, 02:18:42) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ngransac
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/spple/anaconda3/envs/pytorch1_1_0--py3_6--cuda9_0/lib/python3.6/site-packages/ngransac-0.0.0-py3.6-linux-x86_64.egg/ngransac.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail36_typeMetaDataInstance_preallocated_7E
>>> 

Your issues indicate that the linker cannot find some relevant libraries. First, make sure, the library path you provided in setup.py does indeed contain the libopencv .so files. Also, be aware that we developed the code with OpenCV 3.4 - if you want to use OpenCV 4, several things might be organized differently, causing diverse problems.

Ok, thank you for your answer.

@yangninghua Hello, have you solved your problem? I have met the same error as you. I am so confused about the undefined symbol error. Can you share your solution? Thank you very much!!! This is my error:
ImportError: /opt/anaconda3/envs/ngransac_env/lib/python3.6/ngransac.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail36_typeMetaDataInstance_preallocated_7E