当useProvidedKeypoints = true时,cvExtractSURF不起作用 [英] cvExtractSURF don't work when useProvidedKeypoints = true

查看:129
本文介绍了当useProvidedKeypoints = true时,cvExtractSURF不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图提取一些SURF关键点,但我想强加这些关键点!因此,我将最后一个参数设为"true",即"useProvidedKeypoints".

So, I'm trying to extract some SURF keypoints, but I want to impose these key points! So, I put the last parameter to "true" which is "useProvidedKeypoints".

此外,当我创建关键点时,我使用了默认构造函数(所以那里有一些默认值).我只更改点"pt"和设置为3的八度.

Also, when I create my Keypoint, I used the default constructor (so some default values there). I only change the point "pt" and the octave that I set to 3.

我在SURF中使用C ++接口.但是我知道问题出在cvExtractSURF,因为我在我的那部分代码中进行了复制以帮助调试.

I'm using the C++ interface with SURF. But I know that the problem is right at cvExtractSURF because I copied that part of the code in mine to help me debug.

当我调用该函数并将最后一个参数设置为true时,出现此错误:

When I call that function, with the last parameter set to true, I got this error:

OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /home/widgg/opencv/trunk/modules/core/src/matrix.cpp, line 651
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/widgg/opencv/trunk/modules/core/src/matrix.cpp:651: error: (-5) Unknown array type in function cvarrToMat

我真的不知道我在做什么错!

I really don't know what I'm doing wrong!

这是一些代码.首先,我如何创建关键点(我留下了一些信息,例如layer_id的东西,但是您有了主要的想法):

Here's some code. First how I create the keypoints (I left a couple of informations, like the layer_id stuff, but you get the main idea):

for (json_pt_info_vector::iterator b_beg = beg->points.begin(); b_beg != b_end; ++b_beg)
{
  int layer_id = b_beg->layer_id;
  json_point_info_coord &jpic = b_beg->coord;

  jpic.feature_id = features[layer_id].keypoints.size();
  KeyPoint kp;
  kp.octave = 3;
  kp.pt.x = jpic.x;
  kp.pt.y = jpic.y;
  features[layer_id].keypoints.push_back(kp);
}

这是SURF的电话:

SURF surf(300, 3, 4);
for (int i = 0; i < nb_img; ++i)
{
  debug_msg("extract_features #4.1");
  cv::detail::ImageFeatures &cdif = features[i];
  Mat gray_image = imread(param.layer_images[i], 0);  // 0 = force to gray scale!

  debug_msg("extract_features #4.2");
  vector<float> descriptors;
  debug_msg("extract_features #4.3");
  surf(gray_image, Mat(), cdif.keypoints, descriptors, true); // MUST BE TRUE TO FORCE THE PROVIDED KEYPOINTS

  debug_msg("extract_features #4.4");
  cdif.descriptors = Mat(descriptors, true).reshape(1, (int)cdif.keypoints.size());
  debug_msg("extract_features #4.5");
  gray_image.release();

  debug_msg("extract_features #4.6");
  images[i] = imread(param.layer_images[i]);  // keep the image open
}

在调试消息中#4.3之后崩溃!

It crashes after #4.3 in the debug message!

希望有帮助!

我用cv :: SurfDescriptorExtracter替换了一部分.我将4.3到4.5的所有内容替换为以下行:

I replaced some part by cv::SurfDescriptorExtracter. I replace everything from 4.3 to 4.5 with the following line:

 extractor.compute(gray_image, cdif.keypoints, cdif.descriptors);

因此,现在仍然存在一个错误,但它位于其他地方,与该问题无关!

So now, there's still a bug, but it's located somewhere else, not necessary related to this question!

推荐答案

对于surf(gray_image, Mat(), cdif.keypoints, descriptors, true)的调用甚至可以编译,我感到很惊讶. descriptors参数应该是cv :: Mat,而不是向量.

I'm surprised that the call to surf(gray_image, Mat(), cdif.keypoints, descriptors, true) even compiles. the descriptors argument should be a cv::Mat, not a vector.

这篇关于当useProvidedKeypoints = true时,cvExtractSURF不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆