| | |
| | | |
| | | 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,",") |
| | |
| | | polygon := getPolygonById(polygonIds[i],cameraId) |
| | | if polygon.Polygon != "[]" && polygon.Polygon != ""{ |
| | | logger.Debug("所画区域:",polygon.Polygon) |
| | | DrawAPolygon(&rook,polygon.Polygon,yellow) |
| | | DrawAPolygon(&rook,polygon.Polygon,yellow,scale) |
| | | } |
| | | } |
| | | } |
| | |
| | | defer rook.Close() |
| | | |
| | | yellow := color.RGBA{255, 255, 0, 0} |
| | | |
| | | scale := float64(img.Width) / 960 // 画图比例 |
| | | // 分割区域id集合并根据id查询区域然后画框 |
| | | for _,result := range results { |
| | | polygonIds := strings.Split(result.AlarmPolygon,",") |
| | |
| | | logger.Info("----查到的报警框:",polygon) |
| | | if polygon.Polygon != "[]" && polygon.Polygon != ""{ |
| | | logger.Debug("所画区域:",polygon.Polygon) |
| | | DrawAPolygon(&rook,polygon.Polygon,yellow) |
| | | DrawAPolygon(&rook,polygon.Polygon,yellow,scale) |
| | | } |
| | | } |
| | | } |
| | |
| | | return protomsg.CameraPolygon{} |
| | | } |
| | | // 在图上画一个框 |
| | | func DrawAPolygon(rook *gocv.Mat,polygonString string, color color.RGBA) { |
| | | func DrawAPolygon(rook *gocv.Mat,polygonString string, color color.RGBA,scale float64) { |
| | | 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*1.33), int(points[index].Y*1.33)), image.Pt(int(points[0].X*1.33), int(points[0].Y*1.33)), color, 2) |
| | | gocv.Line(rook, image.Pt(int(points[index].X * scale), int(points[index].Y * scale)), image.Pt(int(points[0].X * scale), int(points[0].Y * scale)), color, 2) |
| | | } else { |
| | | 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) |
| | | gocv.Line(rook, image.Pt(int(points[index].X * scale), int(points[index].Y * scale)), image.Pt(int(points[index+1].X * scale), int(points[index+1].Y * scale)), color, 2) |
| | | } |
| | | } |
| | | } |