diff --git a/filter/knn.go b/filter/knn.go index d4eb13ed..cc65d1de 100644 --- a/filter/knn.go +++ b/filter/knn.go @@ -29,6 +29,7 @@ LICENSE package filter import ( + "fmt" "image" "image/color" "io" @@ -74,7 +75,10 @@ func (m *KNNFilter) 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 *KNNFilter) Write(f []byte) (int, error) { - img, _ := gocv.IMDecode(f, gocv.IMReadColor) + img, err := gocv.IMDecode(f, gocv.IMReadColor) + if err != nil { + return 0, fmt.Errorf("can't decode image: %w", err) + } defer img.Close() imgDelta := gocv.NewMat()