hyperion.ng
GrabberWrapper.h
1 #pragma once
2 
3 #include <QObject>
4 #include <QJsonObject>
5 #include <QJsonArray>
6 #include <QString>
7 #include <QStringList>
8 
9 #include <utils/Logger.h>
10 #include <utils/Components.h>
11 #include <utils/Image.h>
12 #include <utils/ColorRgb.h>
13 #include <utils/VideoMode.h>
14 #include <utils/settings.h>
15 
16 class Grabber;
17 class GlobalSignals;
18 class QTimer;
19 
23 class GrabberWrapper : public QObject
24 {
25  Q_OBJECT
26 public:
27  GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned width, unsigned height, const unsigned updateRate_Hz = 0);
28 
29  virtual ~GrabberWrapper();
30 
34  virtual bool start();
35 
39  virtual void stop();
40 
41  static QStringList availableGrabbers();
42 
43 public:
44  template <typename Grabber_T>
45  bool transferFrame(Grabber_T &grabber)
46  {
47  unsigned w = grabber.getImageWidth();
48  unsigned h = grabber.getImageHeight();
49  if ( _image.width() != w || _image.height() != h)
50  {
51  _image.resize(w, h);
52  }
53 
54  int ret = grabber.grabFrame(_image);
55  if (ret >= 0)
56  {
57  emit systemImage(_grabberName, _image);
58  return true;
59  }
60  return false;
61  }
62 
63 public slots:
67  virtual void action() = 0;
68 
73  virtual void setVideoMode(const VideoMode& videoMode);
74 
82  virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
83 
89  virtual void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
90 
91 signals:
95  void systemImage(const QString& name, const Image<ColorRgb>& image);
96 
97 protected:
98 
99  QString _grabberName;
100 
102  QTimer* _timer;
103 
106 
109 
110  Grabber *_ggrabber;
111 
114 };
Definition: Logger.h:32
QTimer * _timer
The timer for generating events with the specified update rate.
Definition: GrabberWrapper.h:102
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
Set the crop values.
Definition: GrabberWrapper.cpp:97
virtual void action()=0
virtual method, should perform single frame grab and computes the led-colors
unsigned height() const
Returns the height of the image.
Definition: Image.h:129
virtual void setVideoMode(const VideoMode &videoMode)
Set the video mode (2D/3D)
Definition: GrabberWrapper.cpp:88
Image< ColorRgb > _image
The image used for grabbing frames.
Definition: GrabberWrapper.h:113
Logger * _log
The Logger instance.
Definition: GrabberWrapper.h:108
Singleton instance for simple signal sharing across threads, should be never used with Qt:DirectConne...
Definition: GlobalSignals.h:13
unsigned width() const
Returns the width of the image.
Definition: Image.h:119
void systemImage(const QString &name, const Image< ColorRgb > &image)
Emit the final processed image.
int _updateInterval_ms
The calced update rate [ms].
Definition: GrabberWrapper.h:105
void resize(const unsigned width, const unsigned height)
Resize the image.
Definition: Image.h:178
This class will be inherted by FramebufferWrapper and others which contains the real capture interfac...
Definition: GrabberWrapper.h:23
The Grabber class is responsible to apply image resizes (with or without ImageResampler) Overwrite th...
Definition: Grabber.h:17
virtual void stop()
Stop grabber.
Definition: GrabberWrapper.cpp:46
virtual bool start()
Starts the grabber wich produces led values with the specified update rate.
Definition: GrabberWrapper.cpp:39
virtual void handleSettingsUpdate(const settings::type &type, const QJsonDocument &config)
Handle settings update from HyperionDaemon Settingsmanager emit.
Definition: GrabberWrapper.cpp:102