• 大小: 2.95MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-09
  • 语言: 其他
  • 标签: SIFT  SURF  特征跟踪  

资源简介

这里是基于Opencv的SIFT和SURF特征进行目标跟踪的源代码,但是代码还有错误,找不到错误的来由

资源截图

代码片段和文件信息

#include “FeatureTraker.h“
#include 
#include 
#include “opencv2/calib3d/calib3d.hpp“
#include “opencv2/contrib/contrib.hpp“
#include “opencv2/features2d/features2d.hpp“
#include “opencv2/objdetect/objdetect.hpp“
#include “opencv2/imgproc/imgproc.hpp“
#include “opencv2/imgproc/imgproc_c.h“
#include “opencv2/core/internal.hpp“
#include “opencv2/nonfree/nonfree.hpp“

using namespace cv;

FeatureTraker::FeatureTraker(CvFeatureTrackerParams _params) :
params(_params)
{
initModule_nonfree();
switch (params.feature_type)
{
case CvFeatureTrackerParams::SIFT:
dd = Algorithm::create(“Feature2D.SIFT“);
if( dd.empty() )
CV_Error(CV_StsNotImplemented “OpenCV has been compiled without SIFT support“);
dd->set(“nOctavelayers“ 5);
dd->set(“contrastThreshold“ 0.04);
dd->set(“edgeThreshold“ 10.7);
break;
case CvFeatureTrackerParams::SURF:
dd = Algorithm::create(“Feature2D.SURF“);
if( dd.empty() )
CV_Error(CV_StsNotImplemented “OpenCV has been compiled without SURF support“);
dd->set(“hessianThreshold“ 400);
dd->set(“nOctaves“ 3);
dd->set(“nOctavelayers“ 4);
break;
default:
CV_Error(CV_StsBadArg “Unknown feature type“);
break;
}

matcher = new BFMatcher(NORM_L2);
}

FeatureTraker::FeatureTraker()
{
}

FeatureTraker::~FeatureTraker()
{
}

void FeatureTraker::newTrackingWindow(Mat image Rect selection)
{
image.copyTo(prev_image);
cvtColor(prev_image prev_image_bw CV_BGR2GRAY);
prev_trackwindow = selection;
prev_center.x = selection.x;
prev_center.y = selection.y;
ittr = 0;
}

Rect FeatureTraker::updateTrackingWindow(Mat image)
{
if(params.feature_type == CvFeatureTrackerParams::OPTICAL_FLOW)
return updateTrackingWindowWithFlow(image);
else
return updateTrackingWindowWithSIFT(image);
}

Rect FeatureTraker::updateTrackingWindowWithSIFT(Mat image)
{
ittr++;
vector prev_keypoints curr_keypoints;
vector prev_keys curr_keys;
Mat prev_desc curr_desc;

Rect window = prev_trackwindow;
Mat mask = Mat::zeros(image.size() CV_8UC1);
rectangle(mask Point(window.x window.y) Point(window.x + window.width
window.y + window.height) Scalar(255) CV_FILLED);

dd->operator()(prev_image mask prev_keypoints prev_desc);

window.x -= params.window_size;
window.y -= params.window_size;
window.width += params.window_size;
window.height += params.window_size;
rectangle(mask Point(window.x window.y) Point(window.x + window.width
window.y + window.height) Scalar(255) CV_FILLED);

dd->operator()(image mask curr_keypoints curr_desc);

if (prev_keypoints.size() > 4 && curr_keypoints.size() > 4)
{
//descriptor->compute(prev_image prev_keypoints prev_desc);
//descriptor->compute(image curr_keypoints curr_desc);

matcher->match(prev_desc curr_desc matches);

for (int i = 0; i < (int)matches.size(); i++)
{
prev_keys.push_back(prev_keypoints[matches[i].queryIdx].pt);
curr_keys.push_back(curr_keypoints[matches[i].train

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     133632  2013-06-27 17:11  FeatureTracking\Debug\FeatureTracking.exe

     文件     723172  2013-06-27 17:11  FeatureTracking\Debug\FeatureTracking.ilk

     文件    1666048  2013-06-27 17:11  FeatureTracking\Debug\FeatureTracking.pdb

     文件       7650  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\BuildLog.htm

     文件        621  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\FeatureTracking.exe.intermediate.manifest

     文件     474692  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\FeatureTraker.obj

     文件     139138  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\main.obj

     文件         67  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\mt.dep

     文件     543744  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\vc90.idb

     文件    1044480  2013-06-27 17:11  FeatureTracking\FeatureTracking\Debug\vc90.pdb

     文件       4697  2013-06-27 16:19  FeatureTracking\FeatureTracking\FeatureTracking.vcproj

     文件       1427  2013-06-27 17:15  FeatureTracking\FeatureTracking\FeatureTracking.vcproj.DY5A4OBOCPYFOX7.Administrator.user

     文件       5379  2013-06-27 17:08  FeatureTracking\FeatureTracking\FeatureTraker.cpp

     文件       1324  2013-06-27 16:23  FeatureTracking\FeatureTracking\FeatureTraker.h

     文件       2943  2013-06-27 17:15  FeatureTracking\FeatureTracking\main.cpp

     文件       7420  2013-06-27 16:23  FeatureTracking\FeatureTracking\Release\BuildLog.htm

     文件    1221941  2013-06-27 16:06  FeatureTracking\FeatureTracking\Release\featuretracker.obj

     文件        616  2013-06-27 16:23  FeatureTracking\FeatureTracking\Release\FeatureTracking.exe.intermediate.manifest

     文件    1222612  2013-06-27 16:18  FeatureTracking\FeatureTracking\Release\FeatureTraker.obj

     文件    1009858  2013-06-27 15:24  FeatureTracking\FeatureTracking\Release\hybridtracker.obj

     文件    1102698  2013-06-27 16:23  FeatureTracking\FeatureTracking\Release\main.obj

     文件         67  2013-06-27 16:23  FeatureTracking\FeatureTracking\Release\mt.dep

     文件    1068986  2013-06-27 16:02  FeatureTracking\FeatureTracking\Release\precomp.obj

     文件     265216  2013-06-27 16:23  FeatureTracking\FeatureTracking\Release\vc90.idb

     文件     839680  2013-06-27 16:23  FeatureTracking\FeatureTracking\Release\vc90.pdb

     文件    3419136  2013-06-27 17:15  FeatureTracking\FeatureTracking.ncb

     文件        911  2013-06-27 14:18  FeatureTracking\FeatureTracking.sln

    ..A..H.     46592  2013-06-27 17:15  FeatureTracking\FeatureTracking.suo

     文件      32256  2013-06-27 16:23  FeatureTracking\Release\FeatureTracking.exe

     文件    1092608  2013-06-27 16:23  FeatureTracking\Release\FeatureTracking.pdb

............此处省略9个文件信息

评论

共有 条评论