Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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;

}