8
8
from __future__ import print_function
9
9
10
10
import numpy as np
11
+ from six .moves import range
11
12
import PIL .Image as Image
12
13
import PIL .ImageColor as ImageColor
13
14
import PIL .ImageDraw as ImageDraw
39
40
'WhiteSmoke' , 'Yellow' , 'YellowGreen'
40
41
]
41
42
42
- def draw_single_box (image , xmin , ymin , xmax , ymax , display_str , font , color = 'black' , thickness = 4 ):
43
+ NUM_COLORS = len (STANDARD_COLORS )
44
+
45
+ try :
46
+ FONT = ImageFont .truetype ('arial.ttf' , 24 )
47
+ except IOError :
48
+ FONT = ImageFont .load_default ()
49
+
50
+ def _draw_single_box (image , xmin , ymin , xmax , ymax , display_str , font , color = 'black' , thickness = 4 ):
43
51
draw = ImageDraw .Draw (image )
44
52
(left , right , top , bottom ) = (xmin , xmax , ymin , ymax )
45
53
draw .line ([(left , top ), (left , bottom ), (right , bottom ),
@@ -62,15 +70,10 @@ def draw_single_box(image, xmin, ymin, xmax, ymax, display_str, font, color='bla
62
70
63
71
def draw_bounding_boxes (image , gt_boxes , im_info ):
64
72
num_boxes = gt_boxes .shape [0 ]
65
- num_colors = len ( STANDARD_COLORS )
66
- im_info = im_info [0 ]
73
+ gt_boxes_new = gt_boxes . copy ( )
74
+ gt_boxes_new [:,: 4 ] = np . round ( gt_boxes_new [:,: 4 ]. copy () / im_info [2 ])
67
75
disp_image = Image .fromarray (np .uint8 (image [0 ]))
68
76
69
- try :
70
- font = ImageFont .truetype ('arial.ttf' , 24 )
71
- except IOError :
72
- font = ImageFont .load_default ()
73
-
74
77
for i in range (num_boxes ):
75
78
this_class = int (gt_boxes [i , 4 ])
76
79
disp_image = draw_single_box (disp_image ,
0 commit comments