mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
grabber api and feature unification (#462)
* move setvideomode to common place * implement more croping and 3d support * more api unification * more refactoring * osx fix * next step * add a mock for osx grabber. Now it is possible to test compile on none osx platforms. * more unifications ... * remove obsolete includes and grabbers are not dyn allocated. dispmanx needs rework an probaly not work atm * first version of dispmanx mock. it compiles, but outputs a black image * now dispmanx mock works! * activate mocks in travis linux build prepare dispmanx to rgb image out * dispmanx now with image rgb output fix deadlock with w/h -1 in grabber v4l cleanups * fix json * fix some runtime stuff * Update FramebufferWrapper.cpp fix missing code * unify grabframe * 3d and croping for amlogic * fix setimage not working * make use of templates save some codelines * save more code lines
This commit is contained in:
@@ -9,14 +9,20 @@
|
||||
#include <utils/Components.h>
|
||||
#include <utils/GrabbingMode.h>
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <utils/Image.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/VideoMode.h>
|
||||
|
||||
class ImageProcessor;
|
||||
class Grabber;
|
||||
class DispmanxFrameGrabber;
|
||||
|
||||
class GrabberWrapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GrabberWrapper(QString grabberName, const int priority, hyperion::Components grabberComponentId=hyperion::COMP_GRABBER);
|
||||
GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned width, unsigned height, const unsigned updateRate_Hz, const int priority, hyperion::Components grabberComponentId=hyperion::COMP_GRABBER);
|
||||
|
||||
virtual ~GrabberWrapper();
|
||||
|
||||
@@ -30,8 +36,32 @@ public:
|
||||
///
|
||||
virtual void stop();
|
||||
|
||||
void setImageProcessorEnabled(bool enable);
|
||||
|
||||
static QStringList availableGrabbers();
|
||||
|
||||
|
||||
public:
|
||||
template <typename Grabber_T>
|
||||
void transferFrame(Grabber_T &grabber)
|
||||
{
|
||||
unsigned w = grabber.getImageWidth();
|
||||
unsigned h = grabber.getImageHeight();
|
||||
if (_imageProcessorEnabled && ( _image.width() != w || _image.height() != h))
|
||||
{
|
||||
_processor->setSize(w, h);
|
||||
_image.resize(w, h);
|
||||
}
|
||||
|
||||
if (grabber.grabFrame(_image) >= 0)
|
||||
{
|
||||
emit emitImage(_priority, _image, _timeout_ms);
|
||||
_processor->process(_image, _ledColors);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public slots:
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
|
||||
@@ -50,8 +80,9 @@ public slots:
|
||||
/// Set the video mode (2D/3D)
|
||||
/// @param[in] mode The new video mode
|
||||
///
|
||||
virtual void setVideoMode(const VideoMode videoMode) = 0;
|
||||
virtual void setVideoMode(const VideoMode videoMode);
|
||||
|
||||
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
|
||||
|
||||
signals:
|
||||
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
|
||||
@@ -59,6 +90,7 @@ signals:
|
||||
protected:
|
||||
|
||||
void setColors(const std::vector<ColorRgb> &ledColors, const int timeout_ms);
|
||||
|
||||
QString _grabberName;
|
||||
|
||||
/// Pointer to Hyperion for writing led values
|
||||
@@ -70,6 +102,12 @@ protected:
|
||||
/// The timer for generating events with the specified update rate
|
||||
QTimer _timer;
|
||||
|
||||
/// The update rate [Hz]
|
||||
const int _updateInterval_ms;
|
||||
|
||||
/// The timeout of the led colors [ms]
|
||||
const int _timeout_ms;
|
||||
|
||||
/// The Logger instance
|
||||
Logger * _log;
|
||||
|
||||
@@ -80,4 +118,15 @@ protected:
|
||||
ImageProcessor * _processor;
|
||||
|
||||
hyperion::Components _grabberComponentId;
|
||||
|
||||
Grabber *_ggrabber;
|
||||
|
||||
/// The image used for grabbing frames
|
||||
Image<ColorRgb> _image;
|
||||
|
||||
/// The list with computed led colors
|
||||
std::vector<ColorRgb> _ledColors;
|
||||
|
||||
bool _imageProcessorEnabled;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user