Open Mikkke46 opened 7 years ago
Hi! I got same issues, steps I made to resolve it. 1) Add to main cmake i.e. CMakeLists.txt in main folder "add_definitions(-fPIC)" 2) Do same steps as in instruction but, copy python folder first i.e. cp step. Then use "cmake -D BUILD_PYTHON_SUPPORT=ON .." instead of "cmake .." 3) .... 4) PROFIT!!!
Hello ,
When I try to cmake like this it gives error
$ cmake -D BUILD_PYTHON_SUPPORT=ON -DPYTHON_LIBRARY=/opt/local/lib/libpython2.7.dylib -DPYTHON_EXECUTABLE=/opt/local/bin/python -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ -DUSE_SYSTEM_BOOST=NO ..
-- WITH PYTHON SUPPORT: ON
-- Found OpenCV: /opt/local (found version "3.2.0")
-- OpenCV library status:
-- version: 3.2.0
-- libraries: opencv_calib3d;opencv_core;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_datasets;opencv_dnn;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_reg;opencv_rgbd;opencv_saliency;opencv_stereo;opencv_structured_light;opencv_surface_matching;opencv_text;opencv_tracking;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
-- include path: /opt/local/include;/opt/local/include/opencv
-- Found OpenCV: /opt/local (found version "3.2.0") found components: core
-- Found PythonInterp: /opt/local/bin/python (found suitable version "2.7.13", minimum required is "2.7")
-- Found PythonLibs: /opt/local/lib/libpython2.7.dylib (found suitable exact version "2.7.13")
-- Found PythonInterp: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 (found suitable version "3.6", minimum required is "3.5")
-- Found PythonLibs: /Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib (found suitable exact version "3.6.0")
CMake Warning at /opt/local/share/cmake-3.9/Modules/FindBoost.cmake:1564 (message):
No header defined for python-py27; skipping header check
Call Stack (most recent call first):
python/pyboostcvconverter/CMakeLists.txt:31 (find_package)
CMake Error at /opt/local/share/cmake-3.9/Modules/FindBoost.cmake:1877 (message):
Unable to find the requested Boost libraries.
Boost version: 1.59.0
Boost include path: /opt/local/include
Could not find the following Boost libraries:
boost_python-py27
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
python/pyboostcvconverter/CMakeLists.txt:31 (find_package)
-- Boost version: 1.59.0
-- Found the following Boost libraries:
-- python
Include dirs of boost: /opt/local/include
Libs of boost: /opt/local/lib/libboost_python-mt.dylib
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.7")
Include dirs of Python: /usr/include/python2.7
Libs of Python: /usr/lib/libpython2.7.dylib
-- Configuring incomplete, errors occurred!
Your have problem with Boost python library. Try to compile without -DPYTHON_LIBRARY=/opt/local/lib/libpython2.7.dylib -DPYTHON_EXECUTABLE=/opt/local/bin/python -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ -DUSE_SYSTEM_BOOST=NO ..
Initially I just used cmake -D BUILD_PYTHON_SUPPORT=ON ..
but it was giving same error, so I added other things
BTW Andrew's bgslibrary is compiling fine with -DBGS_PYTHON_SUPPORT=ON
flag
Ok so modified the python/CMakeLists.txt, modified line 31 to find_package(Boost REQUIRED COMPONENTS python)
and now cmake runs fine. But now getting linking error, BTW I'm on MACOS
[ 60%] Linking CXX shared library pbcvt.so
Undefined symbols for architecture x86_64:
"_PyCObject_AsVoidPtr", referenced from:
pbcvt::init_module_pbcvt() in python_module.cpp.o
"_PyCObject_Type", referenced from:
pbcvt::init_module_pbcvt() in python_module.cpp.o
"_PyErr_Format", referenced from:
.....
"__Py_NoneStruct", referenced from:
__GLOBAL__sub_I_pyboost_cv2_converter.cpp in pyboost_cv2_converter.cpp.o
pbcvt::fromMatToNDArray(cv::Mat const&) in pyboost_cv3_converter.cpp.o
pbcvt::matToNDArrayBoostConverter::convert(cv::Mat const&) in pyboost_cv3_converter.cpp.o
__GLOBAL__sub_I_pyboost_cv3_converter.cpp in pyboost_cv3_converter.cpp.o
__GLOBAL__sub_I_python_module.cpp in python_module.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [python/pyboostcvconverter/pbcvt.so] Error 1
make[1]: *** [python/pyboostcvconverter/CMakeFiles/pbcvt.dir/all] Error 2
make: *** [all] Error 2
Hi, I have some problem. I had tried the solutions above, but still the same. Any suggestion?
I solved! First, check if you clone pyboostcvconverter submodule. If this folder is empty, it's better clone this proyect with --recursive Second, edit line 44 in CMakeLists.txt and add -fPIC in ADD_DEFINITIONS Third, follow this commands:
apt-get install libboost-python-dev cmake -D BUILD_PYTHON_SUPPORT=ON .. mkdir python cp -r ../python/* python ../run_python_demo.sh
Install Boost library for Python sudo apt-get install libboost-python-dev
Clone the repo mkdir work cd work git clone --recursive https://github.com/andrewssobral/simple_vehicle_counting.git
Apply Patch cd simple_vehicle_counting patch -p1 <fix.diff git diff
Build cd build mkdir python cp -r ../python/* python cmake -D BUILD_PYTHON_SUPPORT=ON .. make
Run demo ../run_python_demo.sh
fix.diff diff --git a/CMakeLists.txt b/CMakeLists.txt index c205e27..5a5fd9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
IF (UNIX)
ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas -fPIC)
Hello Andrewssobral, i don't understand your step to install python API "/simple_vehicle_counting/build/cp -r ../python/* python/" . But i installed the program normally. When i run the "demo.py" i have always import errors. The script is on the same root paste of the packet analysis.
Do you have any idea to solve my problem, or what i am doing wrong?
ERROR:
Traceback (most recent call last): File "demo.py", line 4, in
import analysis
File "/home/miguel/simple_vehicle_counting/python/analysis/init.py", line 1, in
from _analysis import *
ImportError: No module named _analysis