panlei
2019-12-09 b9402160dbd2f5051c5781fa65a3ff6e7d49e0cb
util/simpleCV.go
@@ -178,8 +178,8 @@
   }
   // 把目标框出来
   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
@@ -187,7 +187,38 @@
   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}
   red := color.RGBA{255, 0, 0, 0}
   scale := float64(img.Width) / 960 // 画图比例
   logger.Info("width:",img.Width,"--画图比例:",scale)
   // 分割区域id集合并根据id查询区域然后画框
   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)