Skip to content
Advertisement

Saliency Model – BMS (having error setting up)

I have downloaded a saliency model called BMS “Exploiting Surroundedness for Saliency Detection: A Boolean Map Approach” from here – available online. The code has been implemented and tested on Windows.

I am trying to set up on my machine (Linux Mint), by reading the instructions given inside the package in the file “readme.txt”. The file says that:

  1. Put the extracted files in a .
  2. Install OpenCV 2.40+.
  3. Go to /mex/ and specify the relevant OpenCV paths at the begining of the compile.m.
  4. Run compile.m in Matlab.
  5. Go to and run demo.m in Matlab.

I have set up the paths of OpenCV in compile.m file as:

opts.opencv_include_path    =   '-I/usr/local/include/opencv2/ -I/usr/local/include/'; % OpenCV include path
opts.opencv_lib_path        =   '/usr/lib/libopencv*'; % OpenCV lib path

But, this gives me the error:

Error using compile>pkg_config (line 74)
OpenCV include path not found: -I/usr/local/include/opencv2/ -I/usr/local/include/

Error in compile (line 34)
[cv_cflags,cv_libs] = pkg_config(opts);

I have checked the paths to OpenCV package, all is good, but in MATLAB, the compile.m is unable to detect the files. I have tried all the options available online, but nothing works.

Please help me run the code, thank you!

Advertisement

Answer

I suppose that OpenCV lib is missing in your system. You can install it in 9 steps:

  1. sudo apt-get install build-essential cmake pkg-config libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk-3-dev libatlas-base-dev gfortran
  2. wget https://github.com/opencv/opencv/archive/3.4.1.zip
  3. unzip opencv-3.4.1.zip
  4. cd opencv-3.4.1/
  5. wget https://github.com/Itseez/opencv_contrib/archive/3.4.1.zip
  6. unzip 3.4.1.zip
  7. mkdir -p build && cd build
  8. cmake -D WITH_TBB=OFF -D WITH_OPENMP=ON -D WITH_IPP=ON -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=OFF -D WITH_NVCUVID=OFF -D WITH_CUDA=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D WITH_CSTRIPES=ON -D WITH_OPENCL=ON -D WITH_MATLAB=ON -D WITH_LAPACK=ON -D WITH_PNG=ON -D WITH_FFMPEG=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_opencv_python_bindings_generator=ON -D PYTHON2_EXECUTABLE=/usr/bin/python2.7 -D PYTHON2_INCLUDE_DIR=/usr/include/python2.7 -D PYTHON2_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so -D PYTHON2_NUMPY_INCLUDE_DIRS=/usr/local/lib/python2.7/dist-packages/numpy/core/include -D PYTHON2_PACKAGES_PATH=lib/python2.7/dist-packages -D PYTHON3_EXECUTABLE=/usr/bin/python3 -D PYTHON3_INCLUDE_DIR=/usr/include/python3.5m -D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include PYTHON3_PACKAGES_PATH=lib/python3.5/dist-packages -D CMAKE_INSTALL_PREFIX=/usr/local/ -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.1/modules ..
  9. make -j 8
  10. sudo make install

After installing OpenCV, you can compile BMS. In Matlab, set the variables opts.opencv_include_path=/usr/local/include/opencv2/ and opts.opencv_lib_path=/usr/local/lib/.

WARNING: test if the commands above are enough for compiling in your machine. The following commands might not be necessary. I had some issues here (probably because I used Octave instead of Matlab). The issues were:

  • In file included from mexBMS.cpp:29:0: BMS.h:44:2: error: ‘vector’ does not name a type

You can solve this issue by adding the following statement in line 32 of BMS.h: using namespace std;

  • MxArray.cpp:484:55: error: invalid conversion from ‘const value_type* {aka const int*}’ to ‘mwIndex* {aka int*}’ [-fpermissive]

Add the following statements at line 484 of MxArray.cpp:

int* pointer; *pointer = si[0];

  • g++: error: BMS.obj: No such file or directory

Replace BMS.obj MxArray.obj by BMS.o MxArray.o at line 52 of `compile.m.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement