c++ - 将 vlfeat 库的 dsift 与 cv::Mat 结合使用

标签 c++ c opencv computer-vision vlfeat

我目前正在尝试使用 vlfeat-lib 的 dsift-algorithm。但无论我使用哪个值创建过滤器(样本步长、bin 大小),它都会在执行期间为每一帧返回相同数量的关键点(连续帧与相机不同)。关于 C 或 C++ 用法的文档非常薄,我找不到这些语言的任何好的示例。 相关代码如下:

// create filter
vlf = vl_dsift_new_basic(320, 240, 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;

最佳答案

it returns the same number of keypoints for every frame during an execution

这对于密集 SIFT 实现是正常的,因为提取的关键点数量仅取决于输入几何参数[1],即步长和图像大小。

参见 documentation :

The feature frames (keypoints) are indirectly specified by the sampling steps (vl_dsift_set_steps) and the sampling bounds (vl_dsift_set_bounds).

[1]:vl_dsift_get_keypoint_num 返回仅由 _vl_dsift_update_buffers 更新的 self->numFrames,它仅使用几何信息(边界、步长和垃圾桶大小)。

关于c++ - 将 vlfeat 库的 dsift 与 cv::Mat 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15246155/

相关文章:

c - 以两种方式实现快速排序算法但只接受一种?

python - 为什么使用cv2.calcHist总是出现错误 "returned NULL without setting an error"

c++ - 如果我的函数是常量,那么参数也必须是常量吗?

C++ 非 const 右值参数解决方法

可以使用 strcpy 但不能使用 strcat 的情况

c++ - 在 Windows 7 上运行应用程序时未加载 OpenCV ffmpeg DLL,适用于 8 和 10

python - OpenCV-Python接口(interface)、cv和cv2的性能比较

c++ - 如何返回 cURL 数据

c++ - 函数调用中的段错误

c - 寻找最小和最大单词的程序