From d5849806de2339beaec4216ede8ffbbf803e6f19 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 29 七月 2019 13:32:24 +0800
Subject: [PATCH] ---
---
util/simpleCV.go | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/util/simpleCV.go b/util/simpleCV.go
index 7f07bff..44f6500 100644
--- a/util/simpleCV.go
+++ b/util/simpleCV.go
@@ -9,6 +9,7 @@
"image/color"
"os"
"ruleprocess/cache"
+ "ruleprocess/logger"
"ruleprocess/ruleserver"
"strings"
)
@@ -154,33 +155,34 @@
}
}
-func DrawPolygonOnImage(cameraId string, img protomsg.Image, results []ruleserver.Result) (maps map[string]interface{}, err0 error) {
+func DrawPolygonOnImage(cameraId string, img protomsg.Image, results []ruleserver.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}
- green := color.RGBA{0, 255, 0, 0}
// 鍒嗗壊鍖哄煙id闆嗗悎骞舵牴鎹甶d鏌ヨ鍖哄煙鐒跺悗鐢绘
for _,result := range results {
- polygonIds := strings.Split(result.AlarmPolygon,"")
+ polygonIds := strings.Split(result.AlarmPolygon,",")
+ logger.Info("-----------------------鐪嬬湅鎶ヨ鍖哄煙id锛�",polygonIds)
for i := 0; i < len(polygonIds)-1; i++ {
polygon := getPolygonById(polygonIds[i],cameraId)
- if polygon.Polygon != "" {
- DrawAPolygon(&rook,polygon.Polygon,red)
+ if polygon.Polygon != "[]" {
+ DrawAPolygon(&rook,polygon.Polygon,yellow)
}
}
}
// 鎶婄洰鏍囨鍑烘潵
for _,result := range results {
for _,rect := range result.Location {
- gocv.Rectangle(&rook, image.Rect(int(rect.X), int(rect.Y), int(rect.X+rect.Width), int(rect.Y+rect.Height)), green, 1)
+ gocv.Rectangle(&rook, image.Rect(int(rect.X), int(rect.Y), int(rect.X+rect.Width), int(rect.Y+rect.Height)), red, 1)
}
}
//return nil,nil
- maps,err0 = UploadFromMat(rook)
+ maps,err0 = UploadFromMat(url,rook)
return
}
--
Gitblit v1.8.0