Fix initialization bug
This commit is contained in:
parent
3b038c2515
commit
f457299f50
10
main.go
10
main.go
@ -56,6 +56,14 @@ func main() {
|
||||
|
||||
fmt.Printf("Start reading device: %v\n", deviceID)
|
||||
|
||||
// This is a warm up ladies and gentlemen.
|
||||
for i := 0; i < 20; i++ {
|
||||
if ok := webcam.Read(&img); !ok {
|
||||
fmt.Printf("Device closed: %v\n", deviceID)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// main loop
|
||||
for {
|
||||
if ok := webcam.Read(&img); !ok {
|
||||
@ -88,7 +96,7 @@ func main() {
|
||||
|
||||
currentRecording.Write(img)
|
||||
// Determine if we should stop recording
|
||||
if lastMotionDetectedTime.Add(time.Second * recordLengthAfterMotion).After(time.Now()) {
|
||||
if lastMotionDetectedTime.Add(time.Second * recordLengthAfterMotion).Before(time.Now()) {
|
||||
log.Printf("motion has not been detected for the last %d seconds stopping recording to file", recordLengthAfterMotion)
|
||||
err = currentRecording.Close()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user