user2480819
user2480819

Reputation: 1

Feature point Tracking

I am trying to track set of feature points in a sequence of grayscale images using OpenCV 2.4.0.

I already know how to implement SIFT or SURF for detecting feature points and initially computing the descriptors. However, I need help in computing the SIFT descriptor of a feature point whose location (u,v) is only known to me. A working example code for SIFT is shown below.

For example, if I use Haris corner detector to detect features at dv_scenePoints_t like:

cvGoodFeaturesToTrack (source2, eig_img, temp_img, dv_scenePoints_t, &corner_count, 0.3, 3.0, mask, 7, 1);

Then in such a case, how would I compute the SIFT descriptor of points at dv_scenePoints_t.

Also, if I have to track feature points by a particle filter. Then, how would I use the SIFT descriptor for computing the weight of each particle (feature point hypothesis). Thanks.

#include "stdafx.h"
#include <stdio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include <opencv2/nonfree/features2d.hpp>
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/legacy/compat.hpp"
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <string.h>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char *argv[])
{        
    Mat source1 = imread("KITTI_train.png",CV_LOAD_IMAGE_GRAYSCALE);
    Mat source2 = imread("KITTI_trainRotate90.png",CV_LOAD_IMAGE_GRAYSCALE);

    vector<KeyPoint> dv_sceneKeypoints_t, dv_objectKeypoints_t;
    vector< DMatch > matches;

    SiftFeatureDetector detector(400,5,0.03);

    detector.detect(source1, dv_objectKeypoints_t);
    detector.detect(source2, dv_sceneKeypoints_t);
    SiftDescriptorExtractor extractor;

    Mat descriptors1,descriptors2;
    extractor.compute(source1,dv_objectKeypoints_t,descriptors1);
    extractor.compute(source2,dv_sceneKeypoints_t,descriptors2);

    FlannBasedMatcher matcher;
    matcher.match(descriptors1,descriptors2, matches);
    Mat target;
    drawMatches(source1,dv_objectKeypoints_t,source2,dv_sceneKeypoints_t,matches,target);
    imshow("Matches", target);
    waitKey(0);
    return 0;

}

Upvotes: 0

Views: 996

Answers (1)

fatihk
fatihk

Reputation: 7919

Keypoint structure contains some members such as size and response: http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html?#KeyPoint

You can use these features to determine the relative weights of particles.

Upvotes: 1

Related Questions