Chandler Squires
Chandler Squires

Reputation: 407

How to install OpenCV 3.0 with nonfree module?

I've tried a few times but most guides out there only tell you how to install it AFTER you've built OpenCV. I've had 2 unsuccessful attempts doing it this way and it's been a lot of work to do it this way, so

  1. I'd appreciate (and other people reading later might appreciate) basic instructions on how to install it (assuming dependencies are already there).
  2. Is it best to use git or build it yourself?
  3. What instructions must cmake be run with?
  4. Is it better to just build an old version (say 2.4.9) since version 3 is unreliable so far?

Upvotes: 5

Views: 17211

Answers (2)

Muthukumar
Muthukumar

Reputation: 11

FINALLY FOUND THE SOLUTION : First configured "opencv-3.4" with required stuff. I found easy to use cmake-gui to configure opencv-3.4 . During configuration enabled "OPENCV_ENABLE_NONFREE" by selecting the check box and other required stuff.

Compilation went well and make install also done. But i couldn't able to use the "nonfree" api like "xfeatures2d" which are used as part of my application.

After 6-7hrs of effort , finally found that we need to include "opencv-contrib" module during configuration of opencv.

Downloaded opencv-contrib-3.4.8 and given till "../opencv-contrib-3.4.8/modules" during opencv configuration in OPENCV_EXTRA_MODULE_PATH

Then did configure using cmake-gui , now i can see below configuration happening from "opencv_contrib" and extra modules has been picked by opencv. End of configure did make and make install.

xfeatures2d/boostdesc: Download: boostdesc_bgm.i
xfeatures2d/boostdesc: Download: boostdesc_bgm_bi.i
xfeatures2d/boostdesc: Download: boostdesc_bgm_hd.i
xfeatures2d/boostdesc: Download: boostdesc_binboost_064.i
xfeatures2d/boostdesc: Download: boostdesc_binboost_128.i
xfeatures2d/boostdesc: Download: boostdesc_binboost_256.i
xfeatures2d/boostdesc: Download: boostdesc_lbgm.i
xfeatures2d/vgg: Download: vgg_generated_48.i
xfeatures2d/vgg: Download: vgg_generated_64.i
xfeatures2d/vgg: Download: vgg_generated_80.i
xfeatures2d/vgg: Download: vgg_generated_120.i
data: Download: face_landmark_model.dat
..

How to test whether "nonfree" module included in opencv: login to your virtual environment and type "python" , then "import cv2" (should return without error) . Then finally did "surf=cv2.xfeatures2d.SURF_create()" which also returns with no error. This included that "nonfree" modules are added in opencv.

>$ python
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import cv2
>>> 
>>> surf=cv2.xfeatures2d.SURF_create()
>>> exit()

Thanks, Muthukumar

Upvotes: 1

GPPK
GPPK

Reputation: 6666

There is an answer by Berak on the opencv forums to this question, quoted below. Essentially you can pull it down from Git, add it during the cmake process and you are good to go.

Beraks answer:

in 3.0, SIFT and SURF were moved to the opencv_contrib repo

you will need to clone/fork/download that, and add that to your (main opencv) cmake;

cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules

then, after building,

#include "opencv2/xfeatures2d/nonfree.hpp"

Ptr<xfeatures2d::SURF> surf = xfeatures2d::SURF::create(); // note
extra namespace surf->detect(...); surf->compute(...);

don't forget to link to opencv_xfeatures2d(.lib)

Also, in answer to Question #4. OpenCV 3.0 is fine, I wouldn't say it was unreliable.

Upvotes: 7

Related Questions