From 35f6dd60f51b44b1e6b4ddaacd17f95b9aa87edc Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 16 十二月 2019 15:22:50 +0800
Subject: [PATCH] 特征值从开始时就存为string

---
 algorithm/personTrack/personTrack.go   |    9 ++++-----
 algorithm/middleware/readyData.go      |   13 ++++++++-----
 structure/rule.go                      |    6 ++----
 algorithm/middleware/insertDataToEs.go |   13 ++++++-------
 4 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/algorithm/middleware/insertDataToEs.go b/algorithm/middleware/insertDataToEs.go
index bb0cfdb..0ff5d3b 100644
--- a/algorithm/middleware/insertDataToEs.go
+++ b/algorithm/middleware/insertDataToEs.go
@@ -1,7 +1,6 @@
 package main
 
 import (
-	"encoding/base64"
 	"encoding/json"
 	"errors"
 	"net"
@@ -9,15 +8,15 @@
 	"strconv"
 	"time"
 
+	"basic.com/valib/logger.git"
 	"github.com/golang/protobuf/proto"
 	"github.com/satori/go.uuid"
-	"basic.com/valib/logger.git"
 
-	"ruleprocess/cache"
-	"ruleprocess/structure"
-	"basic.com/pubsub/protomsg.git"
 	"basic.com/pubsub/esutil.git"
+	"basic.com/pubsub/protomsg.git"
+	"ruleprocess/cache"
 	"ruleprocess/ruleserver"
+	"ruleprocess/structure"
 	"ruleprocess/util"
 )
 
@@ -171,10 +170,10 @@
 				target.TargetId = face.Id
 				target.TargetScore = face.Score
 				target.TargetType = face.Type
-				target.Feature = base64.StdEncoding.EncodeToString(face.Feature)
+				target.Feature = face.Feature
 				target.PicSmUrl = resp["fileUrl"].(string)
 				target.TargetLocation = Points{TopLeft: Point{face.Location.X, face.Location.Y}, BottomRight: Point{face.Location.X + face.Location.Width, face.Location.Y + face.Location.Height}}
-				target.AttachTarget = SourceTarget{face.AttachArg.Id,face.AttachArg.Score,face.AttachArg.Type,base64.StdEncoding.EncodeToString(face.AttachArg.Feature),"",Points{TopLeft: Point{face.AttachArg.Location.X, face.AttachArg.Location.Y}, BottomRight: Point{face.AttachArg.Location.X + face.AttachArg.Location.Width, face.AttachArg.Location.Y + face.AttachArg.Location.Height}}}
+				target.AttachTarget = SourceTarget{face.AttachArg.Id,face.AttachArg.Score,face.AttachArg.Type,face.AttachArg.Feature,"",Points{TopLeft: Point{face.AttachArg.Location.X, face.AttachArg.Location.Y}, BottomRight: Point{face.AttachArg.Location.X + face.AttachArg.Location.Width, face.AttachArg.Location.Y + face.AttachArg.Location.Height}}}
 				var targetInfos []Target
 				targetInfos = append(targetInfos, *target)
 
diff --git a/algorithm/middleware/readyData.go b/algorithm/middleware/readyData.go
index a25f62d..e173812 100644
--- a/algorithm/middleware/readyData.go
+++ b/algorithm/middleware/readyData.go
@@ -3,6 +3,8 @@
 import (
 	"basic.com/pubsub/protomsg.git"
 	"basic.com/valib/logger.git"
+	"encoding/base64"
+	"encoding/json"
 	"github.com/golang/protobuf/proto"
 	uuid "github.com/satori/go.uuid"
 	"ruleprocess/ruleserver"
@@ -35,7 +37,7 @@
 			// 杩欐瑕佸榻愯〃杈惧紡閲屾墍闇�瑕佺殑鎵�鏈夊弬鏁�
 			a.TargetNum++
 			uuid := uuid.NewV4().String()
-			arg1 := structure.Arg{structure.SourceArg{obj.Id,uuid,obj.Score, ruleserver.PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.Type, obj.Rects, obj.Car,obj.Feature,obj.BodyFeature,obj.ThftRes, []*structure.BaseInfo{},"",structure.ResultMsg{}},structure.SourceArg{}}
+			arg1 := structure.Arg{structure.SourceArg{obj.Id,uuid,obj.Score, ruleserver.PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.Type, obj.Rects, obj.Car,obj.Feature,obj.ThftRes, []*structure.BaseInfo{},"",structure.ResultMsg{}},structure.SourceArg{}}
 			//logger.Println("鏀捐繘鍘荤殑arg锛�-------", arg1)
 			a.Args = append(a.Args, &arg1)
 			a.FilterData = append(a.FilterData, &arg1)
@@ -54,7 +56,7 @@
 	}
 	for _, polygon := range cameraPolygons {
 		//logger.Println("++++++鍦ㄨ繖鍎跨湅涓�涓嬪尯鍩熷晩:", polygon.Polygon)
-		areaMap := structure.AreaMap{CameraId: cameraId, AreaId: polygon.Id, AreaJson: polygon.Polygon, TriggerLine: polygon.TriggerLine, DirectionLine: polygon.DirectionLine}
+		areaMap := structure.AreaMap{CameraId: cameraId, AreaId: polygon.Id,AreaJson: polygon.Polygon, TriggerLine: polygon.TriggerLine, DirectionLine: polygon.DirectionLine}
 		// 涓烘瘡涓憚鍍忔満鍖哄煙濉厖鏁版嵁
 		CountAreaObjs(&areaMap,arg)
 		arg.AreaMapList = append(arg.AreaMapList, &areaMap)
@@ -134,7 +136,7 @@
 		logger.Info("--------------杩借釜涔嬪悗浜鸿劯鐨勪釜鏁帮細", len(faceParam.Faces))
 		for _, info := range faceParam.Faces {
 			//logger.Info("_______________________________________________绗竴娆$湅鐩镐技鍊硷細",info.Pos.FAngle.Confidence*100)
-			photoMap := structure.PhotoMap{structure.SourcePhoto{Id: strconv.Itoa(int(info.Pos.FaceID)) , Rects: rectFormat(info.Pos.RcFace), Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: info.Feats},structure.SourcePhoto{}}
+			photoMap := structure.PhotoMap{structure.SourcePhoto{Id: strconv.Itoa(int(info.Pos.FaceID)) , Rects: rectFormat(info.Pos.RcFace), Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: base64.StdEncoding.EncodeToString(info.Feats)},structure.SourcePhoto{}}
 			arg.Photo = append(arg.Photo, photoMap)
 		}
 		args.Sdkdata = append(args.Sdkdata, &arg)
@@ -220,7 +222,8 @@
 		}
 		for _, info := range Track.Result {
 			logger.Info("鎺ユ敹璺熻釜鏁版嵁锛�",info.Id,info.Confidence,info.Feature)
-			photoMap := structure.PhotoMap{structure.SourcePhoto{Id: strconv.Itoa(int(info.Id)),Score: float64(info.Confidence)*100,Rects: rectFormat(info.RcHuman), Type: "track",BodyFeature: info.Feature},structure.SourcePhoto{}}
+			b,_ := json.Marshal(info.Feature)
+			photoMap := structure.PhotoMap{structure.SourcePhoto{Id: strconv.Itoa(int(info.Id)),Score: float64(info.Confidence)*100,Rects: rectFormat(info.RcHuman), Type: "track",Feature: base64.StdEncoding.EncodeToString(b)},structure.SourcePhoto{}}
 			arg.Photo = append(arg.Photo, photoMap)
 		}
 		args.Sdkdata = append(args.Sdkdata, &arg)
@@ -243,7 +246,7 @@
 			for _, info := range faceParam.Faces {
 				percent := ruleserver.PgsInterPercent(Rect2Point(photomap.Rects),rectFormat(info.Pos.RcFace), 1, 1)
 				if percent > 99 {
-					photomap.AttachObj = structure.SourcePhoto{Id:strconv.Itoa(int(info.Pos.FaceID)),Rects: rectFormat(info.Pos.RcFace),Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: info.Feats}
+					photomap.AttachObj = structure.SourcePhoto{Id:strconv.Itoa(int(info.Pos.FaceID)),Rects: rectFormat(info.Pos.RcFace),Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: base64.StdEncoding.EncodeToString(info.Feats)}
 				}
 			}
 		}
diff --git a/algorithm/personTrack/personTrack.go b/algorithm/personTrack/personTrack.go
index 1c7510e..d33e423 100644
--- a/algorithm/personTrack/personTrack.go
+++ b/algorithm/personTrack/personTrack.go
@@ -1,7 +1,6 @@
 package main
 
 import (
-	"encoding/base64"
 	"encoding/json"
 	"errors"
 	uuid "github.com/satori/go.uuid"
@@ -9,11 +8,11 @@
 	"strconv"
 	"time"
 
+	"basic.com/valib/logger.git"
+	"github.com/knetic/govaluate"
 	"nanomsg.org/go-mangos"
 	"nanomsg.org/go-mangos/protocol/req"
 	"nanomsg.org/go-mangos/transport/tcp"
-	"github.com/knetic/govaluate"
-	"basic.com/valib/logger.git"
 
 	"basic.com/pubsub/protomsg.git"
 	"ruleprocess/structure"
@@ -99,8 +98,8 @@
 	trackArg["esId"] = esId
 	trackArg["threshold"] = compareThreshold
 	trackArg["cameraId"] = am.CameraId
-	trackArg["bodyFeature"] = arg.BodyFeature
-	trackArg["faceFeature"]	= base64.StdEncoding.EncodeToString(arg.AttachArg.Feature)
+	trackArg["bodyFeature"] = arg.Feature
+	trackArg["faceFeature"]	= arg.AttachArg.Feature
 	logger.Info("璇锋眰寮犲椋炴瘮瀵规暟鎹弬鏁帮細",trackArg)
 	b,err := json.Marshal(trackArg)
 	if err != nil {
diff --git a/structure/rule.go b/structure/rule.go
index 3479096..4d97c92 100644
--- a/structure/rule.go
+++ b/structure/rule.go
@@ -15,8 +15,7 @@
 	Type        string                   // 璁拌浇鏁版嵁绫诲瀷
 	Location    Rect                     // 璁颁笅姣忎釜鐩爣鐨勪綅缃弬鏁帮紝鏈�鍚庣粰缁撴灉瑁呴厤鐩爣鏁版嵁鐨勬椂鍊欑敤鐨勫埌
 	Car         *protomsg.PlateIDVehicle // 杞﹁締鍙傛暟
-	Feature     []byte
-	BodyFeature []float32
+	Feature     string
 	ThftRes     protomsg.ThftResult
 	Liker       []*BaseInfo
 	TimeLable   string
@@ -53,8 +52,7 @@
 	Score       float64 // 鐩镐技搴﹀緱鍒嗭紙鏈夊澶х▼搴﹀儚涓�涓洰鏍囥�備汉鑴革紝浜轰綋鎴栬溅绛夌瓑锛�
 	Type        string  // 璁拌浇鏁版嵁绫诲瀷
 	ThftRes     protomsg.ThftResult
-	Feature     []byte
-	BodyFeature []float32
+	Feature     string
 	Car         *protomsg.PlateIDVehicle
 }
 

--
Gitblit v1.8.0