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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| package sdk
|
| import (
| "analysis/logo"
| "analysis/work"
| "context"
|
| "basic.com/valib/gogpu.git"
|
| "basic.com/valib/gosdk.git"
| )
|
| type trackInfo struct {
| lastTrackObjs []gosdk.CObjTrackInfo
| lastTrackID uint64
| }
|
| // YoloDetect yolo detect
| type YoloDetect struct {
| yolo *gosdk.YoloHandle
| iGPU int
| cfg string
| weights string
| name string
|
| tracker map[string]*trackInfo
|
| list *LockList
| }
|
| // NewYDetectWithTrack with track
| func NewYDetectWithTrack(gi int, cfg, weights, name string) *YoloDetect {
| return &YoloDetect{
| iGPU: gi,
| cfg: cfg,
| weights: weights,
| name: name,
| list: NewLockList(6),
| }
| }
|
| // Init impl interface
| func (y *YoloDetect) Init() bool {
|
| gpu := y.iGPU
| if gpu == -1 {
| gpu = gogpu.ValidGPU(2048)
| }
| yolo := gosdk.InitYolo(y.cfg, y.weights, y.name, gpu)
|
| if yolo == nil {
| logo.Infoln("yolo start failed: ", gpu)
| return false
| }
| logo.Infoln("yolo use gpu: ", gpu)
|
| y.yolo = yolo
| return true
| }
|
| // Run impl interface
| func (y *YoloDetect) Run(ctx context.Context, in <-chan work.MsgRS, out chan<- work.MsgRS, typ string) {
| y.detectTrack(ctx, in, out, typ)
| }
|
|