Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SampleGrabberCallback.hh
1 #ifndef __SAMPLEGRABERCALLBACK_HH__
2 #define __SAMPLEGRABERCALLBACK_HH__
3 #include <BIAS_DeclSpec.hh>
4 
5 #ifdef BIAS_HAVE_DSHOW
6 # include <qedit.h>
7 #endif
8 
9 namespace BIAS {
10 
11  typedef void (*SampleGrabberCBF)(double time_sec);
12 
13  /** @brief sample grabber callback class for grabbing single frames only
14  @author Marc Grauel 2008 (www.vision-n.de) */
15  class BIASVideoSource_EXPORT SampleGrabberCallback
16 #ifdef BIAS_HAVE_DSHOW
17  : public ISampleGrabberCB
18 #endif
19  {
20  public:
22 
24 
25  /** @brief resets internal trigger
26  call this before grabbing a frame or the internal trigger can't signal
27  that the SampleCB callback has been called.*/
28  void SampleTriggerArm();
29 
30  /** @brief waits until one frame ist grabbed.*/
31  void SampleTriggerWait();
32 
33  /** @brief returns trigger state
34  use this if you want to wait for the sample trigger on your own...*/
35  bool SampleTriggered();
36 
37  void SetTargetBuffer(unsigned char *TargetBuffer, unsigned int size,
38  unsigned width, unsigned height);
39 
40  /** use NULL to disable usage of CB function */
41  inline void SetCallbackFunction(SampleGrabberCBF function)
42  { CallbackFunction_ = function; }
43 
44  inline bool HasCallbackFunction() const
45  { return (CallbackFunction_!=0); }
46 
47 #ifdef BIAS_HAVE_DSHOW
48  STDMETHODIMP SampleCB(double SampleTime, IMediaSample *pSample);
49  STDMETHODIMP BufferCB(double SampleTime, BYTE *pBuffer, long BufferLen);
50  STDMETHODIMP QueryInterface(REFIID riid, void ** ppv);
51  STDMETHODIMP_(ULONG) AddRef() { return 2; }
52  STDMETHODIMP_(ULONG) Release() { return 1; }
53 #endif
54 
55  protected:
57  unsigned char *TargetBuffer_;
58  unsigned int TargetSize_;
59 
60  unsigned Width_;
61  unsigned Height_;
62 
64  }; // class SampleGrabberCallBack
65 
66 } //namespace
67 
68 
69 
70 
71 #endif
sample grabber callback class for grabbing single frames only
void SetCallbackFunction(SampleGrabberCBF function)
use NULL to disable usage of CB function
void(* SampleGrabberCBF)(double time_sec)