closing debug file

This commit is contained in:
Ella Pietraroia 2020-01-31 14:18:54 +10:30
parent ca0b146419
commit 40b282f39d
1 changed files with 6 additions and 11 deletions

View File

@ -42,18 +42,14 @@ import (
"golang.org/x/image/math/fixed"
)
const filename = "motion.mjpeg"
const debugfile = "motion.mjpeg"
const (
threshold = 45000
pixels = 1000
)
type pixel struct {
r uint32
g uint32
b uint32
}
type pixel struct{ r, g, b uint32 }
// BasicFilter is a filter that provides basic motion detection via a difference
// method.
@ -76,20 +72,19 @@ func NewBasicFilter(dst io.WriteCloser, debug bool) *Basic {
var err error
file = nil
if debug {
file, err = os.Create(filename)
file, err = os.Create(debugfile)
if err != nil {
panic(fmt.Sprintf("could not create debug file: %v", err))
}
} else {
file = nil
}
return &Basic{dst, nil, nil, bwImg, 0, 0, file, 0, debug}
}
// 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 {
if bf.debug {
bf.file.Close()
}
return nil
}