| | |
| | | "mime/multipart" |
| | | "net/http" |
| | | "os" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/ruleserver" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | func DrawPolygonOnImage(img protomsg.Image)(maps map[string]interface{}, err0 error){ |
| | | func DrawPolygonOnImage(cameraId string, img protomsg.Image) (maps map[string]interface{}, err0 error) { |
| | | // draw the rook |
| | | //ddd, err := RetrieveROM("/home/user/workspace/ruleprocess/util/105.jpg") |
| | | //if err != nil { |
| | |
| | | // }, |
| | | //} |
| | | //gocv.FillPoly(&rook, points, green) |
| | | gocv.Line(&rook, image.Pt(100, 100), image.Pt(100, 800), green, 2) |
| | | gocv.Line(&rook, image.Pt(100, 800), image.Pt(800, 800), green, 2) |
| | | gocv.Line(&rook, image.Pt(800, 800), image.Pt(800, 100), green, 2) |
| | | gocv.Line(&rook, image.Pt(800, 100), image.Pt(100, 100), green, 2) |
| | | // 查到摄像机所有的区域并画框 |
| | | var cameraPolygons []protomsg.CameraPolygon |
| | | cameraPolygons = cache.GetPolygonsByCameraId(cameraId) |
| | | for _, polygon := range cameraPolygons { |
| | | points := ruleserver.Json2points(polygon.Polygon) |
| | | 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)), green, 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)), green, 2) |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | //return nil,nil |
| | | // 上传 |