2013-06-13 70 views
0

我想使用OpenCV 2.4.0来跟踪一系列灰度图像中的特征点集。特征点跟踪

我已经知道如何实现SIFT或SURF来检测特征点并最初计算描述符。但是,我需要帮助计算一个特征点的SIFT描述符,其位置(u,v)仅为我所知。下面显示了SIFT的工作示例代码。

例如,如果我使用哈里斯角检测器在dv_scenePoints_t像检测功能:

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

在这样的情况下。然后,我将如何计算点的SIFT描述在dv_scenePoints_t

此外,如果我必须通过粒子滤波器跟踪特征点。那么,我将如何使用SIFT描述符来计算每个粒子的权重(特征点假设)。 谢谢。

#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; 

} 

回答