change to error handling

This commit is contained in:
Ella Pietraroia 2020-01-22 15:34:32 +10:30
parent fd8e2e2426
commit 2e70e3fa1b
1 changed files with 3 additions and 3 deletions

View File

@ -87,7 +87,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
m.hfCount = 0
img, err := gocv.IMDecode(f, gocv.IMReadColor)
if err != nil {
return 0, fmt.Errorf("image can't be decoded: %w", err)
return len(f), fmt.Errorf("image can't be decoded: %w", err)
}
defer img.Close()
@ -135,7 +135,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
// Don't write to destination if there is no motion.
if len(contours) == 0 {
return 0, nil
return len(f), nil
}
// Write to destination, past 4 frames then current frame.
@ -143,7 +143,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
_, err := m.dst.Write(h)
m.hold[i] = nil
if err != nil {
return 0, err
return len(f), fmt.Errorf("could not write previous frames: %w", err)
}
}
return m.dst.Write(f)