密集的SIFT关键点&使用vlfeat进行描述符提取

时间:2014-09-28 09:51:42

标签: c++ opencv image-processing computer-vision vlfeat

我目前正在使用vlfeat的Dense SIFT。但我只得到一个关键点&描述符从代码中输出。但返回的关键点数量更多。如何提取所有关键点&描述符。

Descriptor也是单个值,它应该是128 X N.

代码如下。

vlkeypoints大小只有一个。如何提取所有关键点?

    img = imread("filename.jpg");

     // create filter
    vlf = vl_dsift_new(img.rows, img.cols, 1, 3);

    // transform image in cv::Mat to float vector
    std::vector<float> imgvec;
    for (int i = 0; i < img.rows; ++i){
      for (int j = 0; j < img.cols; ++j){
        imgvec.push_back(img.at<unsigned char>(i,j) / 255.0f);                                                                                                                                                                                                        
      }
    }
    // call processing function of vl
    vl_dsift_process(vlf, &imgvec[0]);

    // echo number of keypoints found
    std::cout << vl_dsift_get_keypoint_num(vlf) << std::endl;

    // Extract keypoints
    VlDsiftKeypoint * vlkeypoints;
    vlkeypoints = vl_dsift_get_keypoints(vlf);

1 个答案:

答案 0 :(得分:0)

for (int i = 0; i < numKeyPoints; i++) {
    cout << vlkeypoints[i].x << endl;
    cout << vlkeypoints[i].y << endl;
}