-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
47 lines (38 loc) · 832 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"context"
"log"
"os"
"os/signal"
"syscall"
"flag"
"github.com/matipan/dartagnan/detector"
"github.com/matipan/dartagnan/turret"
"github.com/matipan/dartagnan/window"
)
const minArea = 7000
var (
area = flag.Float64("area", minArea, "base area for motion detection")
device = flag.Int("device", 0, "device ID for the camera")
)
func main() {
flag.Parse()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
t, err := turret.New("33", "35", 1.3, 500, 0)
if err != nil {
log.Println(err)
os.Exit(1)
}
wm := window.New(800, 600)
detector, err := detector.New(*device, *area, t.HandleMotion, wm)
if err != nil {
log.Println(err)
os.Exit(1)
}
ctx, cancel := context.WithCancel(context.Background())
go detector.Run(ctx)
<-c
cancel()
wm.Close()
}