| | |
| | | //rook := gocv.IMRead("/home/user/workspace/ruleprocess/util/105.jpg",gocv.IMReadColor) |
| | | defer rook.Close() |
| | | |
| | | green := color.RGBA{0, 255, 0, 0} |
| | | red := color.RGBA{255, 0, 0, 0} |
| | | //points := [][]image.Point{ |
| | | // { |
| | | // image.Pt(100., 100), |
| | |
| | | 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) |
| | | gocv.Line(&rook, image.Pt(int(points[index].X), int(points[index].Y)), image.Pt(int(points[0].X), int(points[0].Y)), red, 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) |
| | | 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)), red, 2) |
| | | } |
| | | |
| | | } |