This commit is contained in:
Scott 2019-12-19 16:51:49 +10:30
parent bd8922b475
commit f628c4243e
1 changed files with 5 additions and 5 deletions

View File

@ -61,7 +61,7 @@ func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history, kernelSi
// it using c-go.
func (m *MOGFilter) Close() error {
m.bs.Close()
m.kernel.Close()
m.knl.Close()
for _, window := range m.windows {
window.Close()
}
@ -85,12 +85,12 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
gocv.Threshold(imgDelta, &imgDelta, 25, 255, gocv.ThresholdBinary)
// Remove noise.
gocv.Erode(imgDelta, &imgDelta, m.kernel)
gocv.Dilate(imgDelta, &imgDelta, m.kernel)
gocv.Erode(imgDelta, &imgDelta, m.knl)
gocv.Dilate(imgDelta, &imgDelta, m.knl)
// Fill small holes.
gocv.Dilate(imgDelta, &imgDelta, m.kernel)
gocv.Erode(imgDelta, &imgDelta, m.kernel)
gocv.Dilate(imgDelta, &imgDelta, m.knl)
gocv.Erode(imgDelta, &imgDelta, m.knl)
// Find contours and reject ones with a small area.
var contours [][]image.Point