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:
redPanther
2017-08-12 07:55:32 +02:00
committed by GitHub
parent 317a903b14
commit 9eff6384cc
61 changed files with 830 additions and 748 deletions

View File

@@ -11,33 +11,37 @@ class SwitchOption: public Option
{
public:
SwitchOption(const QString &name,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
const QMap<QString, T> &switches=QMap<QString, T>())
: Option(name, description, valueName, defaultValue), _switches(switches)
{}
SwitchOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
const QMap<QString, T> &switches=QMap<QString, T>())
: Option(names, description, valueName, defaultValue), _switches(switches)
{}
SwitchOption(const QCommandLineOption &other, const QMap<QString, T> &switches)
: Option(other), _switches(switches)
{}
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
const QMap<QString, T> &switches=QMap<QString, T>())
: Option(name, description, valueName, defaultValue), _switches(switches)
{}
const QMap<QString, T> &getSwitches() const{return _switches;};
virtual bool validate(Parser &parser, QString &switch_) override{return hasSwitch(switch_);}
bool hasSwitch(const QString &switch_){return _switches.contains(switch_.toLower());}
void setSwitches(const QMap<QString, T> &_switches){this->_switches = _switches;}
void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;}
void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());}
T & switchValue(Parser & parser){return _switches[value(parser).toLower()];}
SwitchOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
const QMap<QString, T> &switches=QMap<QString, T>())
: Option(names, description, valueName, defaultValue), _switches(switches)
{}
SwitchOption(const QCommandLineOption &other, const QMap<QString, T> &switches)
: Option(other), _switches(switches)
{}
virtual ~SwitchOption() {}
const QMap<QString, T> &getSwitches() const { return _switches; }
virtual bool validate(Parser &parser, QString &switch_) override { return hasSwitch(switch_); }
bool hasSwitch(const QString &switch_) { return _switches.contains(switch_.toLower()); }
void setSwitches(const QMap<QString, T> &_switches) { this->_switches = _switches; }
void addSwitch(const QString &switch_, T value=T()) { _switches[switch_.toLower()] = value; }
void removeSwitch(const QString &switch_) { _switches.remove(switch_.toLower()); }
T & switchValue(Parser & parser) { return _switches[value(parser).toLower()]; }
protected:
QMap<QString, T> _switches;
QMap<QString, T> _switches;
};
}

View File

@@ -29,14 +29,17 @@ public:
/// height)
/// @return Zero on success else negative
///
int grabFrame(Image<ColorBgr> & image);
int grabFrame(Image<ColorRgb> & image);
private:
/**
* Returns true if video is playing over the amlogic chip
* @return True if video is playing else false
*/
bool isVideoPlaying();
private:
/** The snapshot/capture device of the amlogic video chip */
int _amlogicCaptureDev;
Image<ColorBgr> _image;
};

View File

@@ -1,16 +1,7 @@
#pragma once
// Utils includes
#include <utils/Image.h>
#include <utils/ColorBgr.h>
#include <utils/ColorRgb.h>
#include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h>
// Forward class declaration
class AmlogicGrabber;
class Hyperion;
class ImageProcessor;
#include <grabber/AmlogicGrabber.h>
///
/// The DispmanxWrapper uses an instance of the DispmanxFrameGrabber to obtain ImageRgb's from the
@@ -34,7 +25,7 @@ public:
///
/// Destructor of this dispmanx frame grabber. Releases any claimed resources.
///
virtual ~AmlogicWrapper();
virtual ~AmlogicWrapper() {};
public slots:
///
@@ -42,19 +33,7 @@ public slots:
///
virtual void action();
virtual void setVideoMode(const VideoMode mode);
private:
/// The update rate [Hz]
const int _updateInterval_ms;
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The image used for grabbing frames
Image<ColorBgr> _image;
/// The actual grabber
AmlogicGrabber * _grabber;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
AmlogicGrabber _grabber;
};

View File

@@ -1,10 +1,15 @@
#pragma once
// BCM includes
#pragma GCC system_header
#include <bcm_host.h>
#ifdef PLATFORM_RPI
#pragma GCC system_header
#include <bcm_host.h>
#else
#include <grabber/DispmanxFrameGrabberMock.h>
#endif
// Utils includes
#include <utils/Image.h>
#include <utils/ColorRgba.h>
#include <hyperion/Grabber.h>
@@ -24,15 +29,6 @@ public:
DispmanxFrameGrabber(const unsigned width, const unsigned height);
~DispmanxFrameGrabber();
///
/// Updates the frame-grab flags as used by the VC library for frame grabbing
///
/// @param vc_flags The snapshot grabbing mask
///
void setFlags(const int vc_flags);
void setCropping(const unsigned cropLeft, const unsigned cropRight,
const unsigned cropTop, const unsigned cropBottom);
///
/// Captures a single snapshot of the display and writes the data to the given image. The
@@ -42,9 +38,16 @@ public:
/// @param[out] image The snapped screenshot (should be initialized with correct width and
/// height)
///
void grabFrame(Image<ColorRgba> & image);
int grabFrame(Image<ColorRgb> & image);
private:
///
/// Updates the frame-grab flags as used by the VC library for frame grabbing
///
/// @param vc_flags The snapshot grabbing mask
///
void setFlags(const int vc_flags);
/// Handle to the display that is being captured
DISPMANX_DISPLAY_HANDLE_T _vc_display;
@@ -63,4 +66,8 @@ private:
// size of the capture buffer in Pixels
unsigned _captureBufferSize;
// rgba output buffer
Image<ColorRgba> _image_rgba;
};

View File

@@ -0,0 +1,40 @@
#pragma once
#ifndef PLATFORM_RPI
#include <QRect>
#include <utils/Image.h>
#include <utils/ColorRgba.h>
typedef int DISPMANX_DISPLAY_HANDLE_T;
typedef Image<ColorRgba> DISPMANX_RESOURCE;
typedef DISPMANX_RESOURCE* DISPMANX_RESOURCE_HANDLE_T;
const int VC_IMAGE_RGBA32 = 1;
const int DISPMANX_SNAPSHOT_FILL = 1;
typedef int DISPMANX_TRANSFORM_T;
struct DISPMANX_MODEINFO_T {
int width;
int height;
};
struct VC_RECT_T {
int left;
int top;
int width;
int height;
};
void bcm_host_init();
void bcm_host_deinit();
int vc_dispmanx_display_open(int);
void vc_dispmanx_display_close(int);
int vc_dispmanx_display_get_info(int, DISPMANX_MODEINFO_T *vc_info);
DISPMANX_RESOURCE_HANDLE_T vc_dispmanx_resource_create(int,int width,int height, uint32_t *);
void vc_dispmanx_resource_delete(DISPMANX_RESOURCE_HANDLE_T resource);
int vc_dispmanx_resource_read_data(DISPMANX_RESOURCE_HANDLE_T vc_resource, VC_RECT_T *rectangle, void* capturePtr, unsigned capturePitch);
void vc_dispmanx_rect_set(VC_RECT_T *rectangle, int left, int top, int width, int height);
int vc_dispmanx_snapshot(int, DISPMANX_RESOURCE_HANDLE_T resource, int vc_flags);
#endif

View File

@@ -1,16 +1,9 @@
#pragma once
// Utils includes
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/ColorRgba.h>
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h>
// Forward class declaration
class DispmanxFrameGrabber;
class ImageProcessor;
#include <grabber/DispmanxFrameGrabber.h>
///
/// The DispmanxWrapper uses an instance of the DispmanxFrameGrabber to obtain ImageRgb's from the
@@ -34,7 +27,7 @@ public:
///
/// Destructor of this dispmanx frame grabber. Releases any claimed resources.
///
virtual ~DispmanxWrapper();
virtual ~DispmanxWrapper() {};
public slots:
///
@@ -42,25 +35,7 @@ public slots:
///
virtual void action();
void setCropping(const unsigned cropLeft, const unsigned cropRight, const unsigned cropTop, const unsigned cropBottom);
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(const VideoMode videoMode);
private:
/// The update rate [Hz]
const int _updateInterval_ms;
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The image used for grabbing frames
Image<ColorRgba> _image;
/// The actual grabber
DispmanxFrameGrabber * _grabber;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
DispmanxFrameGrabber _grabber;
};

View File

@@ -28,7 +28,7 @@ public:
/// @param[out] image The snapped screenshot (should be initialized with correct width and
/// height)
///
void grabFrame(Image<ColorRgb> & image);
int grabFrame(Image<ColorRgb> & image);
private:
/// Framebuffer file descriptor

View File

@@ -1,15 +1,7 @@
#pragma once
// Utils includes
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h>
// Forward class declaration
class FramebufferFrameGrabber;
class ImageProcessor;
#include <grabber/FramebufferFrameGrabber.h>
///
/// The FramebufferWrapper uses an instance of the FramebufferFrameGrabber to obtain ImageRgb's from the
@@ -33,7 +25,7 @@ public:
///
/// Destructor of this framebuffer frame grabber. Releases any claimed resources.
///
virtual ~FramebufferWrapper();
virtual ~FramebufferWrapper() {};
public slots:
///
@@ -41,23 +33,7 @@ public slots:
///
virtual void action();
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(const VideoMode videoMode);
private:
/// The update rate [Hz]
const int _updateInterval_ms;
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The image used for grabbing frames
Image<ColorRgb> _image;
/// The actual grabber
FramebufferFrameGrabber * _grabber;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
FramebufferFrameGrabber _grabber;
};

View File

@@ -1,7 +1,11 @@
#pragma once
// OSX includes
#ifdef __APPLE__
#include <CoreGraphics/CoreGraphics.h>
#else
#include <grabber/OsxFrameGrabberMock.h>
#endif
// Utils includes
#include <utils/ColorRgb.h>
@@ -31,7 +35,7 @@ public:
/// @param[out] image The snapped screenshot (should be initialized with correct width and
/// height)
///
void grabFrame(Image<ColorRgb> & image);
int grabFrame(Image<ColorRgb> & image);
private:
/// display

View File

@@ -0,0 +1,34 @@
#pragma once
#ifndef __APPLE__
/*
* this is a mock up for compiling and testing osx wrapper on no osx platform.
* this will show a test image and rotate the colors.
*
*/
#include <utils/Image.h>
#include <utils/ColorRgb.h>
typedef int CGDirectDisplayID;
typedef Image<ColorRgb> CGImage;
typedef CGImage* CGImageRef;
typedef unsigned char CFData;
typedef CFData* CFDataRef;
typedef unsigned CGDisplayCount;
const int kCGDirectMainDisplay = 0;
void CGGetActiveDisplayList(int max, CGDirectDisplayID *displays, CGDisplayCount *displayCount);
CGImageRef CGDisplayCreateImage(CGDirectDisplayID display);
void CGImageRelease(CGImageRef image);
CGImageRef CGImageGetDataProvider(CGImageRef image);
CFDataRef CGDataProviderCopyData(CGImageRef image);
unsigned char* CFDataGetBytePtr(CFDataRef imgData);
unsigned CGImageGetWidth(CGImageRef image);
unsigned CGImageGetHeight(CGImageRef image);
unsigned CGImageGetBitsPerPixel(CGImageRef image);
unsigned CGImageGetBytesPerRow(CGImageRef image);
void CFRelease(CFDataRef imgData);
#endif

View File

@@ -1,16 +1,7 @@
#pragma once
// Utils includes
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/ColorRgba.h>
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h>
// Forward class declaration
class OsxFrameGrabber;
class ImageProcessor;
#include <grabber/OsxFrameGrabber.h>
///
/// The OsxWrapper uses an instance of the OsxFrameGrabber to obtain ImageRgb's from the
@@ -35,7 +26,7 @@ public:
///
/// Destructor of this osx frame grabber. Releases any claimed resources.
///
virtual ~OsxWrapper();
virtual ~OsxWrapper() {};
public slots:
///
@@ -43,23 +34,7 @@ public slots:
///
virtual void action();
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(const VideoMode videoMode);
private:
/// The update rate [Hz]
const int _updateInterval_ms;
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The image used for grabbing frames
Image<ColorRgb> _image;
/// The actual grabber
OsxFrameGrabber * _grabber;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
OsxFrameGrabber _grabber;
};

View File

@@ -10,11 +10,8 @@
#include <QRectF>
// util includes
#include <utils/ColorRgb.h>
#include <utils/PixelFormat.h>
#include <hyperion/Grabber.h>
// grabber includes
#include <grabber/VideoStandard.h>
/// Capture class for V4L2 devices
@@ -28,8 +25,8 @@ public:
V4L2Grabber(const QString & device,
int input,
VideoStandard videoStandard, PixelFormat pixelFormat,
int width,
int height,
unsigned width,
unsigned height,
int frameDecimation,
int horizontalPixelDecimation,
int verticalPixelDecimation
@@ -39,12 +36,9 @@ public:
QRectF getSignalDetectionOffset();
bool getSignalDetectionEnabled();
int grabFrame(Image<ColorRgb> &);
public slots:
void setCropping(int cropLeft,
int cropRight,
int cropTop,
int cropBottom);
void setSignalThreshold(
double redSignalThreshold,
double greenSignalThreshold,

View File

@@ -1,11 +1,6 @@
#pragma once
// Hyperion includes
#include <hyperion/Hyperion.h>
#include <hyperion/ImageProcessor.h>
#include <hyperion/GrabberWrapper.h>
// Grabber includes
#include <grabber/V4L2Grabber.h>
class V4L2Wrapper : public GrabberWrapper
@@ -17,8 +12,8 @@ public:
int input,
VideoStandard videoStandard,
PixelFormat pixelFormat,
int width,
int height,
unsigned width,
unsigned height,
int frameDecimation,
int pixelDecimation,
double redSignalThreshold,
@@ -26,7 +21,7 @@ public:
double blueSignalThreshold,
const int priority,
bool useGrabbingMode);
virtual ~V4L2Wrapper();
virtual ~V4L2Wrapper() {};
bool getSignalDetectionEnable();
@@ -36,7 +31,6 @@ public slots:
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax);
void setVideoMode(VideoMode mode);
void setSignalDetectionEnable(bool enable);
// signals:
@@ -50,12 +44,6 @@ private slots:
void checkSources();
private:
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The V4L2 grabber
V4L2Grabber _grabber;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
};

View File

@@ -22,8 +22,6 @@ public:
virtual ~X11Grabber();
bool Setup();
Image<ColorRgb> & grab();
///
/// Captures a single snapshot of the display and writes the data to the given image. The
@@ -33,11 +31,13 @@ public:
/// @param[out] image The snapped screenshot (should be initialized with correct width and
/// height)
///
int grabFrame(Image<ColorRgb> & image);
virtual int grabFrame(Image<ColorRgb> & image, bool forceUpdate=false);
///
/// update dimension according current screen
int updateScreenDimensions();
int updateScreenDimensions(bool force=false);
virtual void setVideoMode(VideoMode mode);
private:
bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
@@ -63,6 +63,8 @@ private:
unsigned _screenWidth;
unsigned _screenHeight;
unsigned _src_x;
unsigned _src_y;
Image<ColorRgb> _image;

View File

@@ -1,14 +1,12 @@
#pragma once
// Utils includes
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h>
#include <grabber/X11Grabber.h>
// some include of xorg defines "None" this is also used by QT and has to be undefined to avoid collisions
#ifdef None
#undef None
#endif
// Forward class declaration
class X11Grabber;
class ImageProcessor;
///
/// The X11Wrapper uses an instance of the X11Grabber to obtain ImageRgb's from the
@@ -31,42 +29,18 @@ public:
///
/// Destructor of this framebuffer frame grabber. Releases any claimed resources.
///
virtual ~X11Wrapper();
virtual ~X11Wrapper() {};
public slots:
///
/// Starts the grabber wich produces led values with the specified update rate
///
bool start();
///
/// Performs a single frame grab and computes the led-colors
///
virtual void action();
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(const VideoMode videoMode);
private:
/// The update rate [Hz]
const int _updateInterval_ms;
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The image used for grabbing frames
Image<ColorRgb> _image;
/// The actual grabber
X11Grabber * _grabber;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
X11Grabber _grabber;
bool _init;
bool _x11SetupSuccess;
};

View File

@@ -3,6 +3,7 @@
#include <QObject>
#include <cstdint>
#include <utils/ColorRgb.h>
#include <utils/Image.h>
#include <utils/VideoMode.h>
#include <utils/GrabbingMode.h>
@@ -16,24 +17,28 @@ class Grabber : public QObject
public:
Grabber(QString grabberName, int width=0, int height=0, int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0);
~Grabber();
virtual ~Grabber();
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(VideoMode mode);
virtual void setVideoMode(VideoMode mode);
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
/// gets resulting height of image
const int getImageWidth() { return _width; };
virtual const int getImageWidth() { return _width; };
/// gets resulting width of image
const int getImageHeight() { return _height; };
virtual const int getImageHeight() { return _height; };
protected:
ImageResampler _imageResampler;
bool _useImageResampler;
/// the selected VideoMode
VideoMode _videoMode;

View File

@@ -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;
};

View File

@@ -260,7 +260,7 @@ public slots:
///
/// Clears all priority channels. This will switch the leds off until a new priority is written.
///
void clearall();
void clearall(bool forceClearAll=false);
/// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run

View File

@@ -42,7 +42,6 @@ public:
///
void setSize(const unsigned width, const unsigned height);
/// Returns starte of black border detector
bool blackBorderDetectorEnabled();
@@ -59,7 +58,20 @@ public slots:
/// Enable or disable the black border detector
void setLedMappingType(int mapType);
public:
public:
///
/// Specifies the width and height of 'incomming' images. This will resize the buffer-image to
/// match the given size.
/// NB All earlier obtained references will be invalid.
///
/// @param[in] image The dimensions taken from image
///
template <typename Pixel_T>
void setSize(const Image<Pixel_T> &image)
{
setSize(image.width(), image.height());
}
///
/// Processes the image to a list of led colors. This will update the size of the buffer-image
/// if required and call the image-to-leds mapping to determine the mean color per led.
@@ -71,18 +83,25 @@ public:
template <typename Pixel_T>
std::vector<ColorRgb> process(const Image<Pixel_T>& image)
{
// Ensure that the buffer-image is the proper size
setSize(image.width(), image.height());
// Check black border detection
verifyBorder(image);
// Create a result vector and call the 'in place' functionl
std::vector<ColorRgb> colors;
switch (_mappingType)
if (image.width()>0 && image.height()>0)
{
case 1: colors = _imageToLeds->getUniLedColor(image); break;
default: colors = _imageToLeds->getMeanLedColor(image);
// Ensure that the buffer-image is the proper size
setSize(image);
// Check black border detection
verifyBorder(image);
// Create a result vector and call the 'in place' functionl
switch (_mappingType)
{
case 1: colors = _imageToLeds->getUniLedColor(image); break;
default: colors = _imageToLeds->getMeanLedColor(image);
}
}
else
{
Warning(_log, "ImageProcessor::process called without image size 0");
}
// return the computed colors
@@ -98,19 +117,25 @@ public:
template <typename Pixel_T>
void process(const Image<Pixel_T>& image, std::vector<ColorRgb>& ledColors)
{
// Ensure that the buffer-image is the proper size
setSize(image.width(), image.height());
// Check black border detection
verifyBorder(image);
// Determine the mean-colors of each led (using the existing mapping)
switch (_mappingType)
if ( image.width()>0 && image.height()>0)
{
case 1: _imageToLeds->getUniLedColor(image, ledColors); break;
default: _imageToLeds->getMeanLedColor(image, ledColors);
}
// Ensure that the buffer-image is the proper size
setSize(image);
// Check black border detection
verifyBorder(image);
// Determine the mean-colors of each led (using the existing mapping)
switch (_mappingType)
{
case 1: _imageToLeds->getUniLedColor(image, ledColors); break;
default: _imageToLeds->getMeanLedColor(image, ledColors);
}
}
else
{
Warning(_log, "ImageProcessor::process called without image size 0");
}
}
///

View File

@@ -118,7 +118,7 @@ public:
///
/// Clears all priority channels
///
void clearAll();
void clearAll(bool forceClearAll=false);
///
/// Updates the current time. Channels with a configured time out will be checked and cleared if
@@ -152,5 +152,4 @@ private:
QTimer _timer;
QTimer _blockTimer;
};

View File

@@ -20,7 +20,7 @@ public:
int cropTop,
int cropBottom);
void set3D(VideoMode mode);
void setVideoMode(VideoMode mode);
void processImage(const uint8_t * data, int width, int height, int lineLength, PixelFormat pixelFormat, Image<ColorRgb> & outputImage) const;