The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MPColorTrackerFilter Class Reference

#include <MPColorTrackerFilter.h>

Collaboration diagram for MPColorTrackerFilter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

HRESULT CheckInputType (const CMediaType *mtIn)
HRESULT CheckTransform (const CMediaType *mtIn, const CMediaType *mtOut)
HRESULT DecideBufferSize (IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties)
STDMETHODIMP get_IPEffect (int *IPEffect)
STDMETHODIMP GetClassID (CLSID *pClsid)
HRESULT GetMediaType (int iPosition, CMediaType *pMediaType)
STDMETHODIMP GetPages (CAUUID *pPages)
STDMETHODIMP NonDelegatingQueryInterface (REFIID riid, void **ppv)
STDMETHODIMP put_IPEffect (int IPEffect)
HRESULT ReadFromStream (IStream *pStream)
HRESULT ScribbleToStream (IStream *pStream)
virtual HRESULT StartStreaming ()
virtual HRESULT StopStreaming ()
HRESULT Transform (IMediaSample *pIn, IMediaSample *pOut)

Static Public Member Functions

CUnknown *WINAPI CreateInstance (LPUNKNOWN punk, HRESULT *phr)

Public Attributes

 DECLARE_IUNKNOWN

Private Member Functions

BOOL CanPerformMPColorTrackerFilter (const CMediaType *pMediaType) const
HRESULT Copy (IMediaSample *pSource, IMediaSample *pDest)
 MPColorTrackerFilter (TCHAR *tszName, LPUNKNOWN punk, HRESULT *phr)
HRESULT Transform (IMediaSample *pMediaSample)
 ~MPColorTrackerFilter ()

Private Attributes

CRefTime m_currentTime
int m_effect
int m_imgHeight
int m_imgWidth
FilterInterface m_interface
CRefTime m_lastValidTime
const long m_lBufferRequest
CCritSec m_MPColorTrackerFilterLock
CRefTime m_resetInterval

Constructor & Destructor Documentation

MPColorTrackerFilter TCHAR *  tszName,
LPUNKNOWN  punk,
HRESULT *  phr
[private]
 

Definition at line 127 of file MPColorTrackerFilter.cpp.

References m_currentTime, m_lastValidTime, and m_resetInterval.

Referenced by CreateInstance().

00128 : CTransformFilter(tszName, punk, CLSID_MPColorTrackerFilter)
00129 , m_effect(IDC_RED)
00130 , m_lBufferRequest(1)
00131 , CPersistStream(punk, phr)
00132 {
00133         char sz[60];
00134         GetProfileStringA("Adaptability", "ResetInterval", "30.0", sz, 60);
00135         m_resetInterval = COARefTime(atof(sz));
00136         
00137         m_currentTime = COARefTime(0.0);     
00138         m_lastValidTime = COARefTime(0.0);
00139         
00141         
00142         srand( (unsigned)time( NULL ) );
00143 } // (Constructor)

~MPColorTrackerFilter  )  [private]
 

Definition at line 558 of file MPColorTrackerFilter.cpp.

00558 {}


Member Function Documentation

BOOL CanPerformMPColorTrackerFilter const CMediaType *  pMediaType  )  const [private]
 

Definition at line 444 of file MPColorTrackerFilter.cpp.

References BOOL.

Referenced by CheckInputType(), and CheckTransform().

00445 {
00446         if (IsEqualGUID(*pMediaType->Type(), MEDIATYPE_Video)) {
00447                 if (IsEqualGUID(*pMediaType->Subtype(), MEDIASUBTYPE_RGB24)) {
00448                         VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pMediaType->Format();
00449                         return (pvi->bmiHeader.biBitCount == 24);
00450                 } 
00451         }
00452         return FALSE;
00453 } // CanPerformMPColorTrackerFilter

HRESULT CheckInputType const CMediaType *  mtIn  ) 
 

Definition at line 353 of file MPColorTrackerFilter.cpp.

References CanPerformMPColorTrackerFilter().

00354 {
00355         // check this is a VIDEOINFOHEADER type
00356         if (*mtIn->FormatType() != FORMAT_VideoInfo)
00357                 return E_INVALIDARG;
00358         // Can we transform this type
00359         if (CanPerformMPColorTrackerFilter(mtIn)) 
00360                 return NOERROR;
00361         return E_FAIL;
00362 }

Here is the call graph for this function:

HRESULT CheckTransform const CMediaType *  mtIn,
const CMediaType *  mtOut
 

Definition at line 371 of file MPColorTrackerFilter.cpp.

References CanPerformMPColorTrackerFilter().

00372 {
00373         if (CanPerformMPColorTrackerFilter(mtIn)) {
00374                 if (*mtIn == *mtOut)
00375                         return NOERROR;   
00376         }
00377         return E_FAIL;
00378 } // CheckTransform

Here is the call graph for this function:

HRESULT Copy IMediaSample *  pSource,
IMediaSample *  pDest
[private]
 

Definition at line 230 of file MPColorTrackerFilter.cpp.

References ASSERT, BYTE, FALSE, LONGLONG, m_imgHeight, m_imgWidth, m_interface, FilterInterface::printFrame(), RGBTRIPLE, and TRUE.

Referenced by Transform().

00231 {
00232         // Copy the sample data
00233         
00234         BYTE *pSourceBuffer, *pDestBuffer;
00235         long lSourceSize = pSource->GetActualDataLength();
00236         long lDestSize  = pDest->GetSize();
00237         
00238         ASSERT(lDestSize >= lSourceSize);
00239         
00240         pSource->GetPointer(&pSourceBuffer);
00241         pDest->GetPointer(&pDestBuffer);
00242         
00243         m_interface.printFrame((RGBTRIPLE*)pSourceBuffer, m_imgWidth, m_imgHeight);
00244         CopyMemory( (PVOID) pDestBuffer,(PVOID) pSourceBuffer,lSourceSize);
00245         
00246         // Copy the sample times
00247         
00248         REFERENCE_TIME TimeStart, TimeEnd;
00249         if (NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) {
00250                 pDest->SetTime(&TimeStart, &TimeEnd);
00251         }
00252         
00253         LONGLONG MediaStart, MediaEnd;
00254         if (pSource->GetMediaTime(&MediaStart,&MediaEnd) == NOERROR) {
00255                 pDest->SetMediaTime(&MediaStart,&MediaEnd);
00256         }
00257         
00258         // Copy the Sync point property
00259         
00260         HRESULT hr = pSource->IsSyncPoint();
00261         if (hr == S_OK) {
00262                 pDest->SetSyncPoint(TRUE);
00263         }
00264         else if (hr == S_FALSE) {
00265                 pDest->SetSyncPoint(FALSE);
00266         }
00267         else {  // an unexpected error has occured...
00268                 return E_UNEXPECTED;
00269         }
00270         
00271         // Copy the media type
00272         
00273         AM_MEDIA_TYPE *pMediaType;
00274         pSource->GetMediaType(&pMediaType);
00275         pDest->SetMediaType(pMediaType);
00276         DeleteMediaType(pMediaType);
00277         
00278         // Copy the preroll property
00279         
00280         hr = pSource->IsPreroll();
00281         if (hr == S_OK) {
00282                 pDest->SetPreroll(TRUE);
00283         }
00284         else if (hr == S_FALSE) {
00285                 pDest->SetPreroll(FALSE);
00286         }
00287         else {  // an unexpected error has occured...
00288                 return E_UNEXPECTED;
00289         }
00290         
00291         // Copy the discontinuity property
00292         hr = pSource->IsDiscontinuity();
00293         
00294         if (hr == S_OK)
00295                 pDest->SetDiscontinuity(TRUE);
00296         
00297         else if (hr == S_FALSE)
00298                 pDest->SetDiscontinuity(FALSE);
00299         
00300         else 
00301                 return E_UNEXPECTED; // an unexpected error has occured...
00302         
00303         // Copy the actual data length
00304         long lDataLength = pSource->GetActualDataLength();
00305         pDest->SetActualDataLength(lDataLength);
00306         
00307         return NOERROR;
00308 } // Copy

Here is the call graph for this function:

CUnknown * CreateInstance LPUNKNOWN  punk,
HRESULT *  phr
[static]
 

Definition at line 152 of file MPColorTrackerFilter.cpp.

References MPColorTrackerFilter().

00153 {
00154         MPColorTrackerFilter *pNewObject = new MPColorTrackerFilter(NAME("Face Tracker MPLab"), punk, phr);
00155         if (pNewObject == NULL)
00156                 *phr = E_OUTOFMEMORY;
00157         return pNewObject;
00158 } // CreateInstance

Here is the call graph for this function:

HRESULT DecideBufferSize IMemAllocator *  pAlloc,
ALLOCATOR_PROPERTIES *  pProperties
 

Definition at line 388 of file MPColorTrackerFilter.cpp.

References ASSERT.

00389 {
00390         // Is the input pin connected
00391         if (m_pInput->IsConnected() == FALSE)
00392                 return E_UNEXPECTED;
00393         ASSERT(pAlloc);
00394         ASSERT(pProperties);
00395         HRESULT hr = NOERROR;
00396         pProperties->cBuffers = 1;
00397         pProperties->cbBuffer = m_pInput->CurrentMediaType().GetSampleSize();
00398         ASSERT(pProperties->cbBuffer);
00399         // Ask the allocator to reserve us some sample memory, NOTE the function
00400         // can succeed (that is return NOERROR) but still not have allocated the
00401         // memory that we requested, so we must check we got whatever we wanted
00402         ALLOCATOR_PROPERTIES Actual;
00403         hr = pAlloc->SetProperties(pProperties,&Actual);
00404         if (FAILED(hr))
00405                 return hr;
00406         ASSERT( Actual.cBuffers == 1 );
00407         if (pProperties->cBuffers > Actual.cBuffers ||
00408                 pProperties->cbBuffer > Actual.cbBuffer) {
00409                 return E_FAIL;  
00410         }
00411         return NOERROR;
00412 } // DecideBufferSize

STDMETHODIMP get_IPEffect int *  IPEffect  ) 
 

Definition at line 527 of file MPColorTrackerFilter.cpp.

References m_MPColorTrackerFilterLock.

00528 {
00529         CAutoLock cAutolock(&m_MPColorTrackerFilterLock);
00530         CheckPointer(IPEffect,E_POINTER);
00531         //    CheckPointer(start,E_POINTER);
00532         //    CheckPointer(length,E_POINTER);
00533         *IPEffect = m_effect;
00534         //    *start = COARefTime(m_effectStartTime);
00535         //    *length = COARefTime(m_effectTime);
00536         return NOERROR;
00537 } // get_IPEffect

STDMETHODIMP GetClassID CLSID *  pClsid  ) 
 

Definition at line 470 of file MPColorTrackerFilter.cpp.

00471 {
00472         return CBaseFilter::GetClassID(pClsid);
00473 } // GetClassID

HRESULT GetMediaType int  iPosition,
CMediaType *  pMediaType
 

Definition at line 422 of file MPColorTrackerFilter.cpp.

00423 {
00424         // Is the input pin connected
00425         if (m_pInput->IsConnected() == FALSE) 
00426                 return E_UNEXPECTED;
00427         // This should never happen
00428         if (iPosition < 0) 
00429                 return E_INVALIDARG;
00430         // Do we have more items to offer
00431         if (iPosition > 0)
00432                 return VFW_S_NO_MORE_ITEMS;
00433         *pMediaType = m_pInput->CurrentMediaType();
00434         return NOERROR;
00435 } // GetMediaType

STDMETHODIMP GetPages CAUUID *  pPages  ) 
 

Definition at line 510 of file MPColorTrackerFilter.cpp.

00511 {
00512         pPages->cElems = 1;
00513         pPages->pElems = (GUID *) CoTaskMemAlloc(sizeof(GUID));
00514         if (pPages->pElems == NULL)
00515                 return E_OUTOFMEMORY; 
00516 //      *(pPages->pElems) = CLSID_MPColorTrackerFilterPropertyPage;
00517         return NOERROR;
00518 } // GetPages

STDMETHODIMP NonDelegatingQueryInterface REFIID  riid,
void **  ppv
 

Definition at line 167 of file MPColorTrackerFilter.cpp.

00168 {
00169         CheckPointer(ppv,E_POINTER);
00170         if (riid == IID_IIPEffect) {
00171                 return GetInterface((IIPEffect *) this, ppv);
00172         } else if (riid == IID_ISpecifyPropertyPages) {
00173                 return GetInterface((ISpecifyPropertyPages *) this, ppv);
00174         } else {
00175                 return CTransformFilter::NonDelegatingQueryInterface(riid, ppv);
00176         }
00177 } // NonDelegatingQueryInterface

STDMETHODIMP put_IPEffect int  IPEffect  ) 
 

Definition at line 546 of file MPColorTrackerFilter.cpp.

References m_effect, m_MPColorTrackerFilterLock, and TRUE.

00547 {
00548         CAutoLock cAutolock(&m_MPColorTrackerFilterLock);
00549         m_effect = IPEffect;
00550         //    m_effectStartTime = COARefTime(start);
00551         //    m_effectTime = COARefTime(length);
00552         SetDirty(TRUE);
00553         return NOERROR;
00554 } // put_IPEffect

HRESULT ReadFromStream IStream *  pStream  ) 
 

Definition at line 496 of file MPColorTrackerFilter.cpp.

References m_effect, and READIN.

00497 {
00498         HRESULT hr;
00499         READIN(m_effect);
00500         return NOERROR;
00501 } // ReadFromStream

HRESULT ScribbleToStream IStream *  pStream  ) 
 

Definition at line 482 of file MPColorTrackerFilter.cpp.

References m_effect, and WRITEOUT.

00483 {
00484         HRESULT hr;
00485         WRITEOUT(m_effect);
00486         return NOERROR;
00487 } // ScribbleToStream

HRESULT StartStreaming  )  [virtual]
 

Definition at line 181 of file MPColorTrackerFilter.cpp.

00181                                             {
00182 //      m_colortracker.InitStreaming();
00183         return S_OK;
00184 }

HRESULT StopStreaming  )  [virtual]
 

Definition at line 188 of file MPColorTrackerFilter.cpp.

00188                                            {
00189 //      m_colortracker.EndStreaming();
00190         return S_OK;
00191 }

HRESULT Transform IMediaSample *  pMediaSample  )  [private]
 

Definition at line 332 of file MPColorTrackerFilter.cpp.

References BYTE, m_imgHeight, m_imgWidth, m_interface, and FilterInterface::runInterface().

00333 {
00334         AM_MEDIA_TYPE* pType = &m_pInput->CurrentMediaType();
00335         VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pType->pbFormat;
00336         
00337         BYTE *pData;                // Pointer to the actual image buffer
00338         pMediaSample->GetPointer(&pData);
00339         
00340         // Get the image properties from the BITMAPINFOHEADER
00341 
00342         m_imgWidth = pvi->bmiHeader.biWidth;
00343         m_imgHeight = pvi->bmiHeader.biHeight;
00344 
00345         m_interface.runInterface(pData, m_imgWidth, m_imgHeight);
00346 
00347         return NOERROR;
00348 }

Here is the call graph for this function:

HRESULT Transform IMediaSample *  pIn,
IMediaSample *  pOut
 

Definition at line 208 of file MPColorTrackerFilter.cpp.

References Copy(), and m_currentTime.

00209 {
00210         // Copy the properties across
00211         HRESULT hr = Copy(pIn, pOut);
00212         if (FAILED(hr)) {
00213                 return hr;
00214         }
00215         
00216         CRefTime temp;
00217         pIn->GetTime((REFERENCE_TIME *) &m_currentTime, (REFERENCE_TIME *)&temp);
00218         
00219         return Transform(pOut);
00220         
00221 } // Transform

Here is the call graph for this function:


Member Data Documentation

DECLARE_IUNKNOWN
 

Definition at line 24 of file MPColorTrackerFilter.h.

CRefTime m_currentTime [private]
 

Definition at line 72 of file MPColorTrackerFilter.h.

Referenced by MPColorTrackerFilter(), and Transform().

int m_effect [private]
 

Definition at line 67 of file MPColorTrackerFilter.h.

Referenced by put_IPEffect(), ReadFromStream(), and ScribbleToStream().

int m_imgHeight [private]
 

Definition at line 70 of file MPColorTrackerFilter.h.

Referenced by Copy(), and Transform().

int m_imgWidth [private]
 

Definition at line 69 of file MPColorTrackerFilter.h.

Referenced by Copy(), and Transform().

FilterInterface m_interface [private]
 

Definition at line 76 of file MPColorTrackerFilter.h.

Referenced by Copy(), and Transform().

CRefTime m_lastValidTime [private]
 

Definition at line 73 of file MPColorTrackerFilter.h.

Referenced by MPColorTrackerFilter().

const long m_lBufferRequest [private]
 

Definition at line 68 of file MPColorTrackerFilter.h.

CCritSec m_MPColorTrackerFilterLock [private]
 

Definition at line 66 of file MPColorTrackerFilter.h.

Referenced by get_IPEffect(), and put_IPEffect().

CRefTime m_resetInterval [private]
 

Definition at line 74 of file MPColorTrackerFilter.h.

Referenced by MPColorTrackerFilter().


The documentation for this class was generated from the following files:
Generated on Mon Nov 8 17:08:34 2004 for MPT by  doxygen 1.3.9.1