added enable to v4lgrabber (#93)

* added enable to v4lgrabber

* updated configs with v4l enable/disable example
This commit is contained in:
penfold42 2016-07-10 21:36:05 +10:00 committed by brindosch
parent ca795d883e
commit c1cb148f41
3 changed files with 28 additions and 22 deletions

View File

@ -141,6 +141,7 @@
},
/// Configuration for the embedded V4L2 grabber
/// * enable : Enable or disable the v4lgrabber (true/false)
/// * device : V4L2 Device to use [default="/dev/video0"]
/// * input : V4L2 input to use [default=0]
/// * standard : Video standard (no-change/PAL/NTSC) [default="no-change"]
@ -159,6 +160,7 @@
/// * blueSignalThreshold : Signal threshold for the blue channel between 0.0 and 1.0 [default=0.0]
"grabber-v4l2" :
{
"enable" : false,
"device" : "/dev/video0",
"input" : 0,
"standard" : "no-change",

View File

@ -92,6 +92,7 @@
"grabber-v4l2" :
{
"enable" : false,
"device" : "/dev/video0",
"input" : 0,
"standard" : "PAL",

View File

@ -359,30 +359,33 @@ void HyperionDaemon::createGrabberV4L2()
if (_config.isMember("grabber-v4l2"))
{
const Json::Value & grabberConfig = _config["grabber-v4l2"];
_v4l2Grabber = new V4L2Wrapper(
grabberConfig.get("device", "/dev/video0").asString(),
grabberConfig.get("input", 0).asInt(),
parseVideoStandard(grabberConfig.get("standard", "no-change").asString()),
parsePixelFormat(grabberConfig.get("pixelFormat", "no-change").asString()),
grabberConfig.get("width", -1).asInt(),
grabberConfig.get("height", -1).asInt(),
grabberConfig.get("frameDecimation", 2).asInt(),
grabberConfig.get("sizeDecimation", 8).asInt(),
grabberConfig.get("redSignalThreshold", 0.0).asDouble(),
grabberConfig.get("greenSignalThreshold", 0.0).asDouble(),
grabberConfig.get("blueSignalThreshold", 0.0).asDouble(),
grabberConfig.get("priority", 900).asInt());
_v4l2Grabber->set3D(parse3DMode(grabberConfig.get("mode", "2D").asString()));
_v4l2Grabber->setCropping(
grabberConfig.get("cropLeft", 0).asInt(),
grabberConfig.get("cropRight", 0).asInt(),
grabberConfig.get("cropTop", 0).asInt(),
grabberConfig.get("cropBottom", 0).asInt());
if (grabberConfig.get("enable", true).asBool())
{
_v4l2Grabber = new V4L2Wrapper(
grabberConfig.get("device", "/dev/video0").asString(),
grabberConfig.get("input", 0).asInt(),
parseVideoStandard(grabberConfig.get("standard", "no-change").asString()),
parsePixelFormat(grabberConfig.get("pixelFormat", "no-change").asString()),
grabberConfig.get("width", -1).asInt(),
grabberConfig.get("height", -1).asInt(),
grabberConfig.get("frameDecimation", 2).asInt(),
grabberConfig.get("sizeDecimation", 8).asInt(),
grabberConfig.get("redSignalThreshold", 0.0).asDouble(),
grabberConfig.get("greenSignalThreshold", 0.0).asDouble(),
grabberConfig.get("blueSignalThreshold", 0.0).asDouble(),
grabberConfig.get("priority", 900).asInt());
_v4l2Grabber->set3D(parse3DMode(grabberConfig.get("mode", "2D").asString()));
_v4l2Grabber->setCropping(
grabberConfig.get("cropLeft", 0).asInt(),
grabberConfig.get("cropRight", 0).asInt(),
grabberConfig.get("cropTop", 0).asInt(),
grabberConfig.get("cropBottom", 0).asInt());
QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
_v4l2Grabber->start();
Info(_log, "V4L2 grabber created and started");
_v4l2Grabber->start();
Info(_log, "V4L2 grabber created and started");
}
}
#else
ErrorIf(_config.isMember("grabber-v4l2"), _log, "The v4l2 grabber can not be instantiated, because it has been left out from the build");