@@ -661,7 +661,10 @@ def to_tile_coords(
661
661
Array of coordinates in tile space in the form [x, y].
662
662
663
663
"""
664
- return ((np .reshape (coords , (- 1 , 2 )) - top_left ) / scale ).astype (np .int32 )
664
+ return [
665
+ ((np .reshape (ring , (- 1 , 2 )) - top_left ) / scale ).astype (np .int32 )
666
+ for ring in coords
667
+ ]
665
668
666
669
def get_color (
667
670
self : AnnotationRenderer ,
@@ -756,19 +759,26 @@ def render_poly(
756
759
scale ,
757
760
)
758
761
if self .thickness > - 1 :
759
- cv2 .drawContours (
762
+ cv2 .polylines (
760
763
tile ,
761
- [ cnt ] ,
762
- 0 ,
763
- col ,
764
- self .edge_thickness ,
764
+ cnt ,
765
+ isClosed = True ,
766
+ color = col ,
767
+ thickness = self .edge_thickness ,
765
768
lineType = cv2 .LINE_8 ,
766
769
)
767
770
else :
768
- cv2 .drawContours (tile , [ cnt ], 0 , col , self . thickness , lineType = cv2 . LINE_8 )
771
+ cv2 .fillPoly (tile , cnt , col )
769
772
if self .thickness == - 1 and self .edge_thickness > 0 :
770
773
edge_col = self .get_color (annotation , edge = True )
771
- cv2 .drawContours (tile , [cnt ], 0 , edge_col , 1 , lineType = cv2 .LINE_8 )
774
+ cv2 .polylines (
775
+ tile ,
776
+ cnt ,
777
+ isClosed = True ,
778
+ color = edge_col ,
779
+ thickness = 1 ,
780
+ lineType = cv2 .LINE_8 ,
781
+ )
772
782
773
783
def render_multipoly (
774
784
self : AnnotationRenderer ,
@@ -782,7 +792,7 @@ def render_multipoly(
782
792
geoms = annotation .coords
783
793
for poly in geoms :
784
794
cnt = self .to_tile_coords (poly , top_left , scale )
785
- cv2 .drawContours (tile , [ cnt ], 0 , col , self . thickness , lineType = cv2 . LINE_8 )
795
+ cv2 .fillPoly (tile , cnt , col )
786
796
787
797
def render_pt (
788
798
self : AnnotationRenderer ,
@@ -811,7 +821,7 @@ def render_pt(
811
821
annotation .coords ,
812
822
top_left ,
813
823
scale ,
814
- )[0 ],
824
+ )[0 ][ 0 ] ,
815
825
np .maximum (self .edge_thickness , 1 ),
816
826
col ,
817
827
thickness = self .thickness ,
@@ -838,15 +848,14 @@ def render_line(
838
848
839
849
"""
840
850
col = self .get_color (annotation , edge = False )
851
+ cnt = self .to_tile_coords (
852
+ list (annotation .coords ),
853
+ top_left ,
854
+ scale ,
855
+ )
841
856
cv2 .polylines (
842
857
tile ,
843
- [
844
- self .to_tile_coords (
845
- list (annotation .coords ),
846
- top_left ,
847
- scale ,
848
- ),
849
- ],
858
+ [np .array (cnt )],
850
859
isClosed = False ,
851
860
color = col ,
852
861
thickness = 3 ,
0 commit comments