Train svm with ORB descriptors?

Hi i've been trying to train a svm with features, but i don't understand what to do with the descriptors that are computed of the keypoints using ORB. I know that svm needs a data matrix and a label matrix, but i don't know how can i pass the descriptors Mat to a valid format. I've read about the BoF (Bag of Words/Features) but i don't know how to use it. Thanks for any help.

The code below allows me to get the descriptors of an image. What's the next step?

            std::vector<KeyPoint> kp;
            Mat desc;
        // Default parameters of ORB
            int nfeatures = 128; 
            float scaleFactor = 1.2f; 
            int nlevels = 8;    
            int edgeThreshold = 15; // Changed default (31);
            int firstLevel = 0; 
            int WTA_K = 2; 
            int scoreType = ORB::HARRIS_SCORE; 
            int patchSize = 31; 
            int fastThreshold = 20;

            Ptr<ORB> myORB = ORB::create(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType,
                patchSize, fastThreshold);

            myORB->detectAndCompute(src, Mat(), kp, desc);

            features.push_back(desc);

Upvotes: 1

Views: 1314

Answers (1)

sv_jan5
sv_jan5

Reputation: 1573

I would highly recommend you to use python with OpenCV that will save you a lot of time. In python, this will be just 10 lines of code.

You can refer to this link for ORB. And once you get features then you can use scikit-learn svm for training an SVM classifier.

Upvotes: 0

Related Questions