Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV SIFT & SURF

Hello I have some question related to the SIFT and SURF I installed opencv contrib via VCPKG (https://github.com/microsoft/vcpkg) for visual studio 2017 C++ But when I tried to run it, I got error like this :

OpenCV(3.4.3) Error: 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 cv::xfeatures2d::SIFT::create, file C:\vcpkg\buildtrees\opencv\src\3.4.3-98dbf13329\modules\xfeatures2d\src\sift.cpp, line 1207

Is there anyone had same problem with me and solved this problem?

This is my code :

include "pch.h"

include <opencv2 ximgproc.hpp="">

include <opencv2 opencv.hpp="">

include <opencv2 core="" core.hpp="">

include <opencv2 features2d="" features2d.hpp="">

include <opencv2 xfeatures2d.hpp="">

include <opencv2 xfeatures2d="" nonfree.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 calib3d="" calib3d.hpp="">

include <iostream>

include <stdio.h>

include <chrono>

using namespace std; using namespace cv; using namespace cv::xfeatures2d; int main() { Mat img_1 = imread("a6.jpg", IMREAD_GRAYSCALE); Mat img_2 = imread("a7.jpg", IMREAD_GRAYSCALE);

if (!img_1.data || !img_2.data)
{
    std::cout << " --(!) Error reading images " << std::endl; return -1;
}

//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400;

Ptr<SIFT> detector = xfeatures2d::SIFT::create(minHessian);


std::vector<KeyPoint> keypoints_1, keypoints_2;

detector->detect(img_1, keypoints_1);
detector->detect(img_2, keypoints_2);

//-- Draw keypoints
Mat img_keypoints_1; Mat img_keypoints_2;

drawKeypoints(img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
drawKeypoints(img_2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT);

//-- Show detected (drawn) keypoints
imshow("Keypoints 1", img_keypoints_1);
imshow("Keypoints 2", img_keypoints_2);

waitKey(0);

return 0;

}

OpenCV SIFT & SURF

Hello I have some question related to the SIFT and SURF I installed opencv contrib via VCPKG (https://github.com/microsoft/vcpkg) for visual studio 2017 C++ But when I tried to run it, I got error like this :

OpenCV(3.4.3) Error: 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 cv::xfeatures2d::SIFT::create, file C:\vcpkg\buildtrees\opencv\src\3.4.3-98dbf13329\modules\xfeatures2d\src\sift.cpp, line 1207

Is there anyone had same problem with me and solved this problem?

This is my code :

include "pch.h"

include <opencv2 ximgproc.hpp="">

include <opencv2 opencv.hpp="">

include <opencv2 core="" core.hpp="">

include <opencv2 features2d="" features2d.hpp="">

include <opencv2 xfeatures2d.hpp="">

include <opencv2 xfeatures2d="" nonfree.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 calib3d="" calib3d.hpp="">

include <iostream>

include <stdio.h>

include <chrono>

#include "pch.h"
#include <opencv2/ximgproc.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <iostream>
#include <stdio.h>
#include <chrono>
using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;
int main()
{
    Mat img_1 = imread("a6.jpg", IMREAD_GRAYSCALE);
    Mat img_2 = imread("a7.jpg", IMREAD_GRAYSCALE);

IMREAD_GRAYSCALE);

    if (!img_1.data || !img_2.data)
 {
     std::cout << " --(!) Error reading images " << std::endl; return -1;
 }

 //-- Step 1: Detect the keypoints using SURF Detector
 int minHessian = 400;

 Ptr<SIFT> detector = xfeatures2d::SIFT::create(minHessian);


 std::vector<KeyPoint> keypoints_1, keypoints_2;

 detector->detect(img_1, keypoints_1);
 detector->detect(img_2, keypoints_2);

 //-- Draw keypoints
 Mat img_keypoints_1; Mat img_keypoints_2;

 drawKeypoints(img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
 drawKeypoints(img_2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT);

 //-- Show detected (drawn) keypoints
 imshow("Keypoints 1", img_keypoints_1);
 imshow("Keypoints 2", img_keypoints_2);

 waitKey(0);

 return 0;
}

}