From 55981f8ae90522ea5fa14cdd58f60f6db2685ad8 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 2 Jan 2020 11:45:36 +1030 Subject: [PATCH] Made variable for showing windows --- revid/config/config.go | 5 +++++ revid/revid.go | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/revid/config/config.go b/revid/config/config.go index d13157b2..69eb2901 100644 --- a/revid/config/config.go +++ b/revid/config/config.go @@ -236,6 +236,10 @@ type Config struct { // of the file. Exposure string + // ShowWindows enables or disables the display of windows used for debugging + // motion filters. + ShowWindows bool + // AutoWhiteBalance defines the auto white balance mode used by Raspivid input. // Valid modes are defined in the exported []string AutoWhiteBalanceModes // defined at the start of the file. @@ -304,6 +308,7 @@ var TypeData = map[string]string{ "RTMPURL": "string", "RTPAddress": "string", "Saturation": "int", + "ShowWindows": "bool", "VBRBitrate": "int", "VBRQuality": "enum:standard,fair,good,great,excellent", "VerticalFlip": "bool", diff --git a/revid/revid.go b/revid/revid.go index 9c07a22a..cc68e02a 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -350,11 +350,11 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io. case config.FilterNoOp: r.filter = filter.NewNoOp(r.encoders) case config.FilterMOG: - r.filter = filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, showWindows) + r.filter = filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, r.cfg.ShowWindows) case config.FilterVariableFPS: - r.filter = filter.NewVariableFPSFilter(r.encoders, minFPS, filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, showWindows)) + r.filter = filter.NewVariableFPSFilter(r.encoders, minFPS, filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, r.cfg.ShowWindows)) case config.FilterKNN: - r.filter = filter.NewKNNFilter(r.encoders, knnMinArea, knnThreshold, knnHistory, knnKernel, showWindows) + r.filter = filter.NewKNNFilter(r.encoders, knnMinArea, knnThreshold, knnHistory, knnKernel, r.cfg.ShowWindows) default: panic("Undefined Filter") @@ -773,6 +773,16 @@ func (r *Revid) Update(vars map[string]string) error { break } r.cfg.CameraChan = v + case "ShowWindows": + switch strings.ToLower(value) { + case "true": + r.cfg.ShowWindows = true + case "false": + r.cfg.ShowWindows = false + default: + r.cfg.Logger.Log(logger.Warning, pkg+"invalid ShowWindows var", "value", value) + break + } } } r.cfg.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.cfg))