SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java

后端 未结 3 1413
眼角桃花
眼角桃花 2020-12-14 23:46

I am using OpenCV 3.0 (the latest version) in Java, but when I use SURF algorithm or SIFT algorithm it doesn\'t work and throws Exception which says: OpenCV Error: Bad

3条回答
  •  抹茶落季
    2020-12-15 00:37

    That is because they are not free in newer versions of OpenCV (3+). I faced that problem few time ago. You have to:

    1. Download OpenCV (if you have not)
    2. Download the nonfree part from opencv github repo
    3. Generate the makefiles with cmake -DBUILD_SHARED_LIBS=OFF specifying the nonfree part with DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules option and build with make -j8 (or whatever Java version you use)
    4. Edit features2d_manual.hpp file, including opencv2/xfeatures2d.hpp and including the necessary code for SIFT and SURF case, which are commented and not defined: fd=xfeatures2d::SIFT::create(); for SIFT descriptor andde = xfeatures2d::SIFT::create(); for SIFT extractor. Do the same for SURF if you want to use it too.

    I wrote this post explaining step by step how to compile the nonfree OpenCV part in order to use privative tools like SIFT or SURF. Compile OpenCV nonfree part

提交回复
热议问题