简体   繁体   English

尽管设置了标志 DOPENCV_ENABLE_NONFREE=ON,但运行 opencv 获得专利的 SIFT 和 SURF 的问题

[英]Problem to run opencv patented SIFT and SURF although flag DOPENCV_ENABLE_NONFREE=ON is set

I'm currently working on opencv vers.我目前正在研究 opencv 版本。 4.5.1 and I want to use SIFT and SURF but I run into the well known problem that they're patented. 4.5.1我想使用 SIFT 和 SURF 但我遇到了众所周知的问题,即它们已获得专利。 I already know that under 4.5.1 there is the possibility to use the flags DOPENCV_ENABLE_NONFREE=ON and DBUILD_opencv_xfeatures2d=ON .我已经知道在4.5.1下可以使用标志DOPENCV_ENABLE_NONFREE=ONDBUILD_opencv_xfeatures2d=ON But when I use the following command for cmake但是当我对 cmake 使用以下命令时

cmake -DOPENCV_EXTRA_MODULES_PATH=home/myname/opencv_build/opencv_contrib/modules/xfeatures2d/src -DOPENCV_ENABLE_NONFREE=ON -DBUILD_opencv_xfeatures2d=ON .

I run into the following problem:我遇到以下问题:

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "4.5.1") 
-- OpenCV library status:
--     config: /usr/local/lib/cmake/opencv4
--     version: 4.5.1
--     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_mcc;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_wechat_qrcode;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
--     include path: /usr/local/include/opencv4
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_opencv_xfeatures2d
    OPENCV_ENABLE_NONFREE
    OPENCV_EXTRA_MODULES_PATH


-- Build files have been written to: /home/myname/Dokumente/test/project

The output in clion is: clion中的output是:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.1-dev) /home/myname/opencv_build/opencv_contrib/modules/xfeatures2d/src/surf.cpp:1027: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'

For hours I have been desperately trying to get the program running and the algorithms (SIFT, SURF) to be executed and have now reached the point where I (very, very reluctantly) want to downgrade opencv.几个小时以来,我一直在拼命尝试让程序运行并执行算法(SIFT、SURF),现在我(非常非常不情愿地)想要降级 opencv。 (I simultaneously need this version of opencv for another project). (我同时需要这个版本的 opencv 用于另一个项目)。

Does anyone have a tip for me on how I can still get the algorithms under 5.4.1 to work here.有没有人告诉我如何让 5.4.1 下的算法在这里工作。 And otherwise, which OpenCV version (c++) should I use in order to use SIFT and SURF without problems.否则,我应该使用哪个 OpenCV 版本(c++)才能毫无问题地使用 SIFT 和 SURF。 I did not find anything how I can downgrade the version in case of c++.在 c++ 的情况下,我没有发现如何降级版本。 All I found was in case of python.我发现的只是 python 的情况。

Help would be very much appreciated!!!帮助将不胜感激!!!

Build OpenCV with the following command:使用以下命令构建 OpenCV:

cmake -D CMAKE_BUILD_TYPE=Release \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D OPENCV_EXTRA_MODULES_PATH=path/to/opencv_contrib/modules \
      -D OPENCV_ENABLE_NONFREE=ON \
      path/to/opencv

There is no need to build OpenCV again to use SIFT algorithm, just use a version above 4.4.0.使用SIFT算法无需再次构建OpenCV,使用4.4.0以上的版本即可。

Release highlights:发布亮点:

for python:对于 python:

pip install opencv-python==4.4.0.46

And access it directly ( no more xfeatures2d )并直接访问它( no more xfeatures2d

import cv2
sift = cv2.SIFT_create()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM