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