Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Training of SVM classifier in OpenCV using SIFT and ORB features

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!

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

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!