Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Training color histogram values to svm.

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];
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?

Training color histogram values to svm.

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];
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?this?

The size of the histogram is 255

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];
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

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];
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