spmallick / learnopencv

Learn OpenCV : C++ and Python Examples
https://www.learnopencv.com/
21.32k stars 11.61k forks source link

Build instructions for the Background-Subtraction project no longer work #636

Open allComputableThings opened 2 years ago

allComputableThings commented 2 years ago

The build/cmake instructions for the Background-Subtraction project no longer work (the BGS dependency part) https://github.com/spmallick/learnopencv/tree/master/Background-Subtraction

(p37_default) sir@dublin:~/soft/bgslibrary/build$ cmake -D BGS_PYTHON_SUPPORT=ON  -D CMAKE_INSTALL_PREFIX=/usr/local   -D OpenCV_DIR=~/opencv/build   -D PYTHON_EXECUTABLE=`which python`  ..
-- 
-- BGS_PYTHON_SUPPORT: ON
-- BGS_PYTHON_ONLY:    OFF
-- BGS_CORE_STATIC:    OFF
-- PYTHON VERSION: 3
-- 
-- OpenCV library status:
--     version: 4.3.0
--     libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_datasets;opencv_dnn_objdetect;opencv_dnn_superres;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hfs;opencv_img_hash;opencv_intensity_transform;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_quality;opencv_rapid;opencv_reg;opencv_rgbd;opencv_saliency;opencv_shape;opencv_stereo;opencv_structured_light;opencv_superres;opencv_surface_matching;opencv_text;opencv_tracking;opencv_videostab;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
--     include path: /home/sir/opencv/build;/home/sir/opencv/include;/home/sir/opencv/modules/core/include;/home/sir/opencv/modules/flann/include;/home/sir/opencv/modules/imgproc/include;/home/sir/opencv_contrib/modules/intensity_transform/include;/home/sir/opencv/modules/ml/include;/home/sir/opencv_contrib/modules/phase_unwrapping/include;/home/sir/opencv/modules/photo/include;/home/sir/opencv_contrib/modules/plot/include;/home/sir/opencv_contrib/modules/quality/include;/home/sir/opencv_contrib/modules/reg/include;/home/sir/opencv_contrib/modules/surface_matching/include;/home/sir/opencv_contrib/modules/xphoto/include;/home/sir/opencv/modules/dnn/include;/home/sir/opencv_contrib/modules/dnn_superres/include;/home/sir/opencv/modules/features2d/include;/home/sir/opencv_contrib/modules/freetype/include;/home/sir/opencv_contrib/modules/fuzzy/include;/home/sir/opencv/modules/gapi/include;/home/sir/opencv_contrib/modules/hfs/include;/home/sir/opencv_contrib/modules/img_hash/include;/home/sir/opencv/modules/imgcodecs/include;/home/sir/opencv_contrib/modules/line_descriptor/include;/home/sir/opencv_contrib/modules/saliency/include;/home/sir/opencv_contrib/modules/text/include;/home/sir/opencv/modules/videoio/include;/home/sir/opencv/modules/calib3d/include;/home/sir/opencv_contrib/modules/datasets/include;/home/sir/opencv/modules/highgui/include;/home/sir/opencv/modules/objdetect/include;/home/sir/opencv_contrib/modules/rapid/include;/home/sir/opencv_contrib/modules/rgbd/include;/home/sir/opencv_contrib/modules/shape/include;/home/sir/opencv_contrib/modules/structured_light/include;/home/sir/opencv/modules/ts/include;/home/sir/opencv/modules/video/include;/home/sir/opencv_contrib/modules/videostab/include;/home/sir/opencv_contrib/modules/xfeatures2d/include;/home/sir/opencv_contrib/modules/ximgproc/include;/home/sir/opencv_contrib/modules/xobjdetect/include;/home/sir/opencv_contrib/modules/aruco/include;/home/sir/opencv_contrib/modules/bgsegm/include;/home/sir/opencv_contrib/modules/bioinspired/include;/home/sir/opencv_contrib/modules/ccalib/include;/home/sir/opencv_contrib/modules/dnn_objdetect/include;/home/sir/opencv_contrib/modules/dpm/include;/home/sir/opencv_contrib/modules/face/include;/home/sir/opencv_contrib/modules/optflow/include;/home/sir/opencv/modules/stitching/include;/home/sir/opencv_contrib/modules/superres/include;/home/sir/opencv_contrib/modules/tracking/include;/home/sir/opencv_contrib/modules/stereo/include

-- pybind11 v2.3.dev1
-- 
-- Python library status:
--     executable: /home/sir/venv/p37_default/bin/python
--     library: /usr/lib/x86_64-linux-gnu/libpython3.7m.so
--     include path: /usr/include/python3.7m
-- NUMPY_INCLUDE_DIR: /home/sir/venv/p37_default/lib/python3.7/site-packages/numpy/core/include

-- Bulding bgslibrary_core SHARED
-- 
-- The bgslibrary python package will be installed at: lib/python3.7/site-packages

-- You might need to run:
-- $ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
-- $ export LD_LIBRARY_PATH
-- after 'make install' to avoid error while loading libbgslibrary_core

-- Configuring done
-- Generating done
-- Build files have been written to: /home/sir/soft/bgslibrary/build
% make -j4

/home/sir/soft/bgslibrary/src/algorithms/LBSP/BackgroundSubtractorLBSP_.h:30:22: warning: ‘virtual void bgslibrary::algorithms::lbsp::BackgroundSubtractorLBSP_::initialize(const cv::Mat&)’ was hidden [-Woverloaded-virtual]
         virtual void initialize(const cv::Mat& oInitImg);
                      ^~~~~~~~~~
In file included from /home/sir/soft/bgslibrary/src/algorithms/PAWCS.h:4:0,
                 from /home/sir/soft/bgslibrary/src/algorithms/algorithms.h:42,
                 from /home/sir/soft/bgslibrary/src/FrameProcessor.h:7,
                 from /home/sir/soft/bgslibrary/src/VideoAnalysis.h:7,
                 from /home/sir/soft/bgslibrary/src/VideoAnalysis.cpp:1:
/home/sir/soft/bgslibrary/src/algorithms/LBSP/BackgroundSubtractorPAWCS.h:44:22: warning:   by ‘virtual void bgslibrary::algorithms::lbsp::BackgroundSubtractorPAWCS::initialize(const cv::Mat&, const cv::Mat&)’ [-Woverloaded-virtual]
         virtual void initialize(const cv::Mat& oInitImg, const cv::Mat& oROI);
                      ^~~~~~~~~~
[ 98%] Building CXX object CMakeFiles/bgs_python.dir/wrapper/python/ndarray_converter.cpp.o
[ 99%] Linking CXX executable bgslibrary
[ 99%] Built target bgslibrary
[100%] Linking CXX shared module pybgs.cpython-37m-x86_64-linux-gnu.so
[100%] Built target bgs_python
$ python demo.py 
Traceback (most recent call last):
  File "demo.py", line 3, in <module>
    import pybgs as bgs
ModuleNotFoundError: No module named 'pybgs'
~/soft/bgslibrary$ find . -name "*pybgs*"
./pybgs.egg-info
./build/pybgs.cpython-37m-x86_64-linux-gnu.so
./dist/pybgs-3.0.0.post2-py3.7-linux-x86_64.egg

I skipped this step as instructed (the .so was already built), and I'm using pip, no pyenv available.

PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --force 3.7.5

Is there some install step missed? Not sure what pyenv does.

The BGS project's build instructions also fail:

https://github.com/andrewssobral/bgslibrary/wiki/Installation-instructions-Ubuntu-or-OSX

allComputableThings commented 2 years ago

What did work for me:

git clone --recursive https://github.com/andrewssobral/bgslibrary.git
cd bgslibrary
OpenCV_DIR=../opencv/build pip install .