Ask Your Question

Stefan Isidorovic's profile - activity

2015-08-27 14:41:35 -0500 commented question How to form data for SVM training OpenCV3

Hi, I cloned repo, and install new lib version, and still same error :-/

2015-08-26 02:36:50 -0500 commented question How to form data for SVM training OpenCV3

Thank you very much :D I had serious headache about this one :D

2015-08-26 02:16:11 -0500 commented question How to form data for SVM training OpenCV3

I downloaded library not long after first stable release, at the end of June I think... Did everything go well? I mean did utility produced successfully .xml classifier file?

2015-08-26 00:34:23 -0500 commented question How to form data for SVM training OpenCV3

I should be able to run debugger, I will give it a try when I get back home..

2015-08-26 00:30:08 -0500 commented question How to form data for SVM training OpenCV3

Here is whole project in .tar.gz... https://goo.gl/gWAewI

2015-08-26 00:25:54 -0500 commented question How to form data for SVM training OpenCV3

using TrainingDataType = cv::Ptr<cv::ml::traindata>; Training set is fairly simple, ~45 images, very small set just to see if I get it done. I can zip it all and send :)

2015-08-26 00:13:20 -0500 commented question How to form data for SVM training OpenCV3

During training... Exactly after call of trainAuto. During that method it shows me floating point exception and terminate program.

2015-08-26 00:11:08 -0500 received badge  Enthusiast
2015-08-25 16:45:38 -0500 received badge  Student (source)
2015-08-25 14:19:48 -0500 commented answer Create samples won't work

I changed back from 3.0 version to 2.4 and it worked :)

2015-08-25 14:18:49 -0500 asked a question How to form data for SVM training OpenCV3

I am trying to write utility for training svm classifier for image classification in OpenCV3. But I have Floating point exception (core dumped) error during training process.

My main problem is that I don't know, I'm not sure exactly how to form training data to feed svm.train method.

This is code which is forming training data.

TrainingDataType SVMTrainer::prepareDataForTraining() {

    cv::Mat trainingData(m_numOfAllImages, 28*28, CV_32FC1);
    cv::Mat trainingLabels(m_numOfAllImages, 1, CV_32FC1);

    int rowNum = 0;


    // Item is pair of classId (int) and vector of images.
    for(auto item : m_data){
        int classId = item.first;
        for(auto item1 : item.second){
            Mat temp = item1.reshape(1,1);
            temp.copyTo(trainingData.row(rowNum));

            trainingLabels.at<float>(rowNum) = item.first;
            ++rowNum;
        }
    }

    return cv::ml::TrainData::create(trainingData,
                                     cv::ml::SampleTypes::ROW_SAMPLE, 
                                     trainingLabels) ;

}

void SVMTrainer::train(std::string& configPath){
    // Read and store images in memory.
    formClassifierData(configPath);

    m_classifier = cv::ml::SVM::create();
    // Training parameters:
    m_classifier->setType(cv::ml::SVM::C_SVC);
    m_classifier->setKernel(cv::ml::SVM::POLY);
    m_classifier->setGamma(3);  
    m_classifier->setDegree(3);

    TrainingDataType trainData =  prepareDataForTraining();

    m_classifier->trainAuto(trainData);

}

All images are already prepared with dimensions 28*28, black&white.

And actual train call is in this method

Can somebody tell me what I am doing wrong.

Thanks,

2015-07-02 09:49:29 -0500 asked a question Create samples won't work

Hi,

I am trying to create *.vec file for training classifier.
Problem is that opencv_createsamples tool doesn't show any warning or error, but later when I start opencv_traincascade tool it shows error that there is not enough samples provided.

When I call opencv_createsamples with -show flag it shows only first image. Same happen when I am call it after for created *.vec file.

opencv_createsamples -info pos.info -vec sample.vec -num 500 -w 48 -h 24

Info file name: pos.info
Img file name: (NULL)
Vec file name: sample.vec
BG  file name: (NULL)
Num: 500
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 48
Height: 24
Create training samples from images collection...
Done. Created 500 samples

And pos.file is like this

pos/pos-0.pgm 1 0 0 100 40
pos/pos-100.pgm 1 0 0 100 40
pos/pos-101.pgm 1 0 0 100 40
pos/pos-102.pgm 1 0 0 100 40

Can someone help me?