Ask Your Question
0

how to specify SURF parameters at FeatureDetector object ?

asked 2013-10-23 23:30:51 -0600

shige gravatar image

updated 2013-10-24 01:23:30 -0600

i try to get SURF descriptor with OpenCV 2.4.6.0, but FeatureDetector object cannot be specified SURF parameters. using FeatureDetector object, I can get descriptors Mat, then it contains unkown data.

i.e. -431602080.

about 35000's above data is contained in descriptors Mat. code is below,

void getDescriptors(char* image) {

///// load image
cv::Mat img = cv::imread(image, CV_LOAD_IMAGE_GRAYSCALE);
if(img.empty()) return;

///// detect keypoints /////
cv::vector<cv::KeyPoint> keyPoints; // keypoint vector

// create feature detector
cv::Ptr<cv::FeatureDetector> detector = cv::FeatureDetector::create("SURF");
if(detector.empty()) return;

// detect key points (feature point)
detector->detect(image, keyPoints);

///// compute descriptors /////
cv::Mat descriptor; // descriptors mat

// create descriptor extractor
cv::Ptr<cv::DescriptorExtractor> extractor = cv::DescriptorExtractor::create("SURF");
if(extractor.empty()) return;

// compute descriptor
extractor->compute(image, keyPoints, descriptor);

return descriptor;
}
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-10-23 23:36:24 -0600

Moster gravatar image

Thats actually pretty easy. You dont necessarily need to use a cv ptr.

SurfFeatureDetector detector(options here...)
edit flag offensive delete link more

Comments

thanks for response me ! I try it.

shige gravatar imageshige ( 2013-10-23 23:52:28 -0600 )edit
0

answered 2013-10-27 21:57:15 -0600

shige gravatar image

thanks Monster, I tried below code, and could get 128-dimention SURF descriptors. And contained -431602080. values is initialized Mat data.

void getDescriptors(char* image) {

///// load image
cv::Mat img = cv::imread(image, CV_LOAD_IMAGE_GRAYSCALE);
if(img.empty()) return;

///// detect keypoints /////
cv::vector<cv::KeyPoint> keyPoints; // keypoint vector

// create feature detector
cv::SurfFeatureDetector detector = cv::SurfFeatureDetector(400, 4, 2, true, false);

// detect key points (feature point)
detector->detect(image, keyPoints);

///// compute descriptors /////
cv::Mat descriptor; // descriptors mat

// create descriptor extractor
cv::Ptr<cv::DescriptorExtractor> extractor = cv::DescriptorExtractor::create("SURF");
if(extractor.empty()) return;

// compute descriptor
extractor->compute(image, keyPoints, descriptor);

return descriptor;

}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-23 23:30:51 -0600

Seen: 2,157 times

Last updated: Oct 27 '13