Ask Your Question

mrlibby's profile - activity

2016-04-19 20:17:45 -0600 received badge  Enthusiast
2016-04-18 09:05:05 -0600 asked a question How to parse Mat array saved in a csv file

The lines in the csv file looks like this:

//there are more numbers than in the line below 
label, [4.9854589,  5.1516409,  4.6530952,  7.3120065,  5.8163691,  3.8221853,  5.8163691]
2016-04-16 19:13:57 -0600 commented answer Training color histogram values to svm.

And finally, how do I save the dataset stored in Mat feature to a CSV file?

2016-04-15 00:51:26 -0600 commented answer Training color histogram values to svm.

i mean for the svm like this: http://docs.opencv.org/2.4/_images/re...

2016-04-15 00:22:00 -0600 commented answer Training color histogram values to svm.

Yes. One (probably) last thing, how do i show the training data in an image?

2016-04-14 23:47:18 -0600 commented answer Training color histogram values to svm.

Thank you very much. This is the one I am looking for. Now how do i do a classification using svm->predict?

2016-04-14 23:45:33 -0600 received badge  Scholar (source)
2016-04-14 14:20:17 -0600 asked a question svm->save() throws SEHException

I use the ff. code

Mat data;
Mat feature;
hconcat(r_hist.reshape(1, 1), g_hist.reshape(1, 1), feature); //r_hist and g_hist are color histograms
data.push_back(feature);

int label = 1;
Mat labelMat(1, 1, CV_32SC1, label);

Ptr < cv::ml::SVM > svm = SVM::create();
svm->setC(0.01);
svm->setType(ml::SVM::C_SVC);
svm->setKernel(ml::SVM::LINEAR);
svm->setTermCriteria((cvTermCriteria(TermCriteria::MAX_ITER, 100, 1e-6)));
svm->train(data, ROW_SAMPLE, labelMat);
svm->save("svm.xml");

Can somebody help me with this? I use version 3.0.0

2016-04-14 06:57:57 -0600 received badge  Editor (source)
2016-04-14 06:40:36 -0600 commented question Training color histogram values to svm.

The size is 255.

2016-04-14 05:22:44 -0600 asked a question Training color histogram values to svm.

Complete newbie here. I am trying to make a classifier using OpenCV 3.0.0's SVM and Color histogram to classify a banana to unripe(more green than yellow peel), ripe(more yellow than green or brown peel), and rotten(more brown than yellow peel) based on the color of the peel. I am already trying to make my own using this code which i'm sure will not work:

int labels[510]; //510 is not the number of images but the combined coordinates in the histograms for red and green. I labeled each coordinate.
if (label.compare("raw")){
    for (int i = 0; i < 509; i++){
        labels[i] = 1;
    }
}
else if (label.compare("ripe")){
    for (int i = 0; i < 509; i++){
        labels[i] = 2;
    }
}
else if (label.compare("rotten")){
    for (int i = 0; i < 509; i++){
        labels[i] = 3;
    }
}    
for (int i = 0; i < 254; i++){
        trainingData[i][1] = r_hist.at<float>(i - 1);
        trainingData[i][2] = i;
    }
int j = 0;
for (int i = 255; i < 509; i++){
    trainingData[i][1] = g_hist.at<float>(j - 1);
    trainingData[i][2] = i;
    j++;
}

I know that there is a more effective way to train the SVM. Can anybody help me with this?

The size of the histogram is 255