panlei
2019-07-17 5f48e7f9c10ed76112986b9d59c9517845df6b35
util/simpleCV.go
@@ -9,6 +9,7 @@
   "image/color"
   "os"
   "ruleprocess/cache"
   "ruleprocess/logger"
   "ruleprocess/ruleserver"
   "strings"
)
@@ -154,7 +155,7 @@
   }
}
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)
@@ -165,10 +166,11 @@
   // 分割区域id集合并根据id查询区域然后画框
   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 != "" {
         if polygon.Polygon != "[]" {
            DrawAPolygon(&rook,polygon.Polygon,red)
         }
      }
@@ -180,7 +182,7 @@
      }
   }
   //return nil,nil
   maps,err0 = UploadFromMat(rook)
   maps,err0 = UploadFromMat(url,rook)
   return
}