没有合适的资源?快使用搜索试试~ 我知道了~
视频运动目标跟踪
4星 · 超过85%的资源 需积分: 9 27 下载量 27 浏览量
2012-11-20
09:31:08
上传
评论 1
收藏 8KB TXT 举报
温馨提示
试读
8页
手动圈定欲跟踪运动目标,基于Mean-Shift.
资源推荐
资源详情
资源评论
// 1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <ctype.h>
IplImage *image = 0, *hsv = 0, *hue = 0, *mask = 0, *backproject = 0, *histimg = 0;//用HSV中的Hue分量进行跟踪
CvHistogram *hist = 0;//直方图类
int backproject_mode = 0;
int select_object = 0;
int track_object = 0;
int show_hist = 1;
CvPoint origin;
CvRect selection;
CvRect track_window;
CvBox2D track_box; // Meanshift跟踪算法返回的Box类
CvConnectedComp track_comp;
int hdims = 50; // 划分直方图bins的个数,越多越精确
float hranges_arr[] = {0,180};//像素值的范围
float* hranges = hranges_arr;//用于初始化CvHistogram类
int vmin = 10, vmax = 256, smin = 30;
void on_mouse( int event, int x, int y, int flags,void *NotUsed)//该函数用于选择跟踪目标
{
if( !image )
//
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <ctype.h>
IplImage *image = 0, *hsv = 0, *hue = 0, *mask = 0, *backproject = 0, *histimg = 0;//用HSV中的Hue分量进行跟踪
CvHistogram *hist = 0;//直方图类
int backproject_mode = 0;
int select_object = 0;
int track_object = 0;
int show_hist = 1;
CvPoint origin;
CvRect selection;
CvRect track_window;
CvBox2D track_box; // Meanshift跟踪算法返回的Box类
CvConnectedComp track_comp;
int hdims = 50; // 划分直方图bins的个数,越多越精确
float hranges_arr[] = {0,180};//像素值的范围
float* hranges = hranges_arr;//用于初始化CvHistogram类
int vmin = 10, vmax = 256, smin = 30;
void on_mouse( int event, int x, int y, int flags,void *NotUsed)//该函数用于选择跟踪目标
{
if( !image )
return;
if( image->origin )
y = image->height - y;
if( select_object )//如果处于选择跟踪物体阶段,则对selection用当前的鼠标位置进行设置
{
selection.x = MIN(x,origin.x);
selection.y = MIN(y,origin.y);
selection.width = selection.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 );
selection.width -= selection.x;
selection.height -= selection.y;
}
switch( event )
{
case CV_EVENT_LBUTTONDOWN://开始点击选择跟踪物体
origin = cvPoint(x,y);
selection = cvRect(x,y,0,0);//坐标
select_object = 1;//表明开始进行选取
break;
case CV_EVENT_LBUTTONUP:
select_object = 0;//选取完成
if( image->origin )
y = image->height - y;
if( select_object )//如果处于选择跟踪物体阶段,则对selection用当前的鼠标位置进行设置
{
selection.x = MIN(x,origin.x);
selection.y = MIN(y,origin.y);
selection.width = selection.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 );
selection.width -= selection.x;
selection.height -= selection.y;
}
switch( event )
{
case CV_EVENT_LBUTTONDOWN://开始点击选择跟踪物体
origin = cvPoint(x,y);
selection = cvRect(x,y,0,0);//坐标
select_object = 1;//表明开始进行选取
break;
case CV_EVENT_LBUTTONUP:
select_object = 0;//选取完成
剩余7页未读,继续阅读
资源评论
- su19870002014-10-08挺好的,有参考价值!
- jihongli200820122013-01-18还可以,有一定的参考价值,但不是我所需要的
Tobe_1
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功