mirror of https://bitbucket.org/ausocean/av.git
making new file for basic filter
This commit is contained in:
parent
3851a20aa0
commit
32612865dc
|
@ -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 <scott@ausocean.org>
|
||||
|
||||
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)
|
||||
}
|
Loading…
Reference in New Issue