资源简介
基于opencv 实现的LK跟踪算法,可以跟踪摄像头视频或是视频文件,效果很好。
代码片段和文件信息
/* Demo of modified Lucas-Kanade optical flow algorithm.
See the printf below */
#ifdef _CH_
#pragma package
#endif
#ifndef _EiC
#include “cv.h“
#include “highgui.h“
#include
#include
#endif
IplImage *image = 0 *grey = 0 *prev_grey = 0 *pyramid = 0 *prev_pyramid = 0 *swap_temp;
int win_size = 10;
const int MAX_COUNT = 500;
CvPoint2D32f* points[2] = {00} *swap_points;
char* status = 0;
int count = 0;
int need_to_init = 0;
int night_mode = 0;
int flags = 0;
int add_remove_pt = 0;
CvPoint pt;
void on_mouse( int event int x int y int flags void* param )
{
if( !image )
return;
if( image->origin )
y = image->height - y;
if( event == CV_EVENT_LBUTTONDOWN )
{
pt = cvPoint(xy);
add_remove_pt = 1;
}
}
int main( int argc char** argv )
{
CvCapture* capture = 0;
capture = cvCaptureFromAVI( argv[1] );
if( !capture )
{
fprintf(stderr“Could not initialize capturing...\n“);
return -1;
}
printf( “\tESC - quit the program\n“
“\tr - auto-initialize tracking\n“
“\tc - delete all the points\n“
“\tn - switch the \“night\“ mode on/off\n“
“To add/remove a feature point click it\n“ );
cvNamedWindow( “LkDemo“ 0 );
cvSetMouseCallback( “LkDemo“ on_mouse 0 );
for(;;)
{
IplImage* frame = 0;
int i k c;
frame = cvQueryframe( capture );
if( !frame )
break;
if( !image )
{
/* allocate all the buffers */
image = cvCreateImage( cvGetSize(frame) 8 3 );
image->origin = frame->origin;
grey = cvCreateImage( cvGetSize(frame) 8 1 );
prev_grey = cvCreateImage( cvGetSize(frame) 8 1 );
pyramid = cvCreateImage( cvGetSize(frame) 8 1 );
prev_pyramid = cvCreateImage( cvGetSize(frame) 8 1 );
points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));
points[1] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));
status = (char*)cvAlloc(MAX_COUNT);
flags = 0;
}
cvCopy( frame image 0 );
cvCvtColor( image grey CV_BGR2GRAY );
if( night_mode )
cvZero( image );
if( need_to_init )
{
/* automatic initialization */
IplImage* eig = cvCreateImage( cvGetSize(grey) 32 1 );
IplImage* temp = cvCreateImage( cvGetSize(grey) 32 1 );
double quality = 0.01;
double min_distance = 10;
count = MAX_COUNT;
cvGoodFeaturesToTrack( grey eig temp points[1] &count
quality min_distance 0 3 0 0.04 );
cvFindCornerSubPix( grey points[1] count
cvSize(win_size
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 19246080 2010-11-24 15:48 LKDemo\Debug\liu.avi
文件 2262016 2007-07-08 17:35 LKDemo\Debug\lkdemo.bsc
文件 196675 2007-08-21 11:04 LKDemo\Debug\lkdemo.exe
文件 220544 2007-08-21 11:04 LKDemo\Debug\lkdemo.ilk
文件 25457 2007-08-21 11:04 LKDemo\Debug\lkdemo.obj
文件 3103468 2007-08-21 11:04 LKDemo\Debug\lkdemo.pch
文件 476160 2007-08-21 11:04 LKDemo\Debug\lkdemo.pdb
文件 0 2007-07-08 17:35 LKDemo\Debug\lkdemo.sbr
文件 50176 2010-12-29 11:01 LKDemo\Debug\vc60.idb
文件 77824 2007-08-21 11:04 LKDemo\Debug\vc60.pdb
文件 432700 2007-02-24 15:18 LKDemo\Debug\video1.avi
文件 5362 2010-12-29 11:01 LKDemo\lkdemo.c
文件 3484 2007-06-29 12:07 LKDemo\lkdemo.dsp
文件 520 2007-06-29 12:07 LKDemo\lkdemo.dsw
文件 58368 2010-12-29 13:13 LKDemo\lkdemo.ncb
文件 349184 2010-12-29 13:13 LKDemo\lkdemo.opt
文件 246 2010-12-02 20:11 LKDemo\lkdemo.plg
文件 432700 2007-02-24 15:18 LKDemo\video1.avi
文件 136 2009-12-25 15:01 LKDemo\说明.txt
目录 0 2010-12-29 09:57 LKDemo\Debug
目录 0 2010-12-29 13:13 LKDemo
----------- --------- ---------- ----- ----
26941100 21
相关资源
- OpenCV 3 Computer Vision Application Programmi
- cvMatchShapes
- 贾志刚Opencv图像处理视频教程学习笔
- 用于具有逐周期堵转电流限制器的
- opencv_3rdparty-ffmpeg-master_20161202.zip
- 学习opencv pdf
- vs2010+opencv 图像处理,边缘检测,可设
- 基于Quartus II的FPGA/CPLD 设计扫描版PD
- 基于Quartus II的FPGA/CPLD数字系统设计
- OpenCV By Example.pdf
- opencv实现图像旋转任意角度边界正好
- zw_学习OpenCV(中文版).zip
- 学习OpenCV(中文版)pdf155532
- Wincc IndustrialDataBridge(2)
- opencv3 神经网络字母识别源码.zip
- SecureCRT+FX 8.5.3x64-Build1867汉化补丁完美
- lbp特征提取代码
- 无线通信AndreaGoldsmith杨鸿文等译.rar
- 图片尺寸与格式转换软件.7z
- opencv 2.3.1
- ippicv_2020_win_intel64_20191018_general.zip
- FieldtheoryofGuidedwavesCollin__2nd.pdf
- PowerBuilder6.0 绿色版
- OPENCV车道检测与车辆识别
- opencv立体匹配算法BM+SGBM+VAR运行官方立
- gcc、make、build-essential离线安装包及依
- 基于opencv的手写数字字符识别
- 易表.net10.3 Build 1310(附破解)+龙族小
- PowerBuilder 7.0.3补丁
- opencv数字识别更新
评论
共有 条评论