91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 413KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-09
  • 語言: 其他
  • 標(biāo)簽: vc、opencv??

資源簡介

基于幀間差分法的運動目標(biāo)檢測vc源代碼,調(diào)用OpenCV編程實現(xiàn),文件中包含運行時所要的運動視頻。

資源截圖

代碼片段和文件信息

#include?“cv.h“
#include?“highgui.h“
#include?
#include?
#include?
#include?
#include?

//?various?tracking?parameters?(in?seconds)
const?double?MHI_DURATION?=?0.5;
const?double?MAX_TIME_DELTA?=?0.5;
const?double?MIN_TIME_DELTA?=?0.05;
const?int?N?=?3;

//
const?int?CONTOUR_MAX_AERA?=?16;

//?ring?image?buffer
IplImage?**buf?=?0;
int?last?=?0;

//?temporary?images
IplImage?*mhi?=?0;?//?MHI:?motion?history?image

CvFilter?filter?=?CV_GAUSSIAN_5x5;
CvConnectedComp?*cur_comp?min_comp;
CvConnectedComp?comp;
CvMemStorage?*storage;
CvPoint?pt[4];

//??參數(shù):
//??img?–?輸入視頻幀
//??dst?–?檢測結(jié)果
void??update_mhi(?IplImage*?img?IplImage*?dst?int?diff_threshold?)
{
????double?timestamp?=?clock()/100.;?//?get?current?time?in?seconds
????CvSize?size?=?cvSize(img->widthimg->height);?//?get?current?frame?size
????int?i?j?idx1?idx2;
????IplImage*?silh;
????uchar?val;
????float?temp;
????IplImage*?pyr?=?cvCreateImage(?cvSize((size.width?&?-2)/2?(size.height?&?-2)/2)?8?1?);
????CvMemStorage?*stor;
????CvSeq?*cont?*result?*squares;
????CvSeqReader?reader;

????if(?!mhi?||?mhi->width?!=?size.width?||?mhi->height?!=?size.height?)?
????{
????????if(?buf?==?0?)?
????????{
????????????buf?=?(IplImage**)malloc(N*sizeof(buf[0]));
????????????memset(?buf?0?N*sizeof(buf[0]));
????????}
????????
????????for(?i?=?0;?i?????????{
????????????cvReleaseImage(?&buf[i]?);
????????????buf[i]?=?cvCreateImage(?size?IPL_DEPTH_8U?1?);
????????????cvZero(?buf[i]?);
????????}
????????cvReleaseImage(?&mhi?);
????????mhi?=?cvCreateImage(?size?IPL_DEPTH_32F?1?);
????????cvZero(?mhi?);?//?clear?MHI?at?the?beginning
????}?//?end?of?if(mhi)

????cvCvtColor(?img?buf[last]?CV_BGR2GRAY?);?//?convert?frame?to?grayscale

????idx1?=?last;
????idx2?=?(last?+?1)?%?N;?//?index?of?(last?-?(N-1))th?frame?
????last?=?idx2;

????//?做幀差
????silh?=?buf[idx2];
????cvAbsDiff(?buf[idx1]?buf[idx2]?silh?);?//?get?difference?between?frames
????
????//?對差圖像做二值化
????cvThreshold(?silh?silh?30?255?CV_THRESH_BINARY?);?//?and?threshold?it
????
????cvUpdateMotionHistory(?silh?mhi?timestamp?MHI_DURATION?);?//?update?MHI
????cvCvtScale(?mhi?dst?255./MHI_DURATION?
??????(MHI_DURATION?-?timestamp)*255./MHI_DURATION?);????
????cvCvtScale(?mhi?dst?255./MHI_DURATION?0?);????
????
????//?中值濾波,消除小的噪聲
????cvSmooth(?dst?dst?CV_MEDIAN?3?0?0?0?);
????
????//?向下采樣,去掉噪聲
????cvPyrDown(?dst?pyr?7?);
????cvDilate(?pyr?pyr?0?1?);??//?做膨脹操作,消除目標(biāo)的不連續(xù)空洞
????cvPyrUp(?pyr?dst?7?);
????//
????//?下面的程序段用來找到輪廓
????//
????//?Create?dynamic?structure?and?sequence.
????stor?=?cvCreateMemStorage(0);
????cont?=?cvCreateSeq(CV_SEQ_ELTYPE_POINT?sizeof(CvSeq)?sizeof(CvPoint)??stor);
????
????//?找到所有輪廓
????cvFindContours(?dst?stor?&cont?sizeof(CvContour)?
????????????????????CV_RETR_LIST?CV_CHAIN_APPROX_SIMPLE?cvPoint(00));
/*
????for(;cont;cont?=?cont->h_next)
????{???
????????//?Number?point?must?be?more?than?or?equal?to?6?(for?cvFitEllipse_32f).????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????140??2007-02-24?14:01??運動目標(biāo)檢測\Makefile

?????文件???????4905??2007-02-24?14:02??運動目標(biāo)檢測\motiondetect.c

?????文件???????4220??2007-03-07?20:41??運動目標(biāo)檢測\motiondetect.dsp

?????文件????????549??2007-03-07?20:41??運動目標(biāo)檢測\motiondetect.dsw

?????文件?????432700??2006-09-05?00:10??運動目標(biāo)檢測\video.avi

?????目錄??????????0??2010-04-24?23:51??運動目標(biāo)檢測

-----------?---------??----------?-----??----

???????????????442514????????????????????6


評論

共有 條評論

相關(guān)資源