Ask Your Question
0

C++ / mean of value CvSVM::predict()

asked 2014-07-17 06:55:05 -0600

lilouch gravatar image

I'm actually working on a project of logos classification using SURF + BOW + SVM. This is my first time i'm work on a kind of project and especially with SVM.

So i have two folders : train and eval which contains 4 classes of differents elements.My class are distinctive because i have a class of boat,class of car,class of plane and class of animals. Train has about 255 pictures (so 255/4) Eval has about 340 pictures (so 340/4)

I followed a tutorial which explain how use BoW. I think that's fine for me but i have a problem with the value of my svm.predict().

for (int i=0;i<logos_list_eval.size();i++){
      cv::Mat imgEval=cv::imread(path_to_eval + logos_list_eval.at(i),CV_LOAD_IMAGE_GRAYSCALE);
      ssm_ensure(imgEval.data, "Could not load the first image");
      //Debug::info("Eval : " + logos_list_eval.at(i));
      detector_training.detect(imgEval, keypoint2);
      bowDE.compute(imgEval, keypoint2, bowDescriptor2);

      evalData.push_back(bowDescriptor2);
      groundTruth.push_back((float) i);
      float response = svm.predict(bowDescriptor2);
      std::cout << "Reponse : " << response <<  std::endl;
      results.push_back(response);
      string info= logos_list_eval.at(i) + " |  response : " + convertInt(response) ;
      compute_info << info << std::endl;

  }

The result of my prediction is :

... Reponse : 242 Reponse : 242 Reponse : 178 Reponse : 242 Reponse : 178 Reponse : 175 Reponse : 121 Reponse : 190 Reponse : 191 Reponse : 186 Reponse : 188 Reponse : 207 Reponse : 189 Reponse : 189 Reponse : 179 Reponse : 178 Reponse : 201 Reponse : 173 Reponse : 188 Reponse : 178 Reponse : 179 Reponse : 186 Reponse : 189 Reponse : 189 Reponse : 189 Reponse : 209 Reponse : 178 Reponse : 179 ...

I don't understand theses values. How can i know if it's belong to class 1,2,3 or 4 ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-17 07:14:31 -0600

Actually your problem is quite simple. You are using a binary classifier (SVM implementation for CvSVM is binary / 2 classed) to try and solve a 4 class SVM problem.

Solution to this can be to train a 1 vs all classifier for each class. Or you could make a classifier for each combination of 2 classes and evaluate those. Thats a design choice.

For this all positive and negative data need the same amount of features in their descriptor as well as a +1 or -1 label with it. That will then result in a classifier ouputting labels near +1 or -1, assigning the certainty for a class together with the result.

edit flag offensive delete link more

Comments

I understood what you told me but i follow a tutorial when they say that the code i used is for image classification with lots of classes...Therefore i'm a bit lost. I follow this trame : 1. Obtain the set of bags of features. Select a large set of images. Extract the SIFT feature points of all the images in the set and obtain the SIFT descriptor for each feature point that is extracted from each image. Cluster the set of feature descriptors for the amount of bags we defined and train the bags with clustered feature descriptors (we can use the K-Means algorithm). Obtain the visual vocabulary. Therefore it's cluster the 4 classes no ? Maybe i'm mistaken...

Otherwise, how can i do a 1 vs all classifier for each class or make a classifier for each combination of 2 class please ?

lilouch gravatar imagelilouch ( 2014-07-17 07:35:07 -0600 )edit

Question Tools

Stats

Asked: 2014-07-17 06:55:05 -0600

Seen: 364 times

Last updated: Jul 17 '14