filter: check for errors after decoding

This commit is contained in:
Scott 2020-01-24 16:10:08 +10:30
parent e0fa474906
commit b15b649151
1 changed files with 7 additions and 3 deletions

View File

@ -74,12 +74,16 @@ func (d *Difference) Close() error {
// are written to the destination encoder, frames without are discarded. // are written to the destination encoder, frames without are discarded.
func (d *Difference) Write(f []byte) (int, error) { func (d *Difference) Write(f []byte) (int, error) {
if d.prev.Empty() { if d.prev.Empty() {
d.prev, _ = gocv.IMDecode(f, gocv.IMReadColor) var err error
return 0, nil d.prev, err = gocv.IMDecode(f, gocv.IMReadColor)
return 0, err
} }
img, _ := gocv.IMDecode(f, gocv.IMReadColor) img, err := gocv.IMDecode(f, gocv.IMReadColor)
defer img.Close() defer img.Close()
if err != nil {
return 0, err
}
imgDelta := gocv.NewMat() imgDelta := gocv.NewMat()
defer imgDelta.Close() defer imgDelta.Close()