Nooba Plugin API  0.12
API for the Nooba Video Surveillance System
 All Classes Namespaces Functions Enumerations Enumerator
noobapluginapi.h
1 
23 #ifndef NOOBAPLUGINAPI_H
24 #define NOOBAPLUGINAPI_H
25 
26 #include "noobapluginbase.h"
27 
28 //Qt
29 #include <QObject>
30 #include <QString>
31 #include <QStringList>
32 #include <QtPlugin>
33 #include <QMetaType>
34 #include <QImage>
35 #include <QColor>
36 
37 /************************************************************************/
38 /* IMPORTANT: ANY CHANGE TO THE API CORRESPOND TO A CHANGE IN THE */
39 /* VERSION NUMBER. SO IF A CHANGE IS DONE TO THE API */
40 /* REMEMBER TO CHANGE THE API MAJOR AND MINOR VESION */
41 /* NUMBERS ACCORDINGLY. */
42 /* */
43 /* ~ Asitha Nanayakkara <daun07@gmail.com> - 2/3/2013 */
44 /************************************************************************/
45 
46 // forward declaration
47 namespace cv {
48  class Mat;
49 }
50 
51 
53 
56 namespace nooba {
57 
59 
61  enum ParamType {
62  IntParam = 0,
65  RangeParam = 3,
69  };
70 
72 
75  enum VideoState {
79  };
80 
82 
86  enum AlertType {
87  RedAlert = 0,
89  };
90 
92 
95  enum PathType {
96  FilePath = 0,
97  DirPath = 1
98  };
99 }
100 
101 Q_DECLARE_METATYPE(nooba::ParamType) // now ParamTypes can be used with QVariants
102 Q_DECLARE_METATYPE(nooba::VideoState)
103 Q_DECLARE_METATYPE(nooba::AlertType)
104 Q_DECLARE_METATYPE(nooba::PathType)
105 
106 struct ProcParamsPrivate;
107 struct PluginInfoPrivate;
108 struct NoobaPluginAPIPrivate;
109 struct PluginPassDataPrivate;
110 
117 {
118 public:
119 
120  ProcParams();
121  ProcParams(const ProcParams& rhs); // copy constructor
122  ProcParams& operator=(const ProcParams& rhs); // assignment operator
123 
124  ~ProcParams();
125 
126  void setFrameId(int id);
127  int frameId() const;
128 
129  void setFrameRate(double rate);
130  double frameRate() const;
131 
132  void setErrorState(bool isError);
133  bool isError() const;
134 
135  void setErrorMsg(const QString& errMsg);
136  QString errMsg() const;
137 
142  nooba::VideoState currentVideoState() const;
143 
150  bool setVidState(nooba::VideoState state);
151 
152 private:
153 
154  ProcParamsPrivate* createPrivateStruct(const ProcParams& rhs);
155  ProcParamsPrivate* d; // d pointer
156 
157 };
158 
159 Q_DECLARE_METATYPE(ProcParams*)
160 
162 {
163 public:
164 
165  explicit PluginPassData();
166  ~PluginPassData();
167 
168  PluginPassData(const PluginPassData& rhs); // copy constructor
169  PluginPassData& operator=(const PluginPassData& rhs); // assignment operator
170  QStringList strList() const;
171  void setStrList(const QStringList& list);
172  void appendStrList(const QString& str);
173  void setImage(const QImage& image);
174  QImage& getImage() const;
175 
176 private:
177 
178  PluginPassDataPrivate* createPrivateStruct(const PluginPassData& rhs);
179  PluginPassDataPrivate* d; // d pointer
180 };
181 
182 Q_DECLARE_METATYPE(PluginPassData*)
183 Q_DECLARE_METATYPE(PluginPassData)
184 
189 {
190 public:
191 
192  PluginInfo(const QString& name, const int majorVersion, const int minorVersion,
193  const QString& description, const QString& author);
194  PluginInfo(const PluginInfo& rhs); // copy constructor
195  PluginInfo& operator=(const PluginInfo& rhs); // assignment operator
196 
197  ~PluginInfo();
198 
199  QString name() const;
200  QString description() const;
201  QString author() const;
202 
203  int majorVersion() const;
204  int minorVersion() const;
205 
206 private:
207 
208  PluginInfoPrivate *createPrivateStruct(const PluginInfo& rhs);
210 
211 };
212 
214 {
215  Q_OBJECT
216 
217 public:
218 
219  virtual ~NoobaPluginAPI(){}
220 
237  virtual bool init() = 0;
238 
256  virtual bool release() = 0;
257 
278  virtual bool procFrame(const cv::Mat& in, cv::Mat& out, ProcParams& params) = 0;
279 
285  virtual PluginInfo getPluginInfo() const = 0;
286 
287  // functions to create variables that need to be changed by the user.
288  // once created user can see the variables and change them.
289 
309  void createIntParam(const QString& varName, int val, int max = 100, int min = 0)
310  { emit createIntParamRequest(varName, val, max, min);}
311 
331  void createDoubleParam(const QString& varName, double val, double max = 100.0, double min = 0.0)
332  { emit createDoubleParamRequest(varName, val, max, min); }
333 
355  void createStringParam(const QString& varName, QString val, bool isFilePath = false)
356  { emit createStringParamRequest(varName, val, isFilePath);}
357 
375  void createFilePathParam(const QString& varName, QString path = QString(), nooba::PathType pathType = nooba::FilePath, const QString& filter = QString() )
376  { emit createFilePathParamRequest(varName, path, pathType, filter); }
377 
391  void createMultiValParam(const QString& varName, const QStringList& varList)
392  { emit createMultiValParamRequest(varName, varList); }
393 
403  void createLineParam(const QString& varName, const QString& frameViewerTitle, QColor lineColor)
404  { emit createLineParamRequest(varName, frameViewerTitle, lineColor); }
405 
413  void debugMsg(const QString& msg)
414  { emit debugMsgRequest(msg); }
415 
420  void outputData(const PluginPassData& data)
421  { emit outputDataRequest(data); }
422 
423  void outputData(const QStringList& strList, QList<QImage> imageList)
424  { emit outputDataRequest(strList, imageList); }
425 
430  void createFrameViewer(const QString& title, bool isVisible = true)
431  { emit createFrameViewerRequest(title, isVisible); }
432 
438  void updateFrameViewer(const QString& title, const QImage& frame)
439  { emit updateFrameViewerRequest(title, frame); }
440 
445  void setFrameViewerVisibility(const QString& title, bool isVisible)
446  { emit updateFrameViewerVisibilityRequest(title, isVisible); }
447 
452  void generateAlert(const QString& frameViewerTitle, const QString& msg, nooba::AlertType alert) // after version 0.11
453  { emit generateAlertRequest(frameViewerTitle, msg, alert); }
454 
455 signals:
456 
457  void createIntParamRequest(const QString& varName, int val, int max = 100, int min = 0);
458  void createDoubleParamRequest(const QString& varName, double val, double max = 100.0, double min = 0.0);
459  void createStringParamRequest(const QString& varName, QString val, bool isFilePath = false);
460  void createMultiValParamRequest(const QString& varName, const QStringList& varList);
461  void createLineParamRequest(const QString& varName, const QString& frameViewerTitle, QColor lineColor); // after version 0.10
462  void debugMsgRequest(const QString& msg);
463  void outputDataRequest(const PluginPassData& data);
464  void outputDataRequest(const QStringList& strList, QList<QImage> imageList);
465  void createFrameViewerRequest(const QString& title, bool isVisible = true); // added isVisible argument after ver 0.9
466  void updateFrameViewerRequest(const QString& title, const QImage& frame);
467  void updateFrameViewerVisibilityRequest(const QString& title, bool isVisible); // after ver 0.9
468  void createFilePathParamRequest(const QString& varName, QString path,
469  nooba::PathType pathType, const QString& filter); // added in version 0.10
470  void generateAlertRequest(const QString& frameViewerTitle, const QString& msg, nooba::AlertType alert); // after version 0.11
471 
472 public slots:
473 
478  virtual void onIntParamChanged(const QString& varName, int val) {
479  Q_UNUSED(varName) Q_UNUSED(val)
480  }
481 
482  virtual void onDoubleParamChanged(const QString& varName, double val) {
483  Q_UNUSED(varName) Q_UNUSED(val)
484  }
485 
486  virtual void onStringParamChanged(const QString& varName, const QString& val){
487  Q_UNUSED(varName) Q_UNUSED(val)
488  }
489 
490  virtual void onMultiValParamChanged(const QString& varName, const QString& val){
491  Q_UNUSED(varName) Q_UNUSED(val)
492  }
493 
494  virtual void onFilePathParamChanged(const QString& varName, const QString& path) {
495  Q_UNUSED(varName) Q_UNUSED(path)
496  }
497 
503  virtual void inputData(const PluginPassData& data){
504  Q_UNUSED(data)
505  }
506 
507  virtual void inputData(const QStringList& strList, QList<QImage> imageList){
508  Q_UNUSED(strList) Q_UNUSED(imageList)
509  }
510 
511  virtual void onLineParamUpdated(const QString& varName, const QString frameViewerTitle, QLine line)
512  { Q_UNUSED(varName) Q_UNUSED(frameViewerTitle) Q_UNUSED(line) }
513 
514 protected:
515 
520  explicit NoobaPluginAPI();
521 
522 private:
523 
524  NoobaPluginAPI(const NoobaPluginAPI& rhs); // private copy constructor
525  NoobaPluginAPI& operator=(const NoobaPluginAPI& rhs); // private assignment operator
526 
527  NoobaPluginAPIPrivate* d; // d pointer (opaque pointer)
528 };
529 
530 Q_DECLARE_INTERFACE(NoobaPluginAPI, "NoobaVSS.NoobaPluginAPI/" )
531 #endif // NOOBAPLUGINAPI_H