| | |
| | | "sync" |
| | | "time" |
| | | |
| | | "basic.com/libgowrapper/sdkhelper.git" |
| | | "face/common" |
| | | |
| | | "basic.com/libgowrapper/sdkstruct.git" |
| | | "basic.com/pubsub/protomsg.git" |
| | |
| | | fn("Face SDK Create Error When New SDK") |
| | | return nil |
| | | } |
| | | cfg, err := sdkhelper.ReadConfig(config) |
| | | cfg, err := common.ReadConfig(config) |
| | | if err != nil { |
| | | fn("Face SDK Create Error When Read Config: ", err) |
| | | return nil |
| | |
| | | } |
| | | |
| | | w, h, detThrd, detNum, detAngle, propThrd, extThrd, trckInterval, trckSmpl, maxChan, gpuM := |
| | | 1280, 720, sdkhelper.Atoi(cfg.Param[dt]), sdkhelper.Atoi(cfg.Param[dn]), sdkhelper.Atoi(cfg.Param[da]), |
| | | sdkhelper.Atoi(cfg.Param[pt]), sdkhelper.Atoi(cfg.Param[et]), sdkhelper.Atoi(cfg.Param[ti]), sdkhelper.Atoi(cfg.Param[ts]), |
| | | sdkhelper.Atoi(cfg.Param[mc]), sdkhelper.Atoi(cfg.Param[gm]) |
| | | 1280, 720, common.Atoi(cfg.Param[dt]), common.Atoi(cfg.Param[dn]), common.Atoi(cfg.Param[da]), |
| | | common.Atoi(cfg.Param[pt]), common.Atoi(cfg.Param[et]), common.Atoi(cfg.Param[ti]), common.Atoi(cfg.Param[ts]), |
| | | common.Atoi(cfg.Param[mc]), common.Atoi(cfg.Param[gm]) |
| | | |
| | | if detAngle > 0 { |
| | | } |
| | |
| | | postPull = `_1` |
| | | postPush = `_2` |
| | | ) |
| | | ipcRcv := sdkhelper.GetIpcAddress(s.shm, s.id+postPull) |
| | | ipcSnd := sdkhelper.GetIpcAddress(s.shm, s.id+postPush) |
| | | ipcRcv := common.GetIpcAddress(s.shm, s.id+postPull) |
| | | ipcSnd := common.GetIpcAddress(s.shm, s.id+postPush) |
| | | chRcv := make(chan []byte, s.maxChannel) |
| | | chSnd := make(chan sdkstruct.MsgSDK, s.maxChannel) |
| | | |
| | | rcver := sdkhelper.NewReciever(ipcRcv, chRcv, s.shm, s.fnLogger) |
| | | snder := sdkhelper.NewSender(ipcSnd, chSnd, s.shm, s.fnLogger) |
| | | torule := sdkhelper.NewToRule(s.ipc2Rule, s.ruleMsgMaxCacheSize, s.fnLogger) |
| | | rcver := common.NewReciever(ipcRcv, chRcv, s.shm, s.fnLogger) |
| | | snder := common.NewSender(ipcSnd, chSnd, s.shm, s.fnLogger) |
| | | torule := common.NewToRule(s.ipc2Rule, s.ruleMsgMaxCacheSize, s.fnLogger) |
| | | |
| | | snder.ApplyCallbackFunc(torule.Push) |
| | | |
| | |
| | | func (f *face) run(ctx context.Context, in <-chan []byte, out chan<- sdkstruct.MsgSDK) { |
| | | |
| | | chMsg := make(chan protomsg.SdkMessage, f.maxChannel) |
| | | go sdkhelper.UnserilizeProto(ctx, in, chMsg, f.fnLogger) |
| | | go common.UnserilizeProto(ctx, in, chMsg, f.fnLogger) |
| | | |
| | | for { |
| | | select { |
| | |
| | | f.handle.Free() |
| | | return |
| | | case rMsg := <-chMsg: |
| | | if !sdkhelper.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { |
| | | if !common.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { |
| | | f.fnLogger("FACE TRACK VALIDREMOTEMESSAGE INVALID") |
| | | sdkhelper.EjectResult(nil, rMsg, out) |
| | | common.EjectResult(nil, rMsg, out) |
| | | continue |
| | | } |
| | | |
| | |
| | | chn := f.getAvailableChn() |
| | | if chn < 0 { |
| | | f.fnLogger("TOO MUCH CHANNEL") |
| | | sdkhelper.EjectResult(nil, rMsg, out) |
| | | common.EjectResult(nil, rMsg, out) |
| | | continue |
| | | } |
| | | f.ftrackChannels[rMsg.Cid] = chn |
| | | |
| | | i := sdkhelper.UnpackImage(rMsg, f.typ, f.fnLogger) |
| | | i := common.UnpackImage(rMsg, f.typ, f.fnLogger) |
| | | if i == nil { |
| | | sdkhelper.EjectResult(nil, rMsg, out) |
| | | common.EjectResult(nil, rMsg, out) |
| | | continue |
| | | } |
| | | // conv to bgr24 and resize |
| | |
| | | |
| | | case rMsg := <-in: |
| | | |
| | | if !sdkhelper.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { |
| | | sdkhelper.EjectResult(nil, rMsg, out) |
| | | if !common.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { |
| | | common.EjectResult(nil, rMsg, out) |
| | | continue |
| | | } |
| | | |
| | | i := sdkhelper.UnpackImage(rMsg, f.typ, f.fnLogger) |
| | | i := common.UnpackImage(rMsg, f.typ, f.fnLogger) |
| | | if i == nil || i.Data == nil || i.Width <= 0 || i.Height <= 0 { |
| | | sdkhelper.EjectResult(nil, rMsg, out) |
| | | common.EjectResult(nil, rMsg, out) |
| | | continue |
| | | } |
| | | |
| | |
| | | |
| | | count, data, _ := f.handle.Run(i.Data, imgW, imgH, 3, dtchn) |
| | | |
| | | sdkhelper.EjectResult(data, rMsg, out) |
| | | common.EjectResult(data, rMsg, out) |
| | | f.mtxRunning.Lock() |
| | | f.running = true |
| | | f.mtxRunning.Unlock() |