mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Added image handler to v4l2 grabber to send colors to Hyperion
Former-commit-id: be6fb4dd8080b3325ba6161f48c093f8a145786d
This commit is contained in:
@@ -4,6 +4,7 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/v4l2)
|
||||
|
||||
SET(V4L2_QT_HEADERS
|
||||
${CURRENT_HEADER_DIR}/V4L2Grabber.h
|
||||
${CURRENT_HEADER_DIR}/V4L2Wrapper.h
|
||||
)
|
||||
|
||||
SET(V4L2_HEADERS
|
||||
@@ -12,6 +13,7 @@ SET(V4L2_HEADERS
|
||||
|
||||
SET(V4L2_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/V4L2Grabber.cpp
|
||||
${CURRENT_SOURCE_DIR}/V4L2Wrapper.cpp
|
||||
)
|
||||
|
||||
QT4_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS})
|
||||
|
67
libsrc/grabber/v4l2/V4L2Wrapper.cpp
Normal file
67
libsrc/grabber/v4l2/V4L2Wrapper.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <grabber/V4L2Wrapper.h>
|
||||
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
|
||||
V4L2Wrapper::V4L2Wrapper(const std::string &device,
|
||||
int input,
|
||||
VideoStandard videoStandard,
|
||||
int width,
|
||||
int height,
|
||||
int frameDecimation,
|
||||
int pixelDecimation,
|
||||
Hyperion *hyperion,
|
||||
int hyperionPriority) :
|
||||
_timeout_ms(1000),
|
||||
_priority(hyperionPriority),
|
||||
_grabber(device,
|
||||
input,
|
||||
videoStandard,
|
||||
width,
|
||||
height,
|
||||
frameDecimation,
|
||||
pixelDecimation,
|
||||
pixelDecimation),
|
||||
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
|
||||
_hyperion(hyperion),
|
||||
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0})
|
||||
{
|
||||
// connect the new frame signal using a queued connection, because it will be called from a different thread
|
||||
QObject::connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
V4L2Wrapper::~V4L2Wrapper()
|
||||
{
|
||||
delete _processor;
|
||||
}
|
||||
|
||||
void V4L2Wrapper::start()
|
||||
{
|
||||
_grabber.start();
|
||||
}
|
||||
|
||||
void V4L2Wrapper::stop()
|
||||
{
|
||||
_grabber.stop();
|
||||
}
|
||||
|
||||
void V4L2Wrapper::setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
{
|
||||
_grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom);
|
||||
}
|
||||
|
||||
void V4L2Wrapper::set3D(VideoMode mode)
|
||||
{
|
||||
_grabber.set3D(mode);
|
||||
}
|
||||
|
||||
void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
|
||||
{
|
||||
// TODO: add a signal detector
|
||||
|
||||
// process the new image
|
||||
_processor->process(image, _ledColors);
|
||||
|
||||
// send colors to Hyperion
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
}
|
||||
|
Reference in New Issue
Block a user