mirror of https://bitbucket.org/ausocean/av.git
Merged in show-windows-var (pull request #321)
Show windows var Approved-by: Saxon Milton <saxon.milton@gmail.com>
This commit is contained in:
commit
24c9377017
|
@ -27,6 +27,8 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/ausocean/av/codec/codecutil"
|
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||||
|
@ -116,6 +118,9 @@ const (
|
||||||
FilterKNN
|
FilterKNN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OS names
|
||||||
|
const raspian = "Raspbian GNU/Linux"
|
||||||
|
|
||||||
// Config provides parameters relevant to a revid instance. A new config must
|
// Config provides parameters relevant to a revid instance. A new config must
|
||||||
// be passed to the constructor. Default values for these fields are defined
|
// be passed to the constructor. Default values for these fields are defined
|
||||||
// as consts above.
|
// as consts above.
|
||||||
|
@ -236,6 +241,10 @@ type Config struct {
|
||||||
// of the file.
|
// of the file.
|
||||||
Exposure string
|
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.
|
// AutoWhiteBalance defines the auto white balance mode used by Raspivid input.
|
||||||
// Valid modes are defined in the exported []string AutoWhiteBalanceModes
|
// Valid modes are defined in the exported []string AutoWhiteBalanceModes
|
||||||
// defined at the start of the file.
|
// defined at the start of the file.
|
||||||
|
@ -304,6 +313,7 @@ var TypeData = map[string]string{
|
||||||
"RTMPURL": "string",
|
"RTMPURL": "string",
|
||||||
"RTPAddress": "string",
|
"RTPAddress": "string",
|
||||||
"Saturation": "int",
|
"Saturation": "int",
|
||||||
|
"ShowWindows": "bool",
|
||||||
"VBRBitrate": "int",
|
"VBRBitrate": "int",
|
||||||
"VBRQuality": "enum:standard,fair,good,great,excellent",
|
"VBRQuality": "enum:standard,fair,good,great,excellent",
|
||||||
"VerticalFlip": "bool",
|
"VerticalFlip": "bool",
|
||||||
|
@ -442,9 +452,29 @@ func (c *Config) Validate() error {
|
||||||
c.PSITime = defaultPSITime
|
c.PSITime = defaultPSITime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.ShowWindows {
|
||||||
|
os, err := osName()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if os == raspian {
|
||||||
|
c.Logger.Log(logger.Info, "ShowWindows disabled on Raspbian GNU/Linux")
|
||||||
|
c.ShowWindows = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func osName() (string, error) {
|
||||||
|
out, err := exec.Command("grep", "^NAME=", "/etc/os-release").Output()
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("could not get OS name: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(out)[6 : len(out)-2], nil
|
||||||
|
}
|
||||||
|
|
||||||
// stringInSlice returns true if want is in slice.
|
// stringInSlice returns true if want is in slice.
|
||||||
func stringInSlice(want string, slice []string) bool {
|
func stringInSlice(want string, slice []string) bool {
|
||||||
for _, s := range slice {
|
for _, s := range slice {
|
||||||
|
|
|
@ -77,10 +77,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Motion filter parameters.
|
// Motion filter parameters.
|
||||||
const (
|
const minFPS = 1.0
|
||||||
showWindows = true
|
|
||||||
minFPS = 1.0
|
|
||||||
)
|
|
||||||
|
|
||||||
// KNN specific parameters.
|
// KNN specific parameters.
|
||||||
const (
|
const (
|
||||||
|
@ -353,11 +350,11 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
||||||
case config.FilterNoOp:
|
case config.FilterNoOp:
|
||||||
r.filter = filter.NewNoOp(r.encoders)
|
r.filter = filter.NewNoOp(r.encoders)
|
||||||
case config.FilterMOG:
|
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:
|
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:
|
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:
|
default:
|
||||||
panic("Undefined Filter")
|
panic("Undefined Filter")
|
||||||
|
@ -776,6 +773,16 @@ func (r *Revid) Update(vars map[string]string) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
r.cfg.CameraChan = v
|
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))
|
r.cfg.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.cfg))
|
||||||
|
|
Loading…
Reference in New Issue