COcvVideoControllerComp.h
Go to the documentation of this file.
1 #ifndef iocv_COcvVideoControllerComp_included
2 #define iocv_COcvVideoControllerComp_included
3 
4 
5 // OpenCV includes
6 #include <opencv/cv.h>
7 #include <opencv/highgui.h>
8 #undef min
9 #undef max
10 
11 // ACF includes
12 #include "istd/TDelPtr.h"
13 #include "icomp/CComponentBase.h"
15 
16 // ACF-Solutions includes
18 #include "imm/IVideoController.h"
19 
20 
21 namespace iocv
22 {
23 
24 
29  public iproc::TSyncProcessorCompBase<icam::IBitmapAcquisition>,
30  virtual public imm::IVideoController
31 {
32 public:
34 
35  I_BEGIN_COMPONENT(COcvVideoControllerComp);
36  I_REGISTER_INTERFACE(istd::IChangeable);
37  I_REGISTER_INTERFACE(imm::IMediaController);
38  I_REGISTER_INTERFACE(imm::IVideoInfo);
39  I_REGISTER_INTERFACE(imm::IVideoController);
40  I_ASSIGN(m_frameDataCompPtr, "FrameData", "Frame instance will be loaded with loader", true, "FrameData");
41  I_END_COMPONENT;
42 
44 
45  // reimplemented (icam::IBitmapAcquisition)
46  virtual istd::CIndex2d GetBitmapSize(const iprm::IParamsSet* paramsPtr) const;
47 
48  // reimplemented (iproc::IProcessor)
49  virtual int DoProcessing(
50  const iprm::IParamsSet* paramsPtr,
51  const istd::IPolymorphic* inputPtr,
52  istd::IChangeable* outputPtr,
53  ibase::IProgressManager* progressManagerPtr = NULL);
54 
55  // reimplemented (imm::IMediaController)
56  virtual QString GetOpenedMediumUrl() const;
57  virtual bool OpenMediumUrl(const QString& url, bool autoPlay = true);
58  virtual void CloseMedium();
59  virtual bool IsPlaying() const;
60  virtual bool SetPlaying(bool state = true);
61  virtual double GetMediumLength() const;
62  virtual double GetCurrentPosition() const;
63  virtual bool SetCurrentPosition(double position);
64  virtual int GetSupportedFeatures() const;
65 
66  // reimplemented (imm::IVideoInfo)
67  virtual int GetFramesCount() const;
68  virtual double GetFrameIntervall() const;
69  virtual istd::CIndex2d GetFrameSize() const;
70  virtual double GetPixelAspectRatio() const;
71 
72  // reimplemented (imm::IVideoController)
73  virtual int GetCurrentFrame() const;
74  virtual bool SetCurrentFrame(int frameIndex);
75 
76  // reimplemented (ifile::IFileTypeInfo)
77  virtual bool GetFileExtensions(QStringList& result, int flags = -1, bool doAppend = false) const;
78  virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const;
79 
80 protected:
81  virtual bool GrabCurrentFrame(iimg::IBitmap& result) const;
82  virtual bool SeekToPosition(int frameIndex) const;
83 
84  // reimplemented (icomp::CComponentBase)
85  virtual void OnComponentDestroyed();
86 
87 private:
88  void EnsureMediumClosed();
89  int GetStreamPosition() const;
90  bool MoveToNextFrame() const;
91 
92 private:
93  I_REF(istd::IChangeable, m_frameDataCompPtr);
94 
95  QString m_mediumUrl;
96  bool m_isPlaying;
97 
98  struct CaptureAccessor: public istd::DefaultAccessor<CvCapture>
99  {
100  static void Delete(CvCapture* ptr){if (ptr != NULL) cvReleaseCapture(&ptr);}
101  };
102 
104  mutable int m_currentFrameIndex;
105  int m_framesCount;
106 };
107 
108 
109 } // namespace iocv
110 
111 
112 #endif // !iocv_COcvVideoControllerComp_included
113 
virtual void OnComponentDestroyed()
virtual double GetFrameIntervall() const
virtual int DoProcessing(const iprm::IParamsSet *paramsPtr, const istd::IPolymorphic *inputPtr, istd::IChangeable *outputPtr, ibase::IProgressManager *progressManagerPtr=NULL)
virtual int GetCurrentFrame() const
virtual istd::CIndex2d GetFrameSize() const
virtual double GetCurrentPosition() const
virtual int GetSupportedFeatures() const
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const
virtual double GetPixelAspectRatio() const
virtual bool GetFileExtensions(QStringList &result, int flags=-1, bool doAppend=false) const
virtual QString GetOpenedMediumUrl() const
virtual bool SeekToPosition(int frameIndex) const
virtual istd::CIndex2d GetBitmapSize(const iprm::IParamsSet *paramsPtr) const
virtual bool GrabCurrentFrame(iimg::IBitmap &result) const
virtual bool SetPlaying(bool state=true)
virtual double GetMediumLength() const
virtual bool IsPlaying() const
virtual bool SetCurrentFrame(int frameIndex)
iproc::TSyncProcessorCompBase< icam::IBitmapAcquisition > BaseClass
virtual bool SetCurrentPosition(double position)
Component for video controlling using OpenCV API.
virtual int GetFramesCount() const
virtual bool OpenMediumUrl(const QString &url, bool autoPlay=true)

© 2007-2011 Witold Gantzke and Kirill Lepskiy