GrabberFix PiCam

This commit is contained in:
SputnikElf 2019-12-30 22:23:38 +01:00
parent aef4e3a571
commit 8ffe9cb8e2
9 changed files with 139 additions and 0 deletions

View File

@ -559,6 +559,10 @@
"edt_conf_v4l2_sDVOffsetMax_expl": "Signal Erkennungs-Bereich vertikal maximum (0.0-1.0)",
"edt_conf_v4l2_sDHOffsetMax_title": "Signal Erkennung HMax",
"edt_conf_v4l2_sDHOffsetMax_expl": "Signal Erkennungs-Bereich horizontal maximum (0.0-1.0)",
"edt_conf_v4l2_grabberFix_title": "Feste Grabber Werte",
"edt_conf_v4l2_gFWidth_title": "Breite",
"edt_conf_v4l2_gFHeight_title": "Höhe",
"edt_conf_v4l2_gFVType_title": "Pixelformat",
"edt_conf_instCapture_heading_title": "Instance Aufnahme",
"edt_conf_instC_systemEnable_title": "Aktiviere Plattform Aufnahme",
"edt_conf_instC_systemEnable_expl": "Aktiviert die Plattform Aufnahme für diese LED Hardware Instanz",

View File

@ -44,6 +44,8 @@ public:
bool getSignalDetectionEnabled() { return _signalDetectionEnabled; }
bool getGrabberFixEnabled() { return _grabberFixEnabled; }
int grabFrame(Image<ColorRgb> &);
///
@ -79,6 +81,12 @@ public:
///
virtual void setSignalDetectionEnable(bool enable);
virtual void setGrabberFixEnable(bool enable);
virtual void setGrabberFixValues(
int width,
int height,
int vtype);
///
/// @brief overwrite Grabber.h implementation
///
@ -204,4 +212,10 @@ private:
bool _initialized;
bool _deviceAutoDiscoverEnabled;
// grabberfix
bool _grabberFixEnabled;
int _gf_width;
int _gf_height;
int _gf_vtype;
};

View File

@ -15,6 +15,7 @@ public:
virtual ~V4L2Wrapper() {};
bool getSignalDetectionEnable();
bool getGrabberFixEnable();
public slots:
bool start();
@ -24,6 +25,8 @@ public slots:
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax);
void setSignalDetectionEnable(bool enable);
void setGrabberFixEnable(bool enable);
void setGrabberFixValues(int width, int height, string vtype);
void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
signals:

View File

@ -66,6 +66,11 @@ public:
/// @brief Apply SignalDetectionEnable (used from v4l)
///
virtual void setSignalDetectionEnable(bool enable) {};
virtual void setGrabberFixEnable(bool enable) {};
virtual void setGrabberFixValues(
int width,
int height,
int vtype) {};
///
/// @brief Apply device and videoStanded (used from v4l)

View File

@ -54,6 +54,10 @@ V4L2Grabber::V4L2Grabber(const QString & device
, _streamNotifier(nullptr)
, _initialized(false)
, _deviceAutoDiscoverEnabled(false)
, _grabberFixEnabled(true)
, _gf_width(0)
, _gf_height(0)
, _gf_vtype("JPEG")
{
setPixelDecimation(pixelDecimation);
getV4Ldevices();
@ -206,6 +210,14 @@ void V4L2Grabber::setSignalDetectionOffset(double horizontalMin, double vertical
Info(_log, "Signal detection area set to: %f,%f x %f,%f", _x_frac_min, _y_frac_min, _x_frac_max, _y_frac_max );
}
void V4L2Grabber::setGrabberFixValues(int width, int height, string vtype)
{
_gf_width = width;
_gf_height = height;
_gf_vtype = vtype;
Warning(_log, "Grabber fix set to: %d x %d, %s", _gf_width, _gf_height, _gf_vtype);
}
bool V4L2Grabber::start()
{
@ -615,6 +627,19 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
fmtdesc.index++;
}
// RPi Camera V1.3 & V2.1 workaround resolution and pixelformat
Warning(_log, "vor _grabberFixEnabled");
if (_grabberFixEnabled) {
Warning(_log, "_grabberFixEnabled");
//if (max_width == 2592 || max_width == 3280) {
max_width = _gf_width;
max_height = _gf_height;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
Warning(_log, "wxh %d x %d", max_width, max_height);
//}
} else {
Warning(_log, "nicht _grabberFixEnabled");
}
// set the settings
if (max_width != 0 || max_height != 0)
@ -1148,6 +1173,14 @@ void V4L2Grabber::setSignalDetectionEnable(bool enable)
Info(_log, "Signal detection is now %s", enable ? "enabled" : "disabled");
}
}
void V4L2Grabber::setGrabberFixEnable(bool enable)
{
if (_grabberFixEnabled != enable)
{
_grabberFixEnabled = enable;
Info(_log, "Grabber fix is now %s", enable ? "enabled" : "disabled");
}
}
void V4L2Grabber::setPixelDecimation(int pixelDecimation)
{

View File

@ -52,6 +52,10 @@ void V4L2Wrapper::setSignalDetectionOffset(double verticalMin, double horizontal
{
_grabber.setSignalDetectionOffset(verticalMin, horizontalMin, verticalMax, horizontalMax);
}
void V4L2Wrapper::setGrabberFixValues(int width, int height, string vtype)
{
_grabber.setGrabberFixValues(width, height, vtype);
}
void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
{
@ -78,6 +82,15 @@ bool V4L2Wrapper::getSignalDetectionEnable()
{
return _grabber.getSignalDetectionEnabled();
}
void V4L2Wrapper::setGrabberFixEnable(bool enable)
{
_grabber.setGrabberFixEnable(enable);
}
bool V4L2Wrapper::getGrabberFixEnable()
{
return _grabber.getGrabberFixEnabled();
}
void V4L2Wrapper::setDeviceVideoStandard(QString device, VideoStandard videoStandard)
{

View File

@ -165,6 +165,10 @@ void GrabberWrapper::handleSettingsUpdate(const settings::type& type, const QJso
_ggrabber->setDeviceVideoStandard(
obj["device"].toString("auto"),
parseVideoStandard(obj["standard"].toString("no-change")));
_ggrabber->setGrabberFixValues(
obj["gFWidth"].toInt(0),
obj["gFHeight"].toInt(0),
obj["gFVType"].toString("JPEG"));
}
}

View File

@ -194,6 +194,64 @@
},
"required" : true,
"propertyOrder" : 15
},
"grabberFix" :
{
"type" : "boolean",
"title" : "edt_conf_v4l2_grabberFix_title",
"default" : false,
"required" : true,
"propertyOrder" : 16
},
"gFWidth" :
{
"type" : "integer",
"title" : "edt_conf_v4l2_gFWidth_title",
"minimum" : 320,
"maximum" : 1980,
"default" : 1280,
"step" : 10,
"options": {
"dependencies": {
"grabberFix": true
}
},
"required" : true,
"propertyOrder" : 17
},
"gFHeight" :
{
"type" : "integer",
"title" : "edt_conf_v4l2_gFHeight_title",
"minimum" : 240,
"maximum" : 1080,
"default" : 720,
"step" : 10,
"options": {
"dependencies": {
"grabberFix": true
}
},
"required" : true,
"propertyOrder" : 18
},
"gFVType" :
{
"type" : "string",
"title" : "edt_conf_v4l2_gFVType_title",
"enum" : ["UYVY","YUYV","RGB32"],
"options":
{
"enum_titles": ["UYVY","YUYV","RGB32"]
},
"default" : "UYVY",
"options": {
"dependencies": {
"grabberFix": true
}
},
"required" : true,
"propertyOrder" : 19
}
},
"additionalProperties" : false

View File

@ -431,6 +431,11 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type& settingsType, co
grabberConfig["sDVOffsetMin"].toDouble(0.25),
grabberConfig["sDHOffsetMax"].toDouble(0.75),
grabberConfig["sDVOffsetMax"].toDouble(0.75));
_v4l2Grabber->setGrabberFixEnable(grabberConfig["grabberFix"].toBool(true));
_v4l2Grabber->setGrabberFixValues(
grabberConfig["gFWidth"].toInt(0),
grabberConfig["gFHeight"].toInt(0),
grabberConfig["gFVType"].toString("JPEG"));
Debug(_log, "V4L2 grabber created");
// connect to HyperionDaemon signal