From 756e00d553bae59f3eddc54fa6131f155e0a6310 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期三, 09 十月 2019 18:51:29 +0800
Subject: [PATCH] 把结构体提出来单独模块儿
---
util/simpleCV.go | 41 ++++++++++++++++++++++++++++++++++-------
1 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/util/simpleCV.go b/util/simpleCV.go
index 1915cf7..9e48691 100644
--- a/util/simpleCV.go
+++ b/util/simpleCV.go
@@ -9,8 +9,9 @@
"image/color"
"os"
"ruleprocess/cache"
- "ruleprocess/logger"
+ "basic.com/valib/logger.git"
"ruleprocess/ruleserver"
+ "ruleprocess/structure"
"strings"
)
@@ -155,14 +156,14 @@
}
}
-func DrawPolygonOnImage(cameraId string, img protomsg.Image, results []ruleserver.Result,url string) (maps map[string]interface{}, err0 error) {
+func DrawPolygonOnImageForYolo(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}
- green := color.RGBA{0, 255, 0, 0}
+ red := color.RGBA{255, 0, 0, 0}
// 鍒嗗壊鍖哄煙id闆嗗悎骞舵牴鎹甶d鏌ヨ鍖哄煙鐒跺悗鐢绘
for _,result := range results {
@@ -170,7 +171,8 @@
logger.Info("-----------------------鐪嬬湅鎶ヨ鍖哄煙id锛�",polygonIds)
for i := 0; i < len(polygonIds)-1; i++ {
polygon := getPolygonById(polygonIds[i],cameraId)
- if polygon.Polygon != "[]" {
+ if polygon.Polygon != "[]" && polygon.Polygon != ""{
+ logger.Debug("鎵�鐢诲尯鍩燂細",polygon.Polygon)
DrawAPolygon(&rook,polygon.Polygon,yellow)
}
}
@@ -178,7 +180,32 @@
// 鎶婄洰鏍囨鍑烘潵
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(url,rook)
+ return
+}
+
+func DrawPolygonOnImageForFace(cameraId string, img protomsg.Image, results []structure.FaceResult,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}
+
+ // 鍒嗗壊鍖哄煙id闆嗗悎骞舵牴鎹甶d鏌ヨ鍖哄煙鐒跺悗鐢绘
+ for _,result := range results {
+ 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 != "[]" && polygon.Polygon != ""{
+ logger.Debug("鎵�鐢诲尯鍩燂細",polygon.Polygon)
+ DrawAPolygon(&rook,polygon.Polygon,yellow)
+ }
}
}
//return nil,nil
@@ -225,9 +252,9 @@
points := ruleserver.Json2points(polygonString)
for index := 0; index < len(points); index++ {
if index == len(points)-1 { // 闂悎鍥惧舰
- gocv.Line(rook, image.Pt(int(points[index].X), int(points[index].Y)), image.Pt(int(points[0].X), int(points[0].Y)), color, 2)
+ gocv.Line(rook, image.Pt(int(points[index].X*1.33), int(points[index].Y*1.33)), image.Pt(int(points[0].X*1.33), int(points[0].Y*1.33)), color, 2)
} else {
- gocv.Line(rook, image.Pt(int(points[index].X), int(points[index].Y)), image.Pt(int(points[index+1].X), int(points[index+1].Y)), color, 2)
+ gocv.Line(rook, image.Pt(int(points[index].X*1.33), int(points[index].Y*1.33)), image.Pt(int(points[index+1].X*1.33), int(points[index+1].Y*1.33)), color, 2)
}
}
}
--
Gitblit v1.8.0