cannot declare field 'std::pair<const std::basic_string<char>, cv::ml::SVM>::second' to be of abstract type 'cv::ml::SVM'

asked 2016-03-06 11:33:18 -0600

floyd gravatar image

updated 2016-03-06 13:03:59 -0600

hey everybody,

i am really new to openCV and i am trying to implement a surf detector using openCV 3.1 and i getting always after building my project in eclipse the error message above. There are a lot of information i getting, too. Most of them concerning to ml.hpp.

image description

My code seem to be okay. The only error appearing references to "line 102, external location: /usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin11.4.2/4.8.2/include/c++/bits/stl_pair.h C/C++ Problem"

I do not know what to do cause the error is not my fault?

desperate floyd

EDIT 1

void categorizer::train_classifiers() {
// Set the vocabulary for the BOW descriptor extractor
bowDescriptorExtractor -> setVocabulary(vocab);
// Extract BOW descriptors for all training images and organize them into positive and negative samples for each category
make_pos_neg();

for(int i = 0; i < categories; i++) {
    string category = category_names[i];

    // Positive training data has labels 1
    Mat train_data = positive_data[category];
    Mat train_labels = Mat::ones(train_data.rows, 1, CV_32S);
    // Negative training data has labels 0
    train_data.push_back(negative_data[category]);
    Mat m = Mat::zeros(negative_data[category].rows, 1, CV_32S);
    train_labels.push_back(m);

    svm = ml::SVM::create();
    svm->setType(ml::SVM::C_SVC);
    svm->setKernel(ml::SVM::POLY);
    svm->setGamma(3);

    svm->train( train_data , ml::ROW_SAMPLE , train_labels );

    cout << "Trained and saved SVM for category " << category << endl;
}

}

edit retag flag offensive close merge delete

Comments

please try to give us a TEXT version of your error, not an (unreadable) screenshot.

also, the resp. part of code might be helpful

berak gravatar imageberak ( 2016-03-06 11:46:43 -0600 )edit

apart from that, you probably need a pair<string,Ptr<ml::SVM>> . ml::SVM is an abstract interface.

"My code seem to be okay." -- definitely not !

berak gravatar imageberak ( 2016-03-06 11:52:14 -0600 )edit

i do agree with you my code is probably (or definitely) not okay. but way is there no reference to my code? so i don't know which part of the code i need to post.

floyd gravatar imagefloyd ( 2016-03-06 12:03:10 -0600 )edit

the parts, where you construct the SVM, and where you're trying to put it into your pair

berak gravatar imageberak ( 2016-03-06 12:07:01 -0600 )edit

I'm doing like you did it here: link, a pair i do nowhere have.

floyd gravatar imagefloyd ( 2016-03-06 12:44:23 -0600 )edit
  • "a pair i do nowhere have." -- then, why is it in the title of your question ?
  • "I'm doing like you did it here" -- obviously not.
berak gravatar imageberak ( 2016-03-06 12:49:09 -0600 )edit

that's the problem, i do not know what is going on. the only error appearing is the title of that question. the location of the error is in the header file stl_pair.h. That is why i wrote my code seem to be okay. the location is out of my code. and all the informations shown in the screenshot are out of my code, too.

floyd gravatar imagefloyd ( 2016-03-06 13:00:58 -0600 )edit

it seems, you're trying to train an svm per class,

do you have a map of svm's ? (it's using pairs internally)

berak gravatar imageberak ( 2016-03-06 13:39:00 -0600 )edit

indeed i did have a unused map of svm's left in the code. all problems are gone. a new problem appeared, but so far for today and the new problem i can handle on my own. thanks a lot. :D :D

floyd gravatar imagefloyd ( 2016-03-06 14:00:18 -0600 )edit