From 732d0c9d92acde9b4de607f511af1d0e7500f3cb Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期三, 13 十一月 2019 20:23:57 +0800 Subject: [PATCH] arg的cacheDate --- ruleserver/readyDataForRule.go | 58 ++++++++++++++++------------------------------------------ 1 files changed, 16 insertions(+), 42 deletions(-) diff --git a/ruleserver/readyDataForRule.go b/ruleserver/readyDataForRule.go index 5859d9b..98063e1 100644 --- a/ruleserver/readyDataForRule.go +++ b/ruleserver/readyDataForRule.go @@ -3,19 +3,18 @@ import ( "basic.com/dbapi.git" "basic.com/pubsub/protomsg.git" + "basic.com/valib/logger.git" "encoding/json" "errors" "fmt" - "github.com/go-yaml/yaml" "github.com/golang/protobuf/proto" - "io/ioutil" + uuid "github.com/satori/go.uuid" "math" "nanomsg.org/go-mangos" "nanomsg.org/go-mangos/protocol/req" "nanomsg.org/go-mangos/transport/tcp" "net" "ruleprocess/cache" - "ruleprocess/logger" "ruleprocess/structure" "strconv" "time" @@ -33,23 +32,6 @@ } func Init() { - data, err := ioutil.ReadFile("./config/conf.yml") - if err != nil { - fmt.Println("璇诲彇閰嶇疆鏂囦欢鍑洪敊--", err) - logger.Error("璇诲彇閰嶇疆鏂囦欢鍑洪敊--", err) - } - c := conf{} - //鎶妝aml褰㈠紡鐨勫瓧绗︿覆瑙f瀽鎴恠truct绫诲瀷 - yaml.Unmarshal(data, &c) - logger.Debug("閰嶇疆鏂囦欢鐨勫�间负锛�", c) - serverIp = c.ServerIp - serverPort = c.ServerPort - dbTablePersons = c.DbTablePersons - localConfig, err1 := cache.GetServerInfo() - if err1 != nil { - logger.Error("鏌ヨ鏈満淇℃伅澶辫触锛�") - } - logger.Debug("鏈満淇℃伅鍜宻erver淇℃伅锛�", localConfig, serverIp, serverPort) go Push1() } @@ -80,7 +62,6 @@ taskGroup = task } } - logger.Debug("褰撳墠鏁版嵁甯ц鍖归厤鐨勮鍒欑粍锛�-------------------------","鎽勫儚鏈篿d:",cameraId,"浠诲姟id",taskId) if taskGroup == nil { return nil } else { @@ -106,10 +87,10 @@ } func Decimal(value float32) float64 { value1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(value)), 64) - logger.Info("鍒濇淇濈暀涓や綅鎴恠tr:",value1) + //logger.Info("鍒濇淇濈暀涓や綅鎴恠tr:",value1) n10 := math.Pow10(4) value2 := math.Trunc((value1+0.5/n10)*n10) / n10 - logger.Info("鍒濇淇濈暀涓や綅鎴恠tr::::",value2) + //logger.Info("鍒濇淇濈暀涓や綅鎴恠tr::::",value2) return value2 } // 鍙栧嚭鏌愪釜鏃堕棿瑙勫垯鐨勭鍑犲ぉ鐨勮鍒欐闆嗗悎 @@ -162,7 +143,7 @@ } // 缁欑洰鏍囧~鍏卨iker -func FillLiker(arg *structure.Arg,tableId []string, compareThreshold float32) { +func fillLiker(tableId []string, compareThreshold float32,arg *structure.Arg) { //bytes := bigCache.GetComparePersonBaseInfo(tableId, arg.Feature, compareThreshold) comArg := &protomsg.CompareArgs{ TableIds:tableId, @@ -229,7 +210,7 @@ if groupRule.Rules[j].SdkArgAlias == "compareBase" && groupRule.Rules[j].SdkArgValue == "" { // 閰嶇殑鍙傛暟鏄瘮瀵瑰叏閮ㄥ簳搴� compareFlag = 1 } - if groupRule.Rules[j].SdkArgAlias == "threshold" { + if groupRule.Rules[j].SdkArgAlias == "cmpThreshold" { v2, err := strconv.ParseFloat(groupRule.Rules[j].SdkArgValue, 32) if err != nil { logger.Error("string杞琭loat32澶辫触锛�") @@ -256,19 +237,11 @@ //logger.Info("--------------鐪嬬湅compareFlag鐨勫�煎拰tableId鍜宎reaMap.args鐨勯暱搴︼細",compareFlag,tableIds,len(areaMap.args)) for _, arg := range areaMap.Args { arg.Liker = arg.Liker[0:0] - logger.Info("娓呯┖涔嬪悗鐪嬬湅涔嬪墠鎵撶殑浜鸿劯鏍囩鍙樹簡娌★細") - if args.RuleResult["face"] != nil && len(args.RuleResult["face"].([]structure.FaceResult)) > 0 { - for _, faceResult := range args.RuleResult["face"].([]structure.FaceResult) { - for _,arg := range faceResult.Args { - logger.Info("浜哄憳鍒嗗�兼槸锛�",arg.Score,"liker鐨勬暟閲忎负",arg.Liker) - } - } - } if compareFlag == 1 { - FillLiker(arg,nil, threshold) + fillLiker(nil, threshold, arg) } if compareFlag == 2 { - FillLiker(arg,tableIds, threshold) + fillLiker(tableIds, threshold, arg) } //logger.Info("-------------------鎴愬姛缁檒iker璧嬪��,闀垮害涓猴細", len(arg.Liker)) } @@ -288,19 +261,21 @@ func CountAreaObjs(a *structure.AreaMap,arg *structure.SdkData) { a.TargetNum = 0 - threshold := 0.5 // 鐩镐技搴� + threshold := 80.0 // 鐩镐技搴� intersectionper := 0.2 // 鍗犳瘮 size := 0.0 // 灏哄 areaPoints := Json2points(a.AreaJson) - widthScale := float64(arg.ImageWidth / 960) - heigthScale := float64(arg.ImageHeight / 540) + logger.Info("鐪嬬湅鍥剧墖鐨剋idth鍜宧eight:",arg.ImageWidth,arg.ImageHeight) + widthScale := float64(arg.ImageWidth) / 960 + heigthScale := float64(arg.ImageHeight) / 540 for _, obj := range arg.Photo { //logger.Info("------------------鐪嬬湅sdkData:", arg.SdkName, "鐨凱hoto鏁版嵁----------------", obj, "----椤轰究鐪嬬湅鍗犳瘮-----锛�", PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale)) - if threshold <= obj.Score && size <= float64(obj.Rects.Width*obj.Rects.Height) && intersectionper <= PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) { + if obj.Score >= threshold && float64(obj.Rects.Width*obj.Rects.Height) >= size && PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) >= intersectionper { // 杩欐瑕佸榻愯〃杈惧紡閲屾墍闇�瑕佺殑鎵�鏈夊弬鏁� a.TargetNum++ - arg1 := structure.Arg{obj.Id,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*structure.BaseInfo{}} + uuid := uuid.NewV4().String() + arg1 := structure.Arg{obj.Id,uuid,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*structure.BaseInfo{},structure.ResultMsg{}} //logger.Println("鏀捐繘鍘荤殑arg锛�-------", arg1) a.Args = append(a.Args, &arg1) a.FilterData = append(a.FilterData, &arg1) @@ -308,8 +283,6 @@ } logger.Info("鍖哄煙鏄細",areaPoints,"鍖哄煙鍐呯洰鏍囨暟閲忎负锛�",a.TargetNum,"---",len(a.FilterData)) a.Time = time.Unix(time.Now().Unix(), 0).String()[11:16] - a.KeepRight = arg.KeepRight - a.IsStatic = arg.IsStatic //logger.Println("--------------------鐪嬬湅鍖哄煙鏁版嵁锛�",*a) } @@ -393,6 +366,7 @@ // case <-ctx.Done(): // return case data := <- sender: + logger.Info("姣斿杩涚▼鍏ュ弬锛�",data.TableIds,data.CompareThreshold) bytes,err1 := proto.Marshal(data) logger.Info("鏁版嵁闀垮害涓猴細",len(bytes)) if err1 != nil { -- Gitblit v1.8.0