Ask Your Question
0

About OPENCV 3.4.1 headerfile

asked 2018-07-12 06:18:40 -0600

expire lee gravatar image

updated 2018-07-13 03:40:03 -0600

Hello. I'm rookie on opencv.(I started Opencv in 3days ago). So, I seek your Understanding although I'm not good at making a code.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp> 
#include <opencv2/flann/flann.hpp> 
#include <vector>

using namespace cv;

#define RED Scalar(0,0,255)

int main()
{
Mat img1=imread("model3.jpg",CV_LOAD_IMAGE_GRAYSCALE); 
Mat img2=imread("scene.jpg",CV_LOAD_IMAGE_GRAYSCALE);
assert(img1.data && img2.data);

SiftFeatureDetector detector(0.3); 
std::vector<KeyPoint> keypoint1, keypoint2; 

detector.detect(img1,keypoint1); 
detector.detect(img2,keypoint2);

Mat disp;
drawKeypoints(img1,keypoint1,disp,RED,DrawMatchesFlags::DRAW_RICH_KEYPOINTS); 
namedWindow("Keypoint"); imshow("Keypoint",disp);

SiftDescriptorExtractor extractor; 
Mat descriptor1, descriptor2; 
extractor.compute(img1,keypoint1,descriptor1); 
extractor.compute(img2,keypoint2,descriptor2);

waitKey();
return 0;
}

This code is example that I used for Opencv learning. And this is error message

Error (active)  E0020  identifier "SiftFeatureDetector" is undefined    error3_6
Error (active)  E0020  identifier "SiftDescriptorExtractor" is undefined    error3_6

As you see, the function SiftFeatureDetector and SiftDescriptionExtractor is undefined. I Searched Google to solve this problem, but it hasn't resolved yet. I Guess, the headerfile that defined SiftFeatureDetector and SiftDescriptionExtractor isn't exist in my PC. But I didn't find that.

So, Is there another problem except headerfile? And what can I do to solve this problem?

edit retag flag offensive close merge delete

Comments

helo, i removed your (useless) screenshot.

please EDIT your question again, and add a TEXT version of your code and the (exact) error messages, thank you !

(we'll help you with the formatting and such, but if noone can quote you correctly, noone will help you.)

berak gravatar imageberak ( 2018-07-12 06:26:05 -0600 )edit

but most likely, there are 2 problems:

  • you're using outdated opencv 2.4 code
  • you did not build the opencv libs with opencv_contrib
berak gravatar imageberak ( 2018-07-12 06:49:36 -0600 )edit
1

Oh, I didn't upload the error message because the language of IDE was not English. I'll change the language, and Edit the question

expire lee gravatar imageexpire lee ( 2018-07-13 03:18:33 -0600 )edit

thanks for the update !

berak gravatar imageberak ( 2018-07-13 03:53:20 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-07-13 04:01:05 -0600

berak gravatar image

updated 2018-07-13 04:02:02 -0600

SIFT and SURF were moved to opencv_contrib with opencv3, so you have to get the src of that and rebuild the opencv libs. please take a look at the readme for build instructions.

then the code changed since opencv2.4, you have to use it like:

#include "opencv2/xfeatures2d.hpp" // new module in opencv_contrib

Ptr<xfeatures2d::SIFT> sift = xfeatures2d::SIFT::create(0.3); // have to use Ptr and create()

std::vector<KeyPoint> keypoints; 
Mat descriptors;

sift->detectAndCompute(keypoints, Mat(), descriptors);

please also visit current tutorials

edit flag offensive delete link more

Comments

Oh, thank you! The example is from the my university C++ Professor. She uses openCV 2.4.9. But my visual studio version is 2017 so I downloaded 3.4.1. But... I didn't expect this situation... I'll Search the Github if similar situation happened for the next time.

expire lee gravatar imageexpire lee ( 2018-07-13 04:19:27 -0600 )edit

oh, i see. well, your professor is lame ;(

and indeed, there are no prebuilt VS2017 libs for the outdated 2.4 branch any more.

no idea, what to recommend, really.

you could:

  • use 3.4.1 (but then you need to rebuild, and most likely get in conflict with your professor)
  • build 2.4.x from src, and use that (no opencv_contrib needed, but you still have to build it
  • downgrade your VS, and use prebuild 2.4 libs from here
berak gravatar imageberak ( 2018-07-13 05:19:48 -0600 )edit
1

Thanks for the advice. I changed OPENCV ver 3.4.0. and installed the Cmake (I didn't know that Cmake is exist and What's the Cmake!). And rebuild the file(source and opencv_contrib) yesterday, then everything is being OK.

expire lee gravatar imageexpire lee ( 2018-07-15 02:18:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-12 06:18:40 -0600

Seen: 511 times

Last updated: Jul 13 '18