package proc import ( "analysis/logo" "analysis/util" "analysis/work" "context" ) // SingleRole 单进程 func SingleRole(ctx context.Context, typ string, ipcID string, gpu int, shm bool) { util.InitDBAPI() if typ == util.FeatAll { // run all proc per proc allProc(ctx, gpu, shm) } else if typ == util.FeatFace || typ == util.FeatYolo { // run all face sdk sdkProc(ctx, typ, gpu, shm) } else { // run one sdk per proc, typ is facedetect/yolodetect/facecompare etc. id is ipc slaveProc(ctx, typ, ipcID, gpu, shm) } } func sdkProc(ctx context.Context, typ string, gpu int, shm bool) { if typ != util.FeatYolo && typ != util.FeatFace { logo.Errorf("NO THIS SDK PROC SDKPROC : ", typ) } rSDK := []string{ work.FDetect, work.FCompare, } if typ == util.FeatYolo { rSDK = rSDK[0:0] rSDK = append(rSDK, work.YDetect) } var res []bool for _, v := range rSDK { _, f := prepare(v, gpu) res = append(res, f) } for k, v := range res { if !v { logo.Errorln(k, " type proc failed to init") return } } sdks := util.SDKInfo() for k, v := range sdks { for _, s := range rSDK { if s == v.SdkType { build(v.SdkType, v.IpcId, shm) logo.Infof("TYPE PROC ID %s TYPE %s\n", k, v.IpcId, v.SdkType) } } } runAll(ctx) } func allProc(ctx context.Context, gpu int, shm bool) { var res []bool for _, v := range work.SDK { _, f := prepare(v, gpu) res = append(res, f) } for k, v := range res { if !v { logo.Errorln(k, " ALL PROC FAILED TO INIT") return } } sdks := util.SDKInfo() // 首先运行yolo for k, v := range sdks { if v.SdkType != "Yolo" { continue } build(v.SdkType, v.IpcId, shm) logo.Infof("all proc %d sdk id %s run sdk %s\n", k, v.IpcId, v.SdkType) } for k, v := range sdks { if v.SdkType == "Yolo" { continue } build(v.SdkType, v.IpcId, shm) logo.Infof("all proc %d sdk id %s run sdk %s\n", k, v.IpcId, v.SdkType) } runAll(ctx) }