From b9402160dbd2f5051c5781fa65a3ff6e7d49e0cb Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 09 十二月 2019 17:45:12 +0800
Subject: [PATCH] es模块儿做成so

---
 util/simpleCV.go |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/util/simpleCV.go b/util/simpleCV.go
index e88e0b8..32bcdef 100644
--- a/util/simpleCV.go
+++ b/util/simpleCV.go
@@ -187,6 +187,37 @@
 	return
 }
 
+func DrawPolygonOnImageForTarget(cameraId string, img protomsg.Image, results []structure.Result,url string) (maps map[string]interface{}, err0 error) {
+
+	rook, _ := gocv.NewMatFromBytes(int(img.Height), int(img.Width), gocv.MatTypeCV8UC3, img.Data)
+	//rook := gocv.IMRead("/home/user/workspace/ruleprocess/util/105.jpg",gocv.IMReadColor)
+	defer rook.Close()
+
+	yellow := color.RGBA{255, 255, 0, 0}
+	red := color.RGBA{255, 0, 0, 0}
+	scale := float64(img.Width) / 960 // 鐢诲浘姣斾緥
+	logger.Info("width:",img.Width,"--鐢诲浘姣斾緥锛�",scale)
+	// 鍒嗗壊鍖哄煙id闆嗗悎骞舵牴鎹甶d鏌ヨ鍖哄煙鐒跺悗鐢绘
+	for _,result := range results  {
+		polygonIds := strings.Split(result.AlarmPolygon,",")
+		logger.Info("鍖哄煙ID锛�",result.AlarmPolygon,polygonIds)
+		for i := 0; i < len(polygonIds); i++ {
+			polygon := getPolygonById(polygonIds[i],cameraId)
+			if polygon.Polygon != "[]" && polygon.Polygon != ""{
+				DrawAPolygon(&rook,polygon.Polygon,yellow,scale)
+			}
+		}
+	}
+	// 鎶婄洰鏍囨鍑烘潵
+	for _,result := range results  {
+		for _,rect := range result.AlarmObj {
+			gocv.Rectangle(&rook, image.Rect(int(rect.Location.X), int(rect.Location.Y), int(rect.Location.X+rect.Location.Width), int(rect.Location.Y+rect.Location.Height)), red, 1)
+		}
+	}
+	//return nil,nil
+	maps,err0 = UploadFromMat(url,rook)
+	return
+}
 func DrawPolygonOnImageForFace(cameraId string, img protomsg.Image, results []structure.Result,url string) (maps map[string]interface{}, err0 error) {
 
 	rook, _ := gocv.NewMatFromBytes(int(img.Height), int(img.Width), gocv.MatTypeCV8UC3, img.Data)

--
Gitblit v1.8.0