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.