From a111f214279966885d1af40766dabd0ee9867453 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 27 Jan 2020 11:23:56 +1030 Subject: [PATCH] filter: return length from the filter's Write method --- filter/difference.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/filter/difference.go b/filter/difference.go index 4504c6ef..d01cf0a7 100644 --- a/filter/difference.go +++ b/filter/difference.go @@ -76,7 +76,10 @@ func (d *Difference) Write(f []byte) (int, error) { if d.prev.Empty() { var err error d.prev, err = gocv.IMDecode(f, gocv.IMReadColor) - return 0, err + if err != nil { + return 0, err + } + return len(f), nil } img, err := gocv.IMDecode(f, gocv.IMReadColor) @@ -94,7 +97,7 @@ func (d *Difference) Write(f []byte) (int, error) { mean := imgDelta.Mean().Val1 - // Update History + // Update History. d.prev = img.Clone() // Draw debug information. @@ -118,7 +121,7 @@ func (d *Difference) Write(f []byte) (int, error) { // Don't write to destination if there is no motion. if mean < d.thresh { - return 0, nil + return len(f), nil } // Write to destination.