From f47efb3d5ea0bfbe709a2b24dbf67a916fc50bb4 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期二, 26 十一月 2019 17:53:18 +0800
Subject: [PATCH] ---
---
util/simpleCV.go | 61 +++++++++++++++++-------------
1 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/util/simpleCV.go b/util/simpleCV.go
index d32691f..32bcdef 100644
--- a/util/simpleCV.go
+++ b/util/simpleCV.go
@@ -155,11 +155,6 @@
}
}
}
-
-<<<<<<< HEAD
-
-=======
->>>>>>> a87978244bbb81f2fa7610560ed190acbaa422f8
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)
@@ -173,22 +168,18 @@
// 鍒嗗壊鍖哄煙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 != ""{
-<<<<<<< HEAD
DrawAPolygon(&rook,polygon.Polygon,yellow,scale)
-=======
- logger.Debug("鎵�鐢诲尯鍩燂細",polygon.Polygon)
- DrawAPolygon(&rook,polygon.Polygon,yellow)
->>>>>>> a87978244bbb81f2fa7610560ed190acbaa422f8
}
}
}
// 鎶婄洰鏍囨鍑烘潵
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)), red, 1)
+ 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
@@ -196,14 +187,44 @@
return
}
-func DrawPolygonOnImageForFace(cameraId string, img protomsg.Image, results []structure.FaceResult,url string) (maps map[string]interface{}, err0 error) {
+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}
-<<<<<<< HEAD
+ 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)
+ //rook := gocv.IMRead("/home/user/workspace/ruleprocess/util/105.jpg",gocv.IMReadColor)
+ defer rook.Close()
+
+ yellow := color.RGBA{255, 255, 0, 0}
scale := float64(img.Width) / 960 // 鐢诲浘姣斾緥
// 鍒嗗壊鍖哄煙id闆嗗悎骞舵牴鎹甶d鏌ヨ鍖哄煙鐒跺悗鐢绘
for _,result := range results {
@@ -212,18 +233,6 @@
polygon := getPolygonById(polygonIds[i],cameraId)
if polygon.Polygon != "[]" && polygon.Polygon != ""{
DrawAPolygon(&rook,polygon.Polygon,yellow,scale)
-=======
-
- // 鍒嗗壊鍖哄煙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)
->>>>>>> a87978244bbb81f2fa7610560ed190acbaa422f8
}
}
}
--
Gitblit v1.8.0