mirror of https://bitbucket.org/ausocean/av.git
closing debug file
This commit is contained in:
parent
ca0b146419
commit
40b282f39d
|
@ -42,18 +42,14 @@ import (
|
||||||
"golang.org/x/image/math/fixed"
|
"golang.org/x/image/math/fixed"
|
||||||
)
|
)
|
||||||
|
|
||||||
const filename = "motion.mjpeg"
|
const debugfile = "motion.mjpeg"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
threshold = 45000
|
threshold = 45000
|
||||||
pixels = 1000
|
pixels = 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
type pixel struct {
|
type pixel struct{ r, g, b uint32 }
|
||||||
r uint32
|
|
||||||
g uint32
|
|
||||||
b uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
// BasicFilter is a filter that provides basic motion detection via a difference
|
// BasicFilter is a filter that provides basic motion detection via a difference
|
||||||
// method.
|
// method.
|
||||||
|
@ -76,20 +72,19 @@ func NewBasicFilter(dst io.WriteCloser, debug bool) *Basic {
|
||||||
var err error
|
var err error
|
||||||
file = nil
|
file = nil
|
||||||
if debug {
|
if debug {
|
||||||
file, err = os.Create(filename)
|
file, err = os.Create(debugfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("could not create debug file: %v", err))
|
panic(fmt.Sprintf("could not create debug file: %v", err))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
file = nil
|
|
||||||
}
|
}
|
||||||
return &Basic{dst, nil, nil, bwImg, 0, 0, file, 0, debug}
|
return &Basic{dst, nil, nil, bwImg, 0, 0, file, 0, debug}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements io.Closer.
|
// Implements io.Closer.
|
||||||
// Close frees resources used by gocv, because it has to be done manually, due to
|
|
||||||
// it using c-go.
|
|
||||||
func (bf *Basic) Close() error {
|
func (bf *Basic) Close() error {
|
||||||
|
if bf.debug {
|
||||||
|
bf.file.Close()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue