mirror of https://bitbucket.org/ausocean/av.git
more testing
This commit is contained in:
parent
44aac3f9fd
commit
c99d3564bf
|
@ -83,6 +83,7 @@ func (m *MOGFilter) Close() error {
|
|||
// Write applies the motion filter to the video stream. Only frames with motion
|
||||
// are written to the destination encoder, frames without are discarded.
|
||||
func (m *MOGFilter) Write(f []byte) (int, error) {
|
||||
t2 := time.Now()
|
||||
if frames == 0 {
|
||||
t1 = time.Now()
|
||||
}
|
||||
|
@ -90,6 +91,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
|
|||
m.hold[m.hfCount] = f
|
||||
m.hfCount++
|
||||
frames++
|
||||
fmt.Printf("Hold in array 1 frame:\t%dms\n", time.Now().Sub(t2).Milliseconds())
|
||||
if frames >= 24 {
|
||||
fmt.Printf("25 frames takes: %dms\n\n", time.Now().Sub(t1).Milliseconds())
|
||||
frames = 0
|
||||
|
@ -148,13 +150,15 @@ 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
|
||||
}
|
||||
frames++
|
||||
fmt.Printf("No motion 1 frame:\t%dms\n", time.Now().Sub(t2).Milliseconds())
|
||||
if frames >= 24 {
|
||||
fmt.Printf("25 frames takes: %dms\n\n", time.Now().Sub(t1).Milliseconds())
|
||||
frames = 0
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Write to destination, past 4 frames then current frame.
|
||||
for i, h := range m.hold {
|
||||
_, err := m.dst.Write(h)
|
||||
|
@ -163,7 +167,12 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
|
|||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("Motion 1 frame:\t\t%dms\n", time.Now().Sub(t2).Milliseconds())
|
||||
frames++
|
||||
if frames >= 24 {
|
||||
fmt.Printf("25 frames takes: %dms\n\n", time.Now().Sub(t1).Milliseconds())
|
||||
frames = 0
|
||||
}
|
||||
return m.dst.Write(f)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue