mirror of https://bitbucket.org/ausocean/av.git
filter: return length from the filter's Write method
This commit is contained in:
parent
fb43e9214a
commit
a111f21427
|
@ -76,7 +76,10 @@ 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)
|
||||||
return 0, err
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return len(f), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := gocv.IMDecode(f, gocv.IMReadColor)
|
img, err := gocv.IMDecode(f, gocv.IMReadColor)
|
||||||
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue