Created constants for the MOG filter

This commit is contained in:
Scott 2019-12-31 15:04:19 +10:30
parent 29b9a9267a
commit 9d857b8a66
3 changed files with 12 additions and 6 deletions

View File

@ -32,7 +32,7 @@ import (
)
// NewMOGFilter returns a pointer to a new NoOp struct for testing purposes only.
func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history, kernelSize int, debug bool) *NoOp {
func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history int, debug bool) *NoOp {
return &NoOp{dst: dst}
}

View File

@ -48,9 +48,9 @@ type MOGFilter struct {
}
// NewMOGFilter returns a pointer to a new MOGFilter struct.
func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history, kernelSize int, debug bool) *MOGFilter {
func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history int, debug bool) *MOGFilter {
bs := gocv.NewBackgroundSubtractorMOG2WithParams(history, threshold, false)
k := gocv.GetStructuringElement(gocv.MorphRect, image.Pt(kernelSize, kernelSize))
k := gocv.GetStructuringElement(gocv.MorphRect, image.Pt(3, 3))
var windows []*gocv.Window
if debug {
windows = []*gocv.Window{gocv.NewWindow("Debug: Bounding boxes"), gocv.NewWindow("Debug: Motion")}

View File

@ -76,13 +76,18 @@ const (
rtmpConnectionTimeout = 10
)
// KNN filter properties
// Motion filter parameters
const (
knnMinArea = 25.0
knnThreshold = 300
knnHistory = 300
knnKernel = 9
knnShowWindows = true
minArea = 25.0
threshold = 20.0
history = 500
showWindows = true
minFPS = 1.0
)
const pkg = "revid: "
@ -341,11 +346,12 @@ 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, 25, 20, 500, 3, true)
r.filter = filter.NewMOGFilter(r.encoders, minArea, threshold, history, showWindows)
case config.FilterVariableFPS:
r.filter = filter.NewVariableFPSFilter(r.encoders, 1.0, filter.NewMOGFilter(r.encoders, 25, 20, 500, 3, true))
r.filter = filter.NewVariableFPSFilter(r.encoders, minFPS, filter.NewMOGFilter(r.encoders, minArea, threshold, history, showWindows))
case config.FilterKNN:
r.filter = filter.NewKNNFilter(r.encoders, knnMinArea, knnThreshold, knnHistory, knnKernel, knnShowWindows)
default:
panic("Undefined Filter")
}