From 3b67420a888523f51e65ac40bb57a5a55c126b9a Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 01 七月 2019 15:01:55 +0800
Subject: [PATCH] 添加了人脸提取的sdk数据处理

---
 util/simpleCV.go             |   30 +++++++++++++++
 insertdata/insertDataToEs.go |    2 +
 ruleserver/ruleToformula.go  |    7 +--
 main.go                      |   43 ++++++++++++++++++++-
 4 files changed, 75 insertions(+), 7 deletions(-)

diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go
index f7ab22a..b4c5553 100644
--- a/insertdata/insertDataToEs.go
+++ b/insertdata/insertDataToEs.go
@@ -173,6 +173,8 @@
 				if err != nil {
 					log.Println("es can not execute right.")
 				}
+			}else {
+				log.Println("璺熷簳搴撶殑鐩镐技鏁版嵁---------锛�",face.Liker)
 			}
 		}
 	}
diff --git a/main.go b/main.go
index bbcfd4d..363391c 100644
--- a/main.go
+++ b/main.go
@@ -152,9 +152,46 @@
 				continue
 			}
 		}
-		//if sdkinfo.Sdktype == "FaceExtract" { // 浜鸿劯鎻愬彇
-
-		//}
+		if sdkinfo.Sdktype == "FaceExtract" { // 浜鸿劯鎻愬彇
+			arg := ruleserver.SdkData{}
+			arg.TaskId = m.Tasklab.Taskid
+			arg.SdkId = sdkinfo.Sdkid
+			arg.SdkName = sdkinfo.SdkName
+			arg.IsYolo = false
+			bdata, err := util.UnCompress(m.Data)
+			if err != nil {
+				panic("瑙e帇缂╁浘鐗囨椂鍑虹幇閿欒")
+			}
+			i := protomsg.Image{}
+			err = proto.Unmarshal(bdata, &i)
+			arg.ImageWidth = int(i.Width)
+			arg.ImageHeight = int(i.Height)
+			// 鏆傛椂鍐欐锛宻dk杩樻病鏈夎繖淇╃畻娉�
+			arg.KeepRight = false
+			arg.IsStatic = false
+			if len(sdkinfo.Sdkdata) > 1 {
+				fmt.Println("----------------------------------------------------",m.Caddr)
+				faceParam := protomsg.ParamFaceFeature{}
+				err = proto.Unmarshal(sdkinfo.Sdkdata, &faceParam)
+				if err != nil {
+					fmt.Println("瑙f瀽FACE sdk鏁版嵁鏃跺嚭鐜伴敊璇�", err)
+					continue
+				}
+				for _, extComp := range faceParam.ExtComp {
+					baseinfos := protomsg.Binfos{}
+					err1 := proto.Unmarshal(extComp.Comp, &baseinfos)
+					if err1 != nil {
+						fmt.Println("瑙f瀽FACE sdk鏁版嵁鏃跺嚭鐜伴敊璇�", err)
+						continue
+					}
+					photoMap := ruleserver.PhotoMap{Rects: rectFormat(extComp.Pos.Pos.RcFace), Score: float64(extComp.Pos.Pos.Quality)*100, IsYolo:false,ThftRes:*(extComp.Pos.Result),Liker:baseinfos.Infos}
+					arg.Photo = append(arg.Photo, photoMap)
+				}
+				args.Sdkdata = append(args.Sdkdata,&arg)
+			} else {
+				continue
+			}
+		}
 
 	}
 	return m
diff --git a/ruleserver/ruleToformula.go b/ruleserver/ruleToformula.go
index 607afd3..c5a562e 100644
--- a/ruleserver/ruleToformula.go
+++ b/ruleserver/ruleToformula.go
@@ -64,7 +64,7 @@
 	Location   Rect    // 璁颁笅姣忎釜鐩爣鐨勪綅缃弬鏁帮紝鏈�鍚庣粰缁撴灉瑁呴厤浜鸿劯鏁版嵁鐨勬椂鍊欑敤鐨勫埌
 	SdkName    string
 	ThftRes    protomsg.ThftResult
-	Liker      []LikePerson
+	Liker      []*protomsg.Baseinfo
 }
 
 type LikePerson struct {
@@ -98,7 +98,7 @@
 	IsYolo  bool    // 鏄惁鏄痽olo鏁版嵁
 	SdkName string
 	ThftRes protomsg.ThftResult
-	Liker   []LikePerson // 濡傛灉鏄汉鑴哥殑璇濆挨鍏舵槸姣斿锛屽簲瀛樹笅浠栬窡搴曞簱鐨勪汉鍛樼殑鐩镐技鎯呭喌 yolo鐨勮瘽缁檔il灏辫
+	Liker   []*protomsg.Baseinfo // 濡傛灉鏄汉鑴哥殑璇濆挨鍏舵槸姣斿锛屽簲瀛樹笅浠栬窡搴曞簱鐨勪汉鍛樼殑鐩镐技鎯呭喌 yolo鐨勮瘽缁檔il灏辫
 }
 
 // 姣忎釜绠楁硶瀵逛簬褰撳墠甯х敾闈㈣嚜宸辨彁鍙栫殑鏁版嵁
@@ -521,7 +521,7 @@
 				for _, obj := range am.filterData {
 					for index := 0; index < len(obj.Liker); {
 						// 灏嗚揪涓嶅埌闃堝�肩殑鐩镐技鑰呬粠鐩镐技鑰呮暟缁勪腑鍒犻櫎
-						if obj.Liker[index].Score < argValue {
+						if float64(obj.Liker[index].CompareScore) < argValue {
 							// Go 璇█涓垏鐗囧垹闄ゅ厓绱犵殑鏈川鏄細浠ヨ鍒犻櫎鍏冪礌涓哄垎鐣岀偣锛屽皢鍓嶅悗涓や釜閮ㄥ垎鐨勫唴瀛橀噸鏂拌繛鎺ヨ捣鏉ャ�備笉鐢ㄦ��鐤戯紝鏁扮粍鍒犻櫎鍏冪礌灏辫繖涔堝潙鐖�
 							obj.Liker = append(obj.Liker[:index], obj.Liker[index+1:]...)
 						} else {
@@ -589,7 +589,6 @@
 		}
 	} else {
 		// 澶勭悊鐨勯兘鏄痽olo鏁版嵁
-		log.Println("瑙勫垯涓殑sdkId涓猴細", rule.SdkId, "--鍖哄煙鏁版嵁闆嗗悎涓殑sdkId涓猴細", am.sdkId, "--瑙勫垯涓殑鍖哄煙Id涓猴細", rule.PolygonId, "--鍖哄煙鏁版嵁闆嗗悎涓殑鍖哄煙Id涓猴細", am.areaId, )
 		if rule.SdkId == am.sdkId && rule.PolygonId == am.areaId { // 棣栧厛杩欐潯瑙勫垯寰楁槸杩欎釜绠楁硶鐨勮鍒欙紝鍏舵瑙勫垯鎵�瀵瑰簲鐨勫尯鍩焛d瑕佽窡鍖哄煙鏁版嵁鐨刬d瀵圭殑涓�
 			if rule.SdkArgAlias == "score" || rule.SdkArgAlias == "proportion" || rule.SdkArgAlias == "size" { // 鍒ゆ柇鐨勬槸鐩镐技鍊硷紝鍗犳瘮锛屽昂瀵哥瓑杩囨护鏉′欢锛屽鏋滃啀鏈夛紝杩樺彲浠ュ啀鍔�
 				var args []Arg
diff --git a/util/simpleCV.go b/util/simpleCV.go
index 05827b1..9513826 100644
--- a/util/simpleCV.go
+++ b/util/simpleCV.go
@@ -93,6 +93,7 @@
 	defer atom.Close()
 
 	rook := gocv.NewMatWithSize(w, w, gocv.MatTypeCV8UC3)
+	gocv.NewMatW
 	defer rook.Close()
 
 	black := color.RGBA{0, 0, 0, 0}
@@ -149,3 +150,32 @@
 		}
 	}
 }
+
+func DrawPolygon(){
+	// draw the rook
+	points := [][]image.Point{
+		{
+			image.Pt(w/4., 7*w/8.),
+			image.Pt(3*w/4., 7*w/8.),
+			image.Pt(3*w/4., 13*w/16.),
+			image.Pt(11*w/16., 13*w/16.),
+			image.Pt(19*w/32., 3*w/8.),
+			image.Pt(3*w/4., 3*w/8.),
+			image.Pt(3*w/4., w/8.),
+			image.Pt(26*w/40., w/8.),
+			image.Pt(26*w/40., w/4.),
+			image.Pt(22*w/40., w/4.),
+			image.Pt(22*w/40., w/8.),
+			image.Pt(18*w/40., w/8.),
+			image.Pt(18*w/40., w/4.),
+			image.Pt(14*w/40., w/4.),
+			image.Pt(14*w/40., w/8.),
+			image.Pt(w/4., w/8.),
+			image.Pt(w/4., 3*w/8.),
+			image.Pt(13*w/32., 3*w/8.),
+			image.Pt(5*w/16., 13*w/16.),
+			image.Pt(w/4., 13*w/16.),
+		},
+	}
+	gocv.FillPoly(&rook, points, white)
+}

--
Gitblit v1.8.0