• 大小: 10.14MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-05
  • 语言: 其他
  • 标签: 视觉  

资源简介

VC05+opencv 粒子滤波的多目标跟踪

资源截图

代码片段和文件信息


#include “ParticleFilter.h“


void on_mouse(int event int x int y int flags void* param)
{
CvPoint *points=(CvPoint*)param;
if( event == CV_EVENT_LBUTTONUP)
{
points[1] = cvPoint(xy);
if (points[0].x>points[1].x)
{
int temp=points[0].x;
points[0].x=points[1].x;
points[1].x=temp;
}
if (points[0].y>points[1].y)
{
int temp=points[0].y;
points[0].y=points[1].y;
points[1].y=temp;
}

}
else if( event == CV_EVENT_LBUTTONDOWN )
points[0] = cvPoint(xy);
}

int main( int argc char** argv )
{

//直方图参数定义
CvHistogram* dsthist1=NULL;
CvHistogram* prediction_hist1 = NULL;
CvHistogram* particlehist1=NULL;
CvHistogram* dsthist2=NULL;
CvHistogram* prediction_hist2 = NULL;
CvHistogram* particlehist2=NULL;
int histnum = 128;
float hranges_arr[] = {1255};
float* histranges = hranges_arr;

IplImage* pframe = NULL; 
IplImage* pGrey = NULL;
CvCapture* pCapture = NULL;
IplImage* dstimage1=NULL;
IplImage* dstimage2=NULL;
CvPoint objectArea1[2];//被跟踪物体1的左上角和右下角坐标
CvPoint objectArea2[2];//被跟踪物体2的左上角和右下角坐标
int a1b1a2b2;
//CvPoint preobjectPosition[2];
//粒子滤波的参数定义
float exptect_dist = 50;
int samplenum = 64;
int measurement_noise = 5;
int Dim=2;
int MDim=histnum;

CvConDensation *ConDens1 = cvCreateConDensation(Dim MDim samplenum);
CvMat* Bottom1 = cvCreateMat(Dim1CV_32FC1);
CvMat* Up1 = cvCreateMat(Dim1CV_32FC1);
CvPoint state_prediction1 = cvPoint(153 180);

CvConDensation *ConDens2 = cvCreateConDensation(Dim MDim samplenum);
CvMat* Bottom2 = cvCreateMat(Dim1CV_32FC1);
CvMat* Up2 = cvCreateMat(Dim1CV_32FC1);
CvPoint state_prediction2= cvPoint(153 180);


CvRandState rng;
cvRandInit(&rng 0 1 -1 0);


//视频读取
int nFrmNum = 0;

if(!(pCapture = cvCaptureFromFile(“twoball.mp4“)))
{
std::cout<<“cannot open video:“< return -2;
}
cvNamedWindow(“video“ 1);

while(pframe = cvQueryframe(pCapture))
{
nFrmNum++;
if(nFrmNum==1)
{
//指定选择区
cvShowImage(“video“ pframe);
cvSetMouseCallback(“video“on_mouse(void*)objectArea1);
cvWaitKey(); 
cvSetMouseCallback(“video“on_mouse(void*)objectArea2);

cvWaitKey(); 
cvLine( pframe objectArea1[0] cvPoint(objectArea1[1].xobjectArea1[0].y) cvScalarAll(255) 1 8 0 );
cvLine( pframe objectArea1[0] cvPoint(objectArea1[0].xobjectArea1[1].y) cvScalarAll(255) 1 8 0 );
cvLine( pframe cvPoint(objectArea1[0].xobjectArea1[1].y) objectArea1[1] cvScalarAll(255) 1 8 0 );
cvLine( pframe cvPoint(objectArea1[1].xobjectArea1[0].y)objectArea1[1] cvScalarAll(255) 1 8 0 );

cvLine( pframe objectArea2[0] cvPoint(objectArea2[1].xobjectArea2[0].y) cvScalarAll(255) 1 8 0 );
cvLine( pframe objectArea2[0] cvPoint(objectArea2[0].xobjectArea2[1].y) cvScalarAll(255) 1 8 0 );
cvLine( pframe cvPoint(objectArea2[0].xobjectArea2[1].y) objectArea2[1] cvScalarAl

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

     文件      61440  2010-01-29 14:36  ParticleFilter\debug\ParticleFilter.exe

     文件     461316  2010-01-29 14:36  ParticleFilter\debug\ParticleFilter.ilk

     文件     805888  2010-01-29 14:36  ParticleFilter\debug\ParticleFilter.pdb

     文件      10122  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug\BuildLog.htm

     文件      83149  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug\main.obj

     文件         67  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug\mt.dep

     文件        406  2010-01-29 13:32  ParticleFilter\ParticleFilter\Debug\ParticleFilter.exe.embed.manifest

     文件        472  2010-01-29 13:32  ParticleFilter\ParticleFilter\Debug\ParticleFilter.exe.embed.manifest.res

     文件        388  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug\ParticleFilter.exe.intermediate.manifest

     文件      71315  2010-01-29 13:32  ParticleFilter\ParticleFilter\Debug\ParticleFilter.obj

     文件     715776  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug\vc80.idb

     文件     446464  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug\vc80.pdb

     文件       5635  2010-01-29 14:36  ParticleFilter\ParticleFilter\main.cpp

     文件       4704  2010-01-28 17:04  ParticleFilter\ParticleFilter\ParticleFilter.cpp

     文件        809  2010-01-28 16:06  ParticleFilter\ParticleFilter\ParticleFilter.h

     文件       4221  2010-01-28 14:38  ParticleFilter\ParticleFilter\ParticleFilter.vcproj

     文件       1413  2010-01-29 14:45  ParticleFilter\ParticleFilter\ParticleFilter.vcproj.randi-PC.randi.user

     文件    1365174  2006-02-08 14:51  ParticleFilter\ParticleFilter\Sample.mpg

     文件     597084  2005-12-12 10:49  ParticleFilter\ParticleFilter\twoball.avi

     文件     422144  2010-01-29 13:00  ParticleFilter\ParticleFilter\twoball.mp4

     文件          0  2010-01-29 11:32  ParticleFilter\ParticleFilter\twoball.mpg

     文件    5244452  2006-02-10 18:19  ParticleFilter\ParticleFilter\V13.avi

     文件   13044736  2010-01-29 14:45  ParticleFilter\ParticleFilter.ncb

     文件        907  2010-01-26 14:31  ParticleFilter\ParticleFilter.sln

    ..A..H.     38912  2010-01-29 14:45  ParticleFilter\ParticleFilter.suo

     目录          0  2010-01-29 14:36  ParticleFilter\ParticleFilter\Debug

     目录          0  2010-01-29 13:32  ParticleFilter\debug

     目录          0  2010-01-29 14:36  ParticleFilter\ParticleFilter

     目录          0  2010-01-29 14:26  ParticleFilter

----------- ---------  ---------- -----  ----

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

评论

共有 条评论