Ask Your Question

nqthiep's profile - activity

2015-12-01 07:37:36 -0600 commented answer svm predict function always return a large number

Yes, Thank you :)

2015-11-30 02:19:21 -0600 received badge  Enthusiast
2015-11-29 02:53:37 -0600 commented answer svm predict function always return a large number

@StevenPuttemans: I dont know how to solve this ticket. Please point me.

2015-11-29 02:52:29 -0600 received badge  Citizen Patrol (source)
2015-11-29 02:51:16 -0600 commented answer svm predict function always return a large number

@berak Thank you so much for your explained. I understood. So, I'd like to solved this ticket.

2015-11-29 02:49:37 -0600 received badge  Scholar (source)
2015-11-26 10:10:24 -0600 commented question svm predict function always return a large number

Thank all your the support. I tried modify as @berak suggest, and my issue solved. @berak: I can't understand. Could you explain for me about the different between your way with my way?

2015-11-25 10:34:25 -0600 asked a question svm predict function always return a large number

Hi all,

I trying to implement a simple sample, the purpose is tranning and detect a number. Source as following:

Step 1: Initial data for tranning: I used a collect of images number for traning data,

    Mat vectorMatToMat(vector<Mat> list) {
        if (list.empty()) {
            return Mat();
        }
        int row = list.size();
        int col = list.at(0).rows * list.at(0).cols;
        Mat data(row, col, CV_32FC1);
        int i = 0;
        for (i = 0; i < row; i++) {
            Mat rowMat = list.at(i).reshape(1, 1);
            rowMat.copyTo(data.row(i));
        }
        return data;
    }
    Mat vectorIntToMat(vector<int> list) {
        int row = list.size();
        Mat data(row, 1, CV_32SC1, &list[0]);
        return data;
    }

    Mat dataMat = vectorMatToMat(listImageForTraining);
    Mat dataLabel = vectorIntToMat(listLabel);

Step 2: Init SVM:

Ptr<TrainData> trainData = TrainData::create(dataMat, ROW_SAMPLE, dataLabel);

Ptr<SVM> model = SVM::create();
model->setType(SVM::C_SVC);
model->setKernel(SVM::LINEAR);
model->setC(7);
model->setNu(SVM::NU_SVC);
model->setP(0);
model->setDegree(0);
model->setGamma(20);
model->setCoef0(0);
TermCriteria term(CV_TERMCRIT_ITER +CV_TERMCRIT_EPS, 1000, 1e-6);
model->setTermCriteria(term);
model->train(trainData);

Step 3: trying using SVM for predict:

    int i = 0;
    for (i = 0; i < 15; i++) {
        Mat check = dataMat.row(i);
        ostringstream oss;
        oss << i;
        imshow(oss.str(), check.reshape(1, 128));

        check = check.reshape(1, 1);
        int lable = model->predict(check);

        cout << "Result: " << lable << endl;
    }

Step 4: Result:

Result: -1237234688
Result: 159407376
Result: 159407376
Result: 167908848
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216
Result: 1065353216

As we can see, my result are very large number, although my labels are numbers in 0 to 10. I can not understand why, i think i have a mistake when I init SVM model.

But i dont know how to fix this issue, If there is any idea, please help me.

Thanks & Best Regards,

Thiep

2015-11-25 09:59:09 -0600 commented question svm predict not correct

Thank you for advice. I will rewrite my question for easy understanding.

2015-11-20 21:53:31 -0600 asked a question svm predict not correct

Hi all,

I trying to implement a class, the purpose is tranning and detect a number. Source as following:

            model = SVM::create();
            model->setType(SVM::C_SVC);
            model->setKernel(SVM::LINEAR);
            model->setC(7);
            model->setNu(SVM::NU_SVC);
            model->setP(0);
            model->setDegree(0);
            model->setGamma(20);
            model->setCoef0(0);
            TermCriteria term(CV_TERMCRIT_ITER +CV_TERMCRIT_EPS, 1000, 1e-6);
            model->setTermCriteria(term);
            model->train(dataTraining->getTrainData());

But predict function always return a large result. I dont know why it work not good.

I attached full source code, please help us solve this issue.

http://www.mediafire.com/download/l6i...

Thanks & Best Regards,

Thiep

2014-06-05 21:53:41 -0600 commented question how to extract similar part of two images

Thanks Witek. Yes, it is. I work on horizontal motion.

2014-06-05 21:51:16 -0600 received badge  Supporter (source)
2014-05-29 03:47:28 -0600 received badge  Student (source)
2014-05-28 05:32:04 -0600 asked a question how to extract similar part of two images

Hi all,

I have two images as below:

image description image description

I want to ask, how to extract similar part of there images.

Thanks for helping me.

=========================================================================================== Thank you very much for reply, Witek & GilLevi.

I have solved this problem in my way.

Here is my solution: - Get the end part of the first image, find its position in second image. Temporary called result A. - Get the first part of the second image, find its position in first image. Temporary called result B.

=> The region between A and B is result which i want.

2014-04-08 04:32:19 -0600 commented question How to train opencv with xm2vts database

Thanks berak & StevenPuttemans very much. I tried flandmark, but not ok. I want to do same http://ibug.doc.ic.ac.uk/resources/facial-point-annotations, have you any way to do same that?

2014-04-08 02:58:38 -0600 received badge  Editor (source)
2014-04-08 02:21:24 -0600 asked a question How to train opencv with xm2vts database

Hi all,

I had a xm2vts face database, that is used for facial point detect. But i don't know to use it for detect facial point with opencv.

Anyone can help me, please.

I found this article (http://ibug.doc.ic.ac.uk/resources/facial-point-annotations/) about xm2vts, which used for detect feature point of the face. But this article does not just how to use xm2vts with opencv. If anyone know xm2vts with opencv, plese help me.