From fc87731788af22601270789e935cf068edc80f79 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期二, 09 七月 2019 10:50:59 +0800 Subject: [PATCH] --- --- insertdata/insertDataToEs.go | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go index 5105498..4321a98 100644 --- a/insertdata/insertDataToEs.go +++ b/insertdata/insertDataToEs.go @@ -4,6 +4,7 @@ "encoding/json" "errors" "fmt" + "io/ioutil" "net" "ruleprocess/cache" "ruleprocess/logger" @@ -15,9 +16,22 @@ "github.com/satori/go.uuid" "ruleprocess/ruleserver" "ruleprocess/util" + "github.com/go-yaml/yaml" ) +var weedfsUrl string +type conf struct { + PhotoUrl string +} +func init() { + logger.Info("_________________________________________鑰佸瓙鎯崇湅浣犳墽琛屼簡娌�") + fmt.Println("_________________________________________鑰佸瓙鎯崇湅浣犳墽琛屼簡娌�") + data, _ := ioutil.ReadFile("conf.yml") + c := conf{} + //鎶妝aml褰㈠紡鐨勫瓧绗︿覆瑙f瀽鎴恠truct绫诲瀷 + yaml.Unmarshal(data, &c) + weedfsUrl = c.PhotoUrl +} -var weedfsUrl = "http://192.168.1.182:6333/submit" // 浜鸿劯鐨勬暟鎹粨鏋� type PerVideoPicture struct { Id string `json:"id"` @@ -84,6 +98,7 @@ func InsertToEs(msg ruleserver.ResultMsg) { // 鐩存帴浠庤鍒欑殑鏍囩鏁版嵁閲屾嬁绗﹀悎瑙勫垯鐨勪汉鑴哥粨鏋� + logger.Info("------------------------------------浠庨厤缃枃浠惰鍙栫殑鍊硷細",weedfsUrl) if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]ruleserver.Arg)) > 0 { logger.Info("寰�ES鎻掍汉鑴告暟鎹�") for _, face := range msg.RuleResult["face"].([]ruleserver.Arg) { @@ -117,12 +132,13 @@ } i := protomsg.Image{} err = proto.Unmarshal(bdata, &i) - logger.Info("-------------------------------------------鐪嬩笅瀹藉拰楂�", i.Width, i.Height) + //logger.Info("-------------------------------------------鐪嬩笅瀹藉拰楂�", i.Width, i.Height) bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height)) resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String()) if err != nil { logger.Error("涓婁紶灏忓浘鍑洪敊") } + logger.Info("================灏忓浘鍦板潃:",resp["fileUrl"].(string)) sex := "" if face.ThftRes.Gender == 1 { sex = "鐢�" @@ -149,7 +165,7 @@ race, face.ThftRes.Smile, face.ThftRes.Beauty, - "", + string(face.Feature), []string{strings.Split(resp["fileUrl"].(string), "/")[1]}, "鏆傛棤闆嗙兢", localConfig.ServerId, @@ -190,12 +206,13 @@ } i := protomsg.Image{} err = proto.Unmarshal(bdata, &i) - logger.Info("-------------------------------------------鐪嬩笅瀹藉拰楂�", i.Width, i.Height) + //logger.Info("-------------------------------------------鐪嬩笅瀹藉拰楂�", i.Width, i.Height) bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height)) resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String()) if err != nil { logger.Error("涓婁紶灏忓浘鍑洪敊") } + logger.Info("================灏忓浘鍦板潃:",resp["fileUrl"].(string)) sex := "" if face.ThftRes.Gender == 1 { sex = "鐢�" -- Gitblit v1.8.0