Reduce copying of data

Former-commit-id: 858ca2331d68458acf87359df87cb25fd051fa30
This commit is contained in:
johan 2014-03-04 20:32:54 +01:00
parent e790cb87ca
commit 4888294e03
2 changed files with 16 additions and 3 deletions

View File

@ -35,6 +35,9 @@ public slots:
void set3D(VideoMode mode); void set3D(VideoMode mode);
signals:
void emitColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
private slots: private slots:
void newFrame(const Image<ColorRgb> & image); void newFrame(const Image<ColorRgb> & image);

View File

@ -29,9 +29,19 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
{ {
// register the image type // register the image type
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>"); qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
// connect the new frame signal using a queued connection, because it will be called from a different thread // Handle the image in the captured thread using a direct connection
QObject::connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::QueuedConnection); QObject::connect(
&_grabber, SIGNAL(newFrame(Image<ColorRgb>)),
this, SLOT(newFrame(Image<ColorRgb>)),
Qt::DirectConnection);
// send color data to Hyperion using a queued connection to handle the data over to the main event loop
QObject::connect(
this, SIGNAL(emitColors(int,std::vector<ColorRgb>,int)),
_hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int)),
Qt::QueuedConnection);
} }
V4L2Wrapper::~V4L2Wrapper() V4L2Wrapper::~V4L2Wrapper()
@ -67,6 +77,6 @@ void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
_processor->process(image, _ledColors); _processor->process(image, _ledColors);
// send colors to Hyperion // send colors to Hyperion
_hyperion->setColors(_priority, _ledColors, _timeout_ms); emit emitColors(_priority, _ledColors, _timeout_ms);
} }