diff --git a/include/grabber/V4L2Wrapper.h b/include/grabber/V4L2Wrapper.h index 39a38d7c..ad6ca247 100644 --- a/include/grabber/V4L2Wrapper.h +++ b/include/grabber/V4L2Wrapper.h @@ -35,6 +35,9 @@ public slots: void set3D(VideoMode mode); +signals: + void emitColors(int priority, const std::vector &ledColors, const int timeout_ms); + private slots: void newFrame(const Image & image); diff --git a/libsrc/grabber/v4l2/V4L2Wrapper.cpp b/libsrc/grabber/v4l2/V4L2Wrapper.cpp index 0423e64a..f859c05e 100644 --- a/libsrc/grabber/v4l2/V4L2Wrapper.cpp +++ b/libsrc/grabber/v4l2/V4L2Wrapper.cpp @@ -29,9 +29,19 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device, { // register the image type qRegisterMetaType>("Image"); + qRegisterMetaType>("std::vector"); - // connect the new frame signal using a queued connection, because it will be called from a different thread - QObject::connect(&_grabber, SIGNAL(newFrame(Image)), this, SLOT(newFrame(Image)), Qt::QueuedConnection); + // Handle the image in the captured thread using a direct connection + QObject::connect( + &_grabber, SIGNAL(newFrame(Image)), + this, SLOT(newFrame(Image)), + 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,int)), + _hyperion, SLOT(setColors(int,std::vector,int)), + Qt::QueuedConnection); } V4L2Wrapper::~V4L2Wrapper() @@ -67,6 +77,6 @@ void V4L2Wrapper::newFrame(const Image &image) _processor->process(image, _ledColors); // send colors to Hyperion - _hyperion->setColors(_priority, _ledColors, _timeout_ms); + emit emitColors(_priority, _ledColors, _timeout_ms); }