From 29443bd61f97c8980e24b92992bdb4fcf99636ed Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 31 Dec 2019 15:30:51 +1030 Subject: [PATCH] filter/mog.go: handles error from IMGDecode --- filter/mog.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/filter/mog.go b/filter/mog.go index 283ea034..5dacbfca 100644 --- a/filter/mog.go +++ b/filter/mog.go @@ -29,6 +29,7 @@ LICENSE package filter import ( + "fmt" "image" "image/color" "io" @@ -74,7 +75,10 @@ func (m *MOGFilter) Close() error { // 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 *MOGFilter) Write(f []byte) (int, error) { - img, _ := gocv.IMDecode(f, gocv.IMReadColor) + img, err := gocv.IMDecode(f, gocv.IMReadColor) + if err != nil { + return -1, fmt.Errorf("image can't be decoded: %w", err) + } defer img.Close() imgDelta := gocv.NewMat()