filter: return length from the filter's Write method

This commit is contained in:
Scott 2020-01-27 11:23:56 +10:30
parent fb43e9214a
commit a111f21427
1 changed files with 6 additions and 3 deletions

View File

@ -76,8 +76,11 @@ func (d *Difference) Write(f []byte) (int, error) {
if d.prev.Empty() { if d.prev.Empty() {
var err error var err error
d.prev, err = gocv.IMDecode(f, gocv.IMReadColor) d.prev, err = gocv.IMDecode(f, gocv.IMReadColor)
if err != nil {
return 0, err return 0, err
} }
return len(f), nil
}
img, err := gocv.IMDecode(f, gocv.IMReadColor) img, err := gocv.IMDecode(f, gocv.IMReadColor)
defer img.Close() defer img.Close()
@ -94,7 +97,7 @@ func (d *Difference) Write(f []byte) (int, error) {
mean := imgDelta.Mean().Val1 mean := imgDelta.Mean().Val1
// Update History // Update History.
d.prev = img.Clone() d.prev = img.Clone()
// Draw debug information. // Draw debug information.
@ -118,7 +121,7 @@ func (d *Difference) Write(f []byte) (int, error) {
// Don't write to destination if there is no motion. // Don't write to destination if there is no motion.
if mean < d.thresh { if mean < d.thresh {
return 0, nil return len(f), nil
} }
// Write to destination. // Write to destination.