| | |
| | | |
| | | import ( |
| | | "analysis/logo" |
| | | "analysis/proc" |
| | | "analysis/util" |
| | | "strconv" |
| | | |
| | | "analysis/app/master" |
| | | "analysis/app/slave" |
| | | |
| | | "context" |
| | | "flag" |
| | | |
| | | "os" |
| | | "os/signal" |
| | | |
| | | "golang.org/x/sys/unix" |
| | | |
| | | "basic.com/valib/gogpu.git" |
| | | // "net/http" |
| | |
| | | gpu int |
| | | shm bool |
| | | ruleIPC string |
| | | soFile string |
| | | |
| | | configPath string |
| | | ) |
| | | |
| | | const ( |
| | | master = `master` |
| | | slave = `slave` |
| | | single = `single` |
| | | roleMaster = `master` |
| | | roleSlave = `slave` |
| | | ) |
| | | |
| | | func init() { |
| | | flag.BoolVar(&logit, "logit", false, "use logger,default flase") |
| | | flag.StringVar(&role, "role", single, "run process role master/slave/single, default single") |
| | | flag.StringVar(&role, "role", roleMaster, "run process role master/slave, default single") |
| | | flag.StringVar(&runType, "sdk", util.FeatAll, "run sdk type, face/facedetect/facecompare/yolo,etc.") |
| | | flag.StringVar(&id, "id", util.FakeSdkID, "sdk id as ipc label") |
| | | flag.IntVar(&gpu, "gpu", -1, "gpu index") |
| | | flag.BoolVar(&shm, "shm", false, "use shm for performance") |
| | | |
| | | flag.StringVar(&soFile, "so-file", "./", "libcffmpeg.so path") |
| | | flag.StringVar(&configPath, util.ConfigPath, "", "sdk config file path") |
| | | |
| | | // 人脸识别参数 |
| | | flag.IntVar(&util.SFI.DetectThrd, util.FaceDetectThread, util.SFI.DetectThrd, "face detect max thread count") |
| | | flag.IntVar(&util.SFI.DetectNum, util.FaceDetectNum, util.SFI.DetectNum, "face detect min face count") |
| | | flag.IntVar(&util.SFI.DetectAngle, util.FaceDetectAngle, util.SFI.DetectAngle, "face detect face angle") |
| | | flag.IntVar(&util.SFI.PropThrd, util.FacePropertyThread, util.SFI.PropThrd, "face property max thread count") |
| | | flag.IntVar(&util.SFI.ExtractThrd, util.FaceExtractThread, util.SFI.ExtractThrd, "face extract max thread count") |
| | | flag.IntVar(&util.SFI.TrackInterval, util.FaceTrackInterval, util.SFI.TrackInterval, "face track needed interval") |
| | | flag.IntVar(&util.SFI.SampleSize, util.FaceTrackSample, util.SFI.SampleSize, "face track sample size") |
| | | flag.BoolVar(&logit, util.LogIt, false, "use logger,default flase") |
| | | flag.BoolVar(&shm, util.SHM, false, "use shm for performance") |
| | | |
| | | // 车辆信息 |
| | | // 授权服务路径 |
| | | flag.StringVar(&util.SCI.LicenseServerPath, util.CarSDKLicense, util.SCI.LicenseServerPath, "car detect lic server bin path") |
| | | flag.IntVar(&util.SCI.MaxImageWidth, util.CarMaxImageWidth, util.SCI.MaxImageWidth, "car detect image width") |
| | | flag.IntVar(&util.SCI.MaxImageHeight, util.CarMaxImageHeight, util.SCI.MaxImageHeight, "car detect image height") |
| | | // cloud plate |
| | | flag.StringVar(&util.SCI.Model, util.CarSDKModel, util.SCI.Model, "cloud palte detector model") |
| | | flag.IntVar(&gpu, util.GPU, -1, "gpu index") |
| | | |
| | | // 指定获取配置信息从sqlite,有最高优先级, master使用 |
| | | flag.StringVar(&util.FSI.IP, util.FetchSrvIP, util.FSI.IP, "fetch server ip, like camera info") |
| | |
| | | } |
| | | |
| | | func setParamters() { |
| | | util.FillParams(util.FaceDetectThread, strconv.Itoa(util.SFI.DetectThrd)) |
| | | util.FillParams(util.FaceDetectNum, strconv.Itoa(util.SFI.DetectNum)) |
| | | util.FillParams(util.FaceDetectAngle, strconv.Itoa(util.SFI.DetectAngle)) |
| | | util.FillParams(util.FacePropertyThread, strconv.Itoa(util.SFI.PropThrd)) |
| | | util.FillParams(util.FaceExtractThread, strconv.Itoa(util.SFI.ExtractThrd)) |
| | | util.FillParams(util.FaceTrackInterval, strconv.Itoa(util.SFI.TrackInterval)) |
| | | util.FillParams(util.FaceTrackSample, strconv.Itoa(util.SFI.SampleSize)) |
| | | |
| | | util.FillParams(util.CarSDKLicense, util.SCI.LicenseServerPath) |
| | | util.FillParams(util.CarSDKModel, util.SCI.Model) |
| | | util.FillParams(util.CarMaxImageWidth, strconv.Itoa(util.SCI.MaxImageWidth)) |
| | | util.FillParams(util.CarMaxImageHeight, strconv.Itoa(util.SCI.MaxImageHeight)) |
| | | |
| | | util.FillParams(util.FetchSrvIP, util.FSI.IP) |
| | | util.FillParams(util.FetchSrvPort, strconv.Itoa(util.FSI.HTTPort)) |
| | | util.FillParams(util.FetchSrvHeartbeatPort, strconv.Itoa(util.FSI.HBPort)) |
| | |
| | | |
| | | util.FillParams(util.RuleIPC, util.ToRuleIPC) |
| | | |
| | | util.SetParams("-so-file=" + soFile) |
| | | util.SetParams("-gpu=" + strconv.Itoa(gpu)) |
| | | util.FillParams(util.GPU, strconv.Itoa(gpu)) |
| | | if logit { |
| | | util.SetParams("-logit") |
| | | util.FillParams(util.LogIt, "true") |
| | | } |
| | | if shm { |
| | | util.SetParams("-shm") |
| | | util.FillParams(util.SHM, "true") |
| | | } |
| | | |
| | | // util.FillParams("gpu", strconv.Itoa(gpu)) |
| | | // if logit { |
| | | // util.FillParams("logit", "true") |
| | | // } |
| | | // if shm { |
| | | // util.FillParams("shm", "true") |
| | | // } |
| | | |
| | | } |
| | | |
| | | func main() { |
| | |
| | | |
| | | runLogger() |
| | | |
| | | if configPath == "" || len(configPath) == 0 { |
| | | logo.Infoln("!!!!!! SDK CONFIG PATH MUST EXIST !!!!!!") |
| | | return |
| | | } |
| | | logo.Infoln(os.Args) |
| | | ctx, cancel := context.WithCancel(context.Background()) |
| | | |
| | | ret := false |
| | | if role == single { |
| | | ret = proc.SingleRole(ctx, runType, id, gpu, shm) |
| | | } else if role == master { |
| | | if role == roleMaster { |
| | | setParamters() |
| | | ret = proc.MasterRole(ctx) |
| | | } else if role == slave { |
| | | ret = proc.SingleRole(ctx, runType, id, gpu, shm) |
| | | ret = master.Run(ctx, configPath) |
| | | |
| | | } else if role == roleSlave { |
| | | ret = slave.Run(ctx, configPath, runType, id, gpu, shm) |
| | | } |
| | | |
| | | if ret { |
| | | c := make(chan os.Signal, 1) |
| | | signal.Notify(c, os.Interrupt, os.Kill, unix.SIGTERM) |
| | | <-c |
| | | // c := make(chan os.Signal, 1) |
| | | // signal.Notify(c, os.Interrupt, os.Kill, unix.SIGTERM) |
| | | // <-c |
| | | select {} |
| | | } |
| | | |
| | | cancel() |
| | | |
| | | logo.Close() |
| | | } |
| | | |
| | | // const ( |
| | | // configFilePath = "/opt/vasystem/config/" |
| | | // configFileName = "sdkconfig" |
| | | // configFileType = "yaml" |
| | | // ) |
| | | // viper.SetConfigType(configFileType) |
| | | // viper.SetConfigName(configFileName) |
| | | // viper.AddConfigPath(configFilePath) |
| | | // viper.AddConfigPath("./") |
| | | |
| | | // envString := "" |