diff --git a/filter/mog.go b/filter/mog.go index b83b039c..9519b656 100644 --- a/filter/mog.go +++ b/filter/mog.go @@ -87,7 +87,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) { m.hfCount = 0 img, err := gocv.IMDecode(f, gocv.IMReadColor) if err != nil { - return 0, fmt.Errorf("image can't be decoded: %w", err) + return len(f), fmt.Errorf("image can't be decoded: %w", err) } defer img.Close() @@ -135,7 +135,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) { // Don't write to destination if there is no motion. if len(contours) == 0 { - return 0, nil + return len(f), nil } // Write to destination, past 4 frames then current frame. @@ -143,7 +143,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) { _, err := m.dst.Write(h) m.hold[i] = nil if err != nil { - return 0, err + return len(f), fmt.Errorf("could not write previous frames: %w", err) } } return m.dst.Write(f)