From fa15d923883ac864e266bd94d089156e8da0921f Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 10 Feb 2020 15:27:43 +1030 Subject: [PATCH] =?UTF-8?q?filter:=20Difference=20=E2=86=92=20Diff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter/difference.go | 14 +++++++------- filter/filters_circleci.go | 4 ++-- revid/config/config.go | 2 +- revid/revid.go | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/filter/difference.go b/filter/difference.go index 7d36d5c2..137a0b0d 100644 --- a/filter/difference.go +++ b/filter/difference.go @@ -39,25 +39,25 @@ import ( const defaultDiffThreshold = 3 -// Difference is a filter that provides basic motion detection. Difference calculates +// Diff is a filter that provides basic motion detection. Difference calculates // the absolute difference for each pixel between two frames, then finds the mean. If // the mean is above a given threshold, then it is considered motion. -type Difference struct { +type Diff struct { debugging debugWindows dst io.WriteCloser thresh float64 prev gocv.Mat } -// NewDifference returns a pointer to a new Difference struct. -func NewDifference(dst io.WriteCloser, c config.Config) *Difference { +// NewDiff returns a pointer to a new Diff struct. +func NewDiff(dst io.WriteCloser, c config.Config) *Diff { // Validate parameters. if c.MotionThreshold <= 0 { c.LogInvalidField("MotionThreshold", defaultDiffThreshold) c.MotionThreshold = defaultDiffThreshold } - return &Difference{ + return &Diff{ dst: dst, thresh: c.MotionThreshold, prev: gocv.NewMat(), @@ -68,7 +68,7 @@ func NewDifference(dst io.WriteCloser, c config.Config) *Difference { // Implements io.Closer. // Close frees resources used by gocv, because it has to be done manually, due to // it using c-go. -func (d *Difference) Close() error { +func (d *Diff) Close() error { d.prev.Close() d.debugging.close() return nil @@ -77,7 +77,7 @@ func (d *Difference) Close() error { // 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 (d *Difference) Write(f []byte) (int, error) { +func (d *Diff) Write(f []byte) (int, error) { if d.prev.Empty() { var err error d.prev, err = gocv.IMDecode(f, gocv.IMReadColor) diff --git a/filter/filters_circleci.go b/filter/filters_circleci.go index 127e3dda..0b001c88 100644 --- a/filter/filters_circleci.go +++ b/filter/filters_circleci.go @@ -44,8 +44,8 @@ func NewKNN(dst io.WriteCloser, c config.Config) *NoOp { return &NoOp{dst: dst} } -// NewDiffference returns a pointer to a new NoOp struct for testing purposes only. -func NewDifference(dst io.WriteCloser, c config.Config) *NoOp { +// NewDiff returns a pointer to a new NoOp struct for testing purposes only. +func NewDiff(dst io.WriteCloser, c config.Config) *NoOp { return &NoOp{dst: dst} } diff --git a/revid/config/config.go b/revid/config/config.go index cb483526..9414b5ae 100644 --- a/revid/config/config.go +++ b/revid/config/config.go @@ -113,7 +113,7 @@ const ( FilterMOG FilterVariableFPS FilterKNN - FilterDifference + FilterDiff FilterBasic ) diff --git a/revid/revid.go b/revid/revid.go index fae9b1ea..1ef886d8 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -339,8 +339,8 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io. r.filters[i] = filter.NewVariableFPS(dst, r.cfg.MinFPS, filter.NewMOG(dst, r.cfg)) case config.FilterKNN: r.filters[i] = filter.NewKNN(dst, r.cfg) - case config.FilterDifference: - r.filters[i] = filter.NewDifference(dst, r.cfg) + case config.FilterDiff: + r.filters[i] = filter.NewDiff(dst, r.cfg) case config.FilterBasic: r.filters[i] = filter.NewBasic(dst, r.cfg) default: @@ -676,7 +676,7 @@ func (r *Revid) Update(vars map[string]string) error { } case "Filters": filters := strings.Split(value, ",") - m := map[string]int{"NoOp": config.FilterNoOp, "MOG": config.FilterMOG, "VariableFPS": config.FilterVariableFPS, "KNN": config.FilterKNN, "Difference": config.FilterDifference, "Basic": config.FilterBasic} + m := map[string]int{"NoOp": config.FilterNoOp, "MOG": config.FilterMOG, "VariableFPS": config.FilterVariableFPS, "KNN": config.FilterKNN, "Difference": config.FilterDiff, "Basic": config.FilterBasic} r.cfg.Filters = make([]int, len(filters)) for i, filter := range filters { v, ok := m[filter]