From 8c32265ae367f91f28b095a025e060e96893177b Mon Sep 17 00:00:00 2001 From: Ella Pietraroia Date: Tue, 31 Dec 2019 15:29:58 +1030 Subject: [PATCH] error message for decoding image --- filter/knn.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()