資源簡介
關于運動背景下的運動補償程序,效果好于幀差法和普通背景建模法

代碼片段和文件信息
/***************************************************
This?is?the?main?Grabber?code.??It?builds?the?Direct?Show?graphs?
and?then?inserts?SampleGrabbers?right?before?the?renderers.??It?
then?changes?all?of?the?renderers?to?NullRenderers.??This?code?
supports?any?number?of?audio?or?video?streams.??Raw?midi?streams
are?not?supported?--?I?didn‘t?think?I?should?bother.
This?code?was?intended?to?be?used?inside?of?a?matlab?interface
but?can?be?used?as?a?generic?grabber?class?for?anyone?who?needs?
one.
Written?by?Micah?Richert.
07/14/2005
**************************************************/
#include?“DDGrab.h“
GUID?NULLGUID?=?{0};
CSampleGrabberCB::CSampleGrabberCB()
{
pbFormat?=?NULL;
frameNr?=?0;
disabled?=?FALSE;
}
CSampleGrabberCB::~CSampleGrabberCB()
{
if?(pbFormat)?free(pbFormat);
for?(int?f=0;fames.size();f++)?if?(frames[f])?free(frames[f]);
}
//?Fake?out?any?COM?QI‘ing
//
STDMETHODIMP?CSampleGrabberCB::QueryInterface(REFIID?riid?void?**?ppv)
{
if?(!ppv)?return?E_POINTER;
if(?riid?==?IID_ISampleGrabberCB?||?riid?==?IID_IUnknown?)?
{
*ppv?=?(void?*)?static_cast?(?this?);
return?NOERROR;
}
return?E_NOINTERFACE;
}
//?The?sample?grabber?is?calling?us?back?on?its?deliver?thread.
//?This?is?NOT?the?main?app?thread!
//
STDMETHODIMP?CSampleGrabberCB::BufferCB(?double?dblSampleTime?BYTE?*?pBuffer?long?lBufferSize?)
{
if?(disabled)?return?0;
if?(!pBuffer)?return?E_POINTER;
frameNr++;
bool?foundNr?=?false;
for?(int?i=0;iameNrs.size();i++)?if?(frameNrs[i]?==?frameNr)?foundNr?=?true;
if?(frameNrs.size()?==?0?||?foundNr)
{
BYTE*?tmp?=?new?BYTE[lBufferSize];
if?(!tmp)?return?E_OUTOFMEMORY;
memcpy(tmppBufferlBufferSize);
frames.push_back(tmp);
frameBytes.push_back(lBufferSize);
}
return?0;
}
void?DDGrabber::cleanUp()
{
IEnumFilters*?filterList;
IbaseFilter*?filt;
ULONG?tmp;
int?i;
for?(i=0;?i for?(i=0;?i
VideoCBs.clear();
AudioCBs.clear();
if?(!FAILED(pGraphBuilder->EnumFilters(&filterList)))
{
filterList->Reset();
while?(filterList->Next(1?&filt?&tmp)?==?S_OK)
{
filt->Release();
}
filterList->Release();
}
pGraphBuilder?=?NULL;
}
void?DDGrabber::MyFreeMediaType(AM_MEDIA_TYPE&?mt)
{
if?(mt.cbFormat?!=?0)
{
CoTaskMemFree((PVOID)mt.pbFormat);
mt.cbFormat?=?0;
mt.pbFormat?=?NULL;
}
if?(mt.pUnk?!=?NULL)
{
//?Unecessary?because?pUnk?should?not?be?used?but?safest.
mt.pUnk->Release();
mt.pUnk?=?NULL;
}
}
PIN_INFO?DDGrabber::getPinInfo(IPin*?pin)
{
PIN_INFO info?=?{0};
if?(pin)
{
if?(!FAILED(pin->QueryPinInfo(&info)))
{
info.pFilter->Release();
}
}
return?info;
}
IPin*?DDGrabber::getInputPin(IbaseFilter*?filt)
{
IPin*?pin?=?NULL;
IEnumPins*?pinList;
ULONG?tmp;
if?(!filt)?return?NULL;
//get?the?input
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2006-05-20?16:51??matlab視頻讀取
?????文件??????15457??2005-07-14?18:01??matlab視頻讀取\DDGrab.cpp
?????文件???????3205??2005-07-14?17:50??matlab視頻讀取\DDGrab.h
?????文件???????4280??2005-07-14?18:35??matlab視頻讀取\makedll.m
?????文件???????6511??2005-07-14?17:08??matlab視頻讀取\mexDDGrab.cpp
?????文件??????36864??2005-07-14?18:41??matlab視頻讀取\mexDDGrab.dll
?????文件???????5050??2005-07-27?14:05??matlab視頻讀取\mmread.m
-----------?---------??----------?-----??----
????????????????71585????????????????????8
評論
共有 條評論