error message for decoding image

This commit is contained in:
Ella Pietraroia 2019-12-31 15:29:58 +10:30
parent 40b5374856
commit 8c32265ae3
1 changed files with 5 additions and 1 deletions

View File

@ -29,6 +29,7 @@ LICENSE
package filter package filter
import ( import (
"fmt"
"image" "image"
"image/color" "image/color"
"io" "io"
@ -74,7 +75,10 @@ func (m *KNNFilter) Close() error {
// Write applies the motion filter to the video stream. Only frames with motion // Write applies the motion filter to the video stream. Only frames with motion
// are written to the destination encoder, frames without are discarded. // are written to the destination encoder, frames without are discarded.
func (m *KNNFilter) Write(f []byte) (int, error) { 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() defer img.Close()
imgDelta := gocv.NewMat() imgDelta := gocv.NewMat()