mirror of https://bitbucket.org/ausocean/av.git
Merged in constants-for-MOG (pull request #318)
Created constants for the MOG filter Approved-by: Saxon Milton <saxon.milton@gmail.com>
This commit is contained in:
commit
0fe0579ba8
|
@ -32,7 +32,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewMOGFilter returns a pointer to a new NoOp struct for testing purposes only.
|
// 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}
|
return &NoOp{dst: dst}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ type MOGFilter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMOGFilter returns a pointer to a new 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)
|
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
|
var windows []*gocv.Window
|
||||||
if debug {
|
if debug {
|
||||||
windows = []*gocv.Window{gocv.NewWindow("Debug: Bounding boxes"), gocv.NewWindow("Debug: Motion")}
|
windows = []*gocv.Window{gocv.NewWindow("Debug: Bounding boxes"), gocv.NewWindow("Debug: Motion")}
|
||||||
|
|
|
@ -9,7 +9,7 @@ AUTHORS
|
||||||
Trek Hopton <trek@ausocean.org>
|
Trek Hopton <trek@ausocean.org>
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
revid is Copyright (C) 2017-2018 the Australian Ocean Lab (AusOcean)
|
revid is Copyright (C) 2017-2020 the Australian Ocean Lab (AusOcean)
|
||||||
|
|
||||||
It is free software: you can redistribute it and/or modify them
|
It is free software: you can redistribute it and/or modify them
|
||||||
under the terms of the GNU General Public License as published by the
|
under the terms of the GNU General Public License as published by the
|
||||||
|
@ -76,13 +76,25 @@ const (
|
||||||
rtmpConnectionTimeout = 10
|
rtmpConnectionTimeout = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
// KNN filter properties
|
// Motion filter parameters.
|
||||||
const (
|
const (
|
||||||
knnMinArea = 25.0
|
showWindows = true
|
||||||
knnThreshold = 300
|
minFPS = 1.0
|
||||||
knnHistory = 300
|
)
|
||||||
knnKernel = 9
|
|
||||||
knnShowWindows = true
|
// KNN specific parameters.
|
||||||
|
const (
|
||||||
|
knnMinArea = 25.0
|
||||||
|
knnThreshold = 300
|
||||||
|
knnHistory = 300
|
||||||
|
knnKernel = 9
|
||||||
|
)
|
||||||
|
|
||||||
|
// MOG specific parameters.
|
||||||
|
const (
|
||||||
|
mogMinArea = 25.0
|
||||||
|
mogThreshold = 20.0
|
||||||
|
mogHistory = 500
|
||||||
)
|
)
|
||||||
|
|
||||||
const pkg = "revid: "
|
const pkg = "revid: "
|
||||||
|
@ -341,11 +353,12 @@ 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, 25, 20, 500, 3, true)
|
r.filter = filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, showWindows)
|
||||||
case config.FilterVariableFPS:
|
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, mogMinArea, mogThreshold, mogHistory, showWindows))
|
||||||
case config.FilterKNN:
|
case config.FilterKNN:
|
||||||
r.filter = filter.NewKNNFilter(r.encoders, knnMinArea, knnThreshold, knnHistory, knnKernel, knnShowWindows)
|
r.filter = filter.NewKNNFilter(r.encoders, knnMinArea, knnThreshold, knnHistory, knnKernel, showWindows)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
panic("Undefined Filter")
|
panic("Undefined Filter")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue