Training of SVM classifier in OpenCV using HOG, SIFT and ORB features

asked 2012-10-08 07:42:32 -0500

rannock gravatar image

updated 2012-10-08 18:28:11 -0500

I'm trying to train a SVM classifier to recognize pedestrians in a set of 64x128 images. I've already done that using HOG features, and now I need to implement the same thing using SIFT and ORB. Now I have a problem: I can not extract the SIFT features from images, nay, I extract the features but I found out that most of desriptors have a 0 value.

This is a piece of the code:

DenseFeatureDetector detector;
SiftDescriptorExtractor descriptor;
vector<KeyPoint> keypoints;


//for every image I compute te SIFT
detector.detect(image, keypoints);
Mat desc;
descriptor.compute(image,keypoints, desc);
Mat v(1,30976,CV_32FC1);
    for (int j = 0; j<desc.rows; j++){
        for(int k = 0; k<desc.cols; k++){
            v.at<float>(0,128*j+k) = desc.at<float>(j,k);

        }
    } //now in vector v there are all the descriptors (the problem is that most of them have 0 value)

descriptormat.push_back(v);  //descriptormat is the cv::Mat that I use to train the SVM

Can anyone help me understand how to solve this problem? Many thanks for your help!

edit retag flag offensive close merge delete

Comments

SIFT and ORB doens't work with SVM.. you are doing it wrong

yes123 gravatar imageyes123 ( 2012-10-08 13:07:36 -0500 )edit

Are you sure? For the HOG features I used a cv::Mat in wich I put in the descriptors (in each row the descriptor of one image); so I thought I could do the same with the SIFT: I build (for every image) a vector in wich I put in the descriptors (calculated with the keypoint). Then I push back every vector in a cv::Mat that I use for the training. if, as you say, it doesn't work, can you recommend a better method? thank you very much!

rannock gravatar imagerannock ( 2012-10-08 18:26:22 -0500 )edit

Did you find any way doing that ? I also try SIFT, SURF, ORB. None of them worked with neither SVM nor random forest.

CHz gravatar imageCHz ( 2013-05-28 16:43:29 -0500 )edit