MAT类型是相同的,但我获得的“推动向量类型与函数中的矩阵类型不同' push_back' &quot错误

发布于 2025-01-30 02:33:39 字数 1199 浏览 1 评论 0原文

我正在尝试重塑SIFT描述符矩阵,然后将其推回另一个矩阵,但我会收到此错误 pusthed向量类型与'push_back'push_back'中的矩阵类型不同。

这是我的代码:

Mat get_featuesunclustered( Mat input)
{
  if(!input.data)
    {
      cout << "Image not found !!!" << endl << endl;
    }
  
  //To store the keypoints that will be extracted by SIFT
  vector<KeyPoint> keypoints;

  //To store the SIFT descriptor of current image
  Mat descriptor;  

  //The SIFT feature extractor and descriptor
  Ptr<SIFT> detector = SIFT::create();
    
  //detect feature points and compute the descriptors for each keypoint
  detector->detectAndCompute(input, noArray(), keypoints, descriptor);

  if (descriptor.type() != CV_32F)
    {
      descriptor.convertTo(descriptor, CV_32F);
    }
  
  return descriptor;
}

int main(){
  Mat dicodescriptor,labels, feats;
  vector<Mat> dico; // dico contains images

  for(size_t y = 0; y < dico.size(); y++)
      {
         dicodescriptor = get_featuesunclustered(dico[y]);
      
         Mat f = dicodescriptor.reshape(dicodescriptor.rows * dicodescriptor.cols, 1);
         feats.push_back(f);    
      }
}

我不知道我的代码有什么问题,有人可以帮忙吗?

I'm trying to reshape the sift descriptor matrix I get into one line and then push it back to another matrix but I get this error Pushed vector type is not the same as matrix type in function 'push_back'.

this is my code:

Mat get_featuesunclustered( Mat input)
{
  if(!input.data)
    {
      cout << "Image not found !!!" << endl << endl;
    }
  
  //To store the keypoints that will be extracted by SIFT
  vector<KeyPoint> keypoints;

  //To store the SIFT descriptor of current image
  Mat descriptor;  

  //The SIFT feature extractor and descriptor
  Ptr<SIFT> detector = SIFT::create();
    
  //detect feature points and compute the descriptors for each keypoint
  detector->detectAndCompute(input, noArray(), keypoints, descriptor);

  if (descriptor.type() != CV_32F)
    {
      descriptor.convertTo(descriptor, CV_32F);
    }
  
  return descriptor;
}

int main(){
  Mat dicodescriptor,labels, feats;
  vector<Mat> dico; // dico contains images

  for(size_t y = 0; y < dico.size(); y++)
      {
         dicodescriptor = get_featuesunclustered(dico[y]);
      
         Mat f = dicodescriptor.reshape(dicodescriptor.rows * dicodescriptor.cols, 1);
         feats.push_back(f);    
      }
}

I don't know what wrong with my code, someone can help please ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文