From 32612865dcf501ee6b80d9c3ae535fd2e7c170d6 Mon Sep 17 00:00:00 2001 From: Ella Pietraroia Date: Wed, 22 Jan 2020 16:32:47 +1030 Subject: [PATCH] making new file for basic filter --- filter/basic.go | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 filter/basic.go diff --git a/filter/basic.go b/filter/basic.go new file mode 100644 index 00000000..a810b0a0 --- /dev/null +++ b/filter/basic.go @@ -0,0 +1,62 @@ +// +build !circleci + +/* +DESCRIPTION + A filter that detects motion and discards frames without motion. The + filter uses a Mixture of Gaussians method (MoG) to determine what is + background and what is foreground. + +AUTHORS + Scott Barnard + +LICENSE + mog.go is Copyright (C) 2019 the Australian Ocean Lab (AusOcean) + + 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 + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + +package filter + +import ( + "io" +) + +// MOGFilter is a filter that provides basic motion detection. MoG is short for +// Mixture of Gaussians method. +type BasicFilter struct { + dst io.WriteCloser +} + +// NewMOGFilter returns a pointer to a new MOGFilter struct. +func NewBasicFilter(dst io.WriteCloser) *BasicFilter { + return &BasicFilter{dst} +} + +// Implements io.Closer. +// Close frees resources used by gocv, because it has to be done manually, due to +// it using c-go. +func (m *BasicFilter) Close() error { + return nil +} + +// Implements io.Writer. +// Write applies the motion filter to the video stream. Only frames with motion +// are written to the destination encoder, frames without are discarded. +func (m *BasicFilter) Write(f []byte) (int, error) { + //decode MJPEG + + //for all frames find difference in this frame from last frames + + return m.dst.Write(f) +}