运动目标跟踪及检测源代码(camshift 算法)

运动目标跟踪及检测源代码(camshift 算法)

ID:26591333

大小:44.00 KB

页数:7页

时间:2018-11-27

运动目标跟踪及检测源代码(camshift 算法)_第1页
运动目标跟踪及检测源代码(camshift 算法)_第2页
运动目标跟踪及检测源代码(camshift 算法)_第3页
运动目标跟踪及检测源代码(camshift 算法)_第4页
运动目标跟踪及检测源代码(camshift 算法)_第5页
资源描述:

《运动目标跟踪及检测源代码(camshift 算法)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、该运行文件在VC6.0环境下编译通过,是一个stand-alone运行程序,不需要OPENCV的DLL库支持。在运行之前,请先连接好USB接口的摄像头。然后可以用鼠标选定欲跟踪目标。#ifdef_CH_#pragmapackage#endif#ifndef_EiC#include"cv.h"#include"highgui.h"#include#include#endifIplImage*image=0,*hsv=0,*hue=0,*mask=0,*backproject=0,*histimg=0;Cv

2、Histogram*hist=0;intbackproject_mode=0;intselect_object=0;inttrack_object=0;intshow_hist=1;  CvPointorigin;CvRectselection;CvRecttrack_window;CvBox2Dtrack_box; //tracking返回的区域box,带角度CvConnectedComptrack_comp;inthdims=48;    //划分HIST的个数,越高越精确floathranges_arr[]={0,180};float*hrange

3、s=hranges_arr;intvmin=10,vmax=256,smin=30;voidon_mouse(intevent,intx,inty,intflags){   if(!image)       return;   if(image->origin)       y=image->height-y;   if(select_object)   {       selection.x=MIN(x,origin.x);       selection.y=MIN(y,origin.y);       selection.width=selecti

4、on.x+CV_IABS(x-origin.x);       selection.height=selection.y+CV_IABS(y-origin.y);               selection.x=MAX(selection.x,0);       selection.y=MAX(selection.y,0);       selection.width=MIN(selection.width,image->width);       selection.height=MIN(selection.height,image->height

5、);       selection.width-=selection.x;       selection.height-=selection.y;   }   switch(event)   {   caseCV_EVENT_LBUTTONDOWN:       origin=cvPoint(x,y);       selection=cvRect(x,y,0,0);       select_object=1;       break;   caseCV_EVENT_LBUTTONUP:       select_object=0;       i

6、f(selection.width>0&&selection.height>0)           track_object=-1;#ifdef_DEBUG   printf("/n#鼠标的选择区域:");    printf("/n  X=%d,Y=%d,Width=%d,Height=%d",       selection.x,selection.y,selection.width,selection.height);#endif       break;   }}CvScalarhsv2rgb(floathue){   intrgb[3],p,

7、sector;   staticconstintsector_data[][3]=       {{0,2,1},{1,2,0},{1,0,2},{2,0,1},{2,1,0},{0,1,2}};   hue*=0.033333333333333333333333333333333f;   sector=cvFloor(hue);   p=cvRound(255*(hue-sector));   p^=sector&1?255:0;   rgb[sector_data[sector][0]]=255;   rgb[sector_data[sector][

8、1]]=0;   rgb[sector_data[sector][2]]=p;#

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。