TLIB documentation
 

tlDigitizerDX.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This file is part of the TLIB computer vision library.
00004 //  Copyright (C) 2003-2008 Sebastien Grange
00005 //  Copyright (C) 2003-2007 VRAI Group, EPFL
00006 //  All rights reserved.
00007 // 
00008 //  This library is free software; you can redistribute it and/or modify
00009 //  it under the terms of the GNU General Public License("GPL") version 2
00010 //  as published by the Free Software Foundation.
00011 // 
00012 //  <http://www.tuyphon.com/tlib>
00013 //
00014 /////////////////////////////////////////////////////////////////////////////////
00015 
00016 
00017 #ifndef __TLDIGITIZERDX_H__
00018 #define __TLDIGITIZERDX_H__
00019 
00020 
00021 
00022 #include "tlVision.h"
00023 #include "tlDigitizer.h"
00024 
00025 // DirectX headers
00026 #ifndef __TLDIRECTXH__
00027 #define __TLDIRECTXH__
00028 #include <atlbase.h>
00029 #include <qedit.h>
00030 #include <dshow.h>
00031 #ifdef _TLIB_BUILD_
00032 #include <streams.h>
00033 #endif
00034 #endif
00035 
00036 
00037 
00038 class SampleGrabberCallback : public ISampleGrabberCB
00039 {
00040 private:
00041   bool *ready;
00042 
00043 public:
00044   SampleGrabberCallback (bool *imageReady) { ready = imageReady; };
00045   virtual ~SampleGrabberCallback () {return; };
00046   STDMETHODIMP_(ULONG) AddRef  () { return 1; }
00047   STDMETHODIMP_(ULONG) Release () { return 2; }
00048 
00049   STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject) {
00050     if (NULL == ppvObject) return E_POINTER;
00051     if (riid == __uuidof(IUnknown)) {
00052       *ppvObject = static_cast<IUnknown*>(this);
00053       return S_OK;
00054     }
00055     if (riid == __uuidof(ISampleGrabberCB)) {
00056       *ppvObject = static_cast<ISampleGrabberCB*>(this);
00057       return S_OK;
00058     }
00059     return E_NOTIMPL;
00060   }
00061 
00062   STDMETHODIMP SampleCB(double Time, IMediaSample *pSample) {
00063     return E_NOTIMPL;
00064   }
00065 
00066   STDMETHODIMP BufferCB(double Time, BYTE *pBuffer, long BufferLen) {
00067     *ready = true;
00068     return S_OK;
00069   }
00070 };
00071 
00072 
00073 
00074 // interface
00075 class tlDigitizerDX : public tlDigitizer
00076 {
00077 private:
00078   bool                    imageReady;
00079   SampleGrabberCallback   *cb;
00080 
00081 protected:
00082   ISampleGrabber          *pGrabber;
00083   IGraphBuilder           *pGraph;
00084   ICaptureGraphBuilder2   *pCapture;
00085   BYTE                    *buffer;
00086   IAMStreamConfig         *pVConfig;
00087   IMediaEvent             *pEvent;
00088   int                     index;
00089   int                     fps;
00090 
00091 public:
00092   tlDigitizerDX  ();
00093   tlDigitizerDX  (int width, int height);
00094   virtual ~tlDigitizerDX ();
00095 
00096   virtual int open            (int index = 0);
00097   virtual int open            (int width, int height, int index = 0);
00098   virtual int close           ();
00099 
00100   virtual int setSize         (int width, int height);
00101 
00102   virtual int grab            (tlImage *image);
00103   virtual int grab            (tlImage *image, tlRect *rect);
00104   virtual int grabQueued      (tlImage *image);
00105   virtual int grabQueued      (tlImage *image, tlRect *rect);
00106 
00107   int setFrameRate (int fps);
00108 };
00109 
00110 
00111 #endif
00112 


TLIB documentation - generated on 7 May 2008
Please address any questions to seb@tuyphon.com
(C) 2001-2008 - S. Grange
(C) 2001-2007 - VRAI Group, EPFL
All Rights Reserved.