package sdk import ( "analysis/logo" "analysis/work" "container/list" "context" "sync" "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 cache *list.List cv *sync.Cond cond bool } // NewYDetectWithTrack with track func NewYDetectWithTrack(gi int, cfg, weights, name string) *YoloDetect { return &YoloDetect{ iGPU: gi, cfg: cfg, weights: weights, name: name, cache: list.New(), cv: sync.NewCond(&sync.Mutex{}), cond: false, } } // 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) logo.Infoln("yolo use gpu: ", gpu) if yolo == nil { return false } 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) }