|
| 1 | +#pragma once |
| 2 | + |
| 3 | +// QT includes |
| 4 | +#include <QObject> |
| 5 | +#include <QTimer> |
| 6 | + |
| 7 | +// Utils includes |
| 8 | +#include <utils/Image.h> |
| 9 | +#include <utils/ColorRgb.h> |
| 10 | +#include <utils/ColorRgba.h> |
| 11 | +#include <utils/GrabbingMode.h> |
| 12 | +#include <utils/VideoMode.h> |
| 13 | + |
| 14 | +// Forward class declaration |
| 15 | +class OsxFrameGrabber; |
| 16 | +class Hyperion; |
| 17 | +class ImageProcessor; |
| 18 | + |
| 19 | +/// |
| 20 | +/// The OsxWrapper uses an instance of the OsxFrameGrabber to obtain ImageRgb's from the |
| 21 | +/// displayed content. This ImageRgb is processed to a ColorRgb for each led and commmited to the |
| 22 | +/// attached Hyperion. |
| 23 | +/// |
| 24 | +class OsxWrapper: public QObject |
| 25 | +{ |
| 26 | + Q_OBJECT |
| 27 | +public: |
| 28 | + /// |
| 29 | + /// Constructs the osx frame grabber with a specified grab size and update rate. |
| 30 | + /// |
| 31 | + /// @param[in] display Index of the display to grab |
| 32 | + /// @param[in] grabWidth The width of the grabbed image [pixels] |
| 33 | + /// @param[in] grabHeight The height of the grabbed images [pixels] |
| 34 | + /// @param[in] updateRate_Hz The image grab rate [Hz] |
| 35 | + /// @param[in] hyperion The instance of Hyperion used to write the led values |
| 36 | + /// |
| 37 | + OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, Hyperion * hyperion); |
| 38 | + |
| 39 | + /// |
| 40 | + /// Destructor of this osx frame grabber. Releases any claimed resources. |
| 41 | + /// |
| 42 | + virtual ~OsxWrapper(); |
| 43 | + |
| 44 | +public slots: |
| 45 | + /// |
| 46 | + /// Starts the grabber wich produces led values with the specified update rate |
| 47 | + /// |
| 48 | + void start(); |
| 49 | + |
| 50 | + /// |
| 51 | + /// Performs a single frame grab and computes the led-colors |
| 52 | + /// |
| 53 | + void action(); |
| 54 | + |
| 55 | + /// |
| 56 | + /// Stops the grabber |
| 57 | + /// |
| 58 | + void stop(); |
| 59 | + |
| 60 | + /// |
| 61 | + /// Set the grabbing mode |
| 62 | + /// @param[in] mode The new grabbing mode |
| 63 | + /// |
| 64 | + void setGrabbingMode(const GrabbingMode mode); |
| 65 | + |
| 66 | + /// |
| 67 | + /// Set the video mode (2D/3D) |
| 68 | + /// @param[in] mode The new video mode |
| 69 | + /// |
| 70 | + void setVideoMode(const VideoMode videoMode); |
| 71 | + |
| 72 | +private: |
| 73 | + /// The update rate [Hz] |
| 74 | + const int _updateInterval_ms; |
| 75 | + /// The timeout of the led colors [ms] |
| 76 | + const int _timeout_ms; |
| 77 | + /// The priority of the led colors |
| 78 | + const int _priority; |
| 79 | + |
| 80 | + /// The timer for generating events with the specified update rate |
| 81 | + QTimer _timer; |
| 82 | + |
| 83 | + /// The image used for grabbing frames |
| 84 | + Image<ColorRgb> _image; |
| 85 | + /// The actual grabber |
| 86 | + OsxFrameGrabber * _frameGrabber; |
| 87 | + /// The processor for transforming images to led colors |
| 88 | + ImageProcessor * _processor; |
| 89 | + |
| 90 | + /// The list with computed led colors |
| 91 | + std::vector<ColorRgb> _ledColors; |
| 92 | + |
| 93 | + /// Pointer to Hyperion for writing led values |
| 94 | + Hyperion * _hyperion; |
| 95 | +}; |
0 commit comments