ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

c – 使用带SURF的SVM获取错误

2019-10-08 12:12:10  阅读:153  来源: 互联网

标签:c opencv image-processing computer-vision svm


下面是我的代码,运行正常,但经过长时间的处理,它显示运行时错误

// Initialize constant values
const int nb_cars = files.size();
const int not_cars = files_no.size();
const int num_img = nb_cars + not_cars; // Get the number of images
// Initialize your training set.
cv::Mat training_mat(num_img,dictionarySize,CV_32FC1);
cv::Mat labels(0,1,CV_32FC1);

std::vector<string> all_names;

all_names.assign(files.begin(),files.end());
all_names.insert(all_names.end(), files_no.begin(), files_no.end());

// Load image and add them to the training set
int count = 0;
vector<string>::const_iterator i;
string Dir;
for (i = all_names.begin(); i != all_names.end(); ++i)
{
    Dir=( (count < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

    Mat row_img = cv::imread( Dir +*i, 0 );

    detector.detect( row_img, keypoints);

    RetainBestKeypoints(keypoints, 20); // retain top 10 key points

    extractor->compute( row_img, keypoints, descriptors_1);

    //uncluster.push_back(descriptors_1);
    descriptors.reshape(1,1);

    bow.add(descriptors_1);

    ++count;
}

int count_2=0;
vector<string>::const_iterator k;
Mat vocabulary = bow.cluster();
dextract.setVocabulary(vocabulary);


for (k = all_names.begin(); k != all_names.end(); ++k)
{
    Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

    row_img = cv::imread( Dir +*k, 0 );

    detector.detect( row_img, keypoints);

    RetainBestKeypoints(keypoints, 20);

    dextract.compute( row_img, keypoints, descriptors_1);

    descriptors_1.reshape(1,1);

    training_mat.push_back(descriptors_1);

    labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1;

    ++count_2;
}

错误:

OpenCv Error : Formats of input argument do not match() in unknown function , file ..\..\..\src\opencv\modules\core\src\matrix.cpp, line 652

我在第二个循环中创建了descriptor_1以重新形成SVM的行,但是错误没有解决

解决方法:

我认为你正在尝试使用比类数更少的功能进行聚类.

您可以从每个图像中获取更多图像或更多10个描述符.

标签:c,opencv,image-processing,computer-vision,svm
来源: https://codeday.me/bug/20191008/1871552.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有