mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
3ff7fe483f
* small collection of bugfixed debugger hints / warnings * 'toStdVector' has been explicitly marked deprecated * fixed double zip naming in artifacts * V4L2 WebUI Fix * Some code fixes based on alerts from lgtm.com * only execute dynamic v4l2 enum code, if V4L2_AVAIL * very high critical bugfix ;) * merge fix * some lgtm.com fixes * lgtm fixes * undo localtime_r fix Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
#include <QMetaType>
|
|
|
|
#include <grabber/V4L2Wrapper.h>
|
|
|
|
// qt
|
|
#include <QTimer>
|
|
|
|
V4L2Wrapper::V4L2Wrapper(const QString &device,
|
|
const unsigned grabWidth,
|
|
const unsigned grabHeight,
|
|
const unsigned fps,
|
|
VideoStandard videoStandard,
|
|
PixelFormat pixelFormat,
|
|
int pixelDecimation )
|
|
: GrabberWrapper("V4L2:"+device, &_grabber, grabWidth, grabHeight, 10)
|
|
, _grabber(device,
|
|
grabWidth,
|
|
grabHeight,
|
|
fps,
|
|
videoStandard,
|
|
pixelFormat,
|
|
pixelDecimation)
|
|
{
|
|
_ggrabber = &_grabber;
|
|
|
|
// register the image type
|
|
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
|
|
|
|
// Handle the image in the captured thread using a direct connection
|
|
connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
|
|
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
|
|
}
|
|
|
|
bool V4L2Wrapper::start()
|
|
{
|
|
return ( _grabber.start() && GrabberWrapper::start());
|
|
}
|
|
|
|
void V4L2Wrapper::stop()
|
|
{
|
|
_grabber.stop();
|
|
GrabberWrapper::stop();
|
|
}
|
|
|
|
void V4L2Wrapper::setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold)
|
|
{
|
|
_grabber.setSignalThreshold( redSignalThreshold, greenSignalThreshold, blueSignalThreshold, 50);
|
|
}
|
|
|
|
void V4L2Wrapper::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
|
|
{
|
|
_grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom);
|
|
}
|
|
|
|
void V4L2Wrapper::setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax)
|
|
{
|
|
_grabber.setSignalDetectionOffset(verticalMin, horizontalMin, verticalMax, horizontalMax);
|
|
}
|
|
|
|
void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
|
|
{
|
|
emit systemImage(_grabberName, image);
|
|
}
|
|
|
|
void V4L2Wrapper::readError(const char* err)
|
|
{
|
|
Error(_log, "stop grabber, because reading device failed. (%s)", err);
|
|
stop();
|
|
}
|
|
|
|
void V4L2Wrapper::action()
|
|
{
|
|
// dummy as v4l get notifications from stream
|
|
}
|
|
|
|
void V4L2Wrapper::setSignalDetectionEnable(bool enable)
|
|
{
|
|
_grabber.setSignalDetectionEnable(enable);
|
|
}
|
|
|
|
bool V4L2Wrapper::getSignalDetectionEnable()
|
|
{
|
|
return _grabber.getSignalDetectionEnabled();
|
|
}
|
|
|
|
void V4L2Wrapper::setDeviceVideoStandard(QString device, VideoStandard videoStandard)
|
|
{
|
|
_grabber.setDeviceVideoStandard(device, videoStandard);
|
|
}
|