| 88 | return plg.Polygon( pointMat) |
| 89 | |
| 90 | def rectangle_to_polygon(rect): |
| 91 | resBoxes=np.empty([1,8],dtype='int32') |
| 92 | resBoxes[0,0]=int(rect.xmin) |
| 93 | resBoxes[0,4]=int(rect.ymax) |
| 94 | resBoxes[0,1]=int(rect.xmin) |
| 95 | resBoxes[0,5]=int(rect.ymin) |
| 96 | resBoxes[0,2]=int(rect.xmax) |
| 97 | resBoxes[0,6]=int(rect.ymin) |
| 98 | resBoxes[0,3]=int(rect.xmax) |
| 99 | resBoxes[0,7]=int(rect.ymax) |
| 100 | |
| 101 | pointMat = resBoxes[0].reshape([2,4]).T |
| 102 | |
| 103 | return plg.Polygon( pointMat) |
| 104 | |
| 105 | def rectangle_to_points(rect): |
| 106 | points = [int(rect.xmin), int(rect.ymax), int(rect.xmax), int(rect.ymax), int(rect.xmax), int(rect.ymin), int(rect.xmin), int(rect.ymin)] |