@@ -50,8 +50,7 @@ def save_batch_image_with_joints(batch_image, batch_joints, batch_joints_vis,
50
50
k = k + 1
51
51
cv2 .imwrite (file_name , ndarr )
52
52
53
- def save_image_with_joints (batch_image , batch_joints , batch_joints_vis ,
54
- file_name , meta ):
53
+ def save_image_with_joints (batch_joints , file_name , meta ):
55
54
'''
56
55
batch_image: [1, channel, height, width]
57
56
batch_joints: [1, num_joints, 3],
@@ -63,25 +62,32 @@ def save_image_with_joints(batch_image, batch_joints, batch_joints_vis,
63
62
image = cv2 .imread (meta ["filename" ][0 ], cv2 .IMREAD_COLOR )
64
63
65
64
joints = batch_joints [0 ]
66
- joints_vis = batch_joints_vis [0 ]
65
+ joints_vis = meta [ 'joints_vis' ] [0 ]
67
66
joints_gt = meta ['joints' ][0 ]
68
67
69
68
cv2 .putText (image , 'pred' , (250 , 100 ), cv2 .FONT_ITALIC , 1.5 , [255 , 0 , 0 ], 3 )
70
69
cv2 .circle (image , (200 , 100 ), 3 , [255 , 0 , 0 ], 2 )
71
70
cv2 .putText (image , 'gt' , (250 , 170 ), cv2 .FONT_ITALIC , 1.5 , [0 , 255 , 0 ], 3 )
72
71
cv2 .circle (image , (200 , 170 ), 3 , [0 , 255 , 0 ], 2 )
73
72
74
- for joint , joint_vis , joint_gt in zip (joints , joints_vis , joints_gt ):
73
+ for i , ( joint , joint_vis , joint_gt ) in enumerate ( zip (joints , joints_vis , joints_gt ) ):
75
74
#joint[0] = x * width + padding + joint[0]
76
75
#joint[1] = y * height + padding + joint[1]
76
+
77
+ teeth_num = {1 : '18' , 2 : '17' , 3 : '16' , 4 : '15' , 5 : '14' , 6 : '13' , 7 : '12' , 8 : '11' ,
78
+ 9 : '21' , 10 : '22' , 11 : '23' , 12 : '24' , 13 : '25' , 14 : '26' , 15 : '27' , 16 : '28' ,
79
+ 17 : '48' , 18 : '47' , 19 : '46' , 20 : '45' , 21 : '44' , 22 : '43' , 23 : '42' , 24 : '41' ,
80
+ 25 : '31' , 26 : '32' , 27 : '33' , 28 : '34' , 29 : '35' , 30 : '36' , 31 : '37' , 32 : '38' }
81
+
77
82
joint_coord = joint [:2 ]
78
83
joint_gt_coord = joint_gt [:2 ]
79
84
joint_coord = pano .getOriginalCoord (image , joint_coord )
80
85
joint_gt_coord = pano .getOriginalCoord (image , joint_gt_coord )
81
86
82
- if joint_vis [0 ]:
83
- cv2 .circle (image , (int (joint_coord [0 ]), int (joint_coord [1 ])), 2 , [255 , 0 , 0 ], 2 )
84
- cv2 .circle (image , (int (joint_gt_coord [0 ]), int (joint_gt_coord [1 ])), 2 , [0 ,255 , 0 ], 2 )
87
+ #if joint_vis[0]:
88
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_coord [0 ]), int (joint_coord [1 ])), cv2 .FONT_ITALIC , 0.4 , [255 , 0 , 0 ], 1 )
89
+ cv2 .circle (image , (int (joint_coord [0 ]), int (joint_coord [1 ])), 2 , [255 , 0 , 0 ], 2 )
90
+ cv2 .circle (image , (int (joint_gt_coord [0 ]), int (joint_gt_coord [1 ])), 2 , [0 ,255 , 0 ], 2 )
85
91
86
92
cv2 .imwrite (file_name , image )
87
93
@@ -184,22 +190,21 @@ def save_result_images(config, input, meta, target, joints_pred, output,
184
190
if not os .path .exists (os .path .join (prefix , 'heatmap' )):
185
191
os .makedirs (os .path .join (prefix , 'heatmap' ))
186
192
187
- heatDir = '{}_{}' .format (os .path .join (prefix , 'heatmap' , 'test' ), i )
188
- imgDir = '{}_{}' .format (os .path .join (prefix , 'test' ), i )
193
+ heatDir = '{}_{}.jpg ' .format (os .path .join (prefix , 'heatmap' , 'test' ), i )
194
+ imgDir = '{}_{}.jpg ' .format (os .path .join (prefix , 'test' ), i )
189
195
190
196
if not config .DEBUG .DEBUG :
191
197
return
192
198
193
199
if config .DEBUG .SAVE_BATCH_IMAGES_PRED :
194
200
save_image_with_joints (
195
- input , joints_pred , meta ['joints_vis' ],
196
- '{}.jpg' .format (imgDir ), meta
201
+ joints_pred , imgDir , meta
197
202
)
198
203
if config .DEBUG .SAVE_HEATMAPS_GT :
199
204
save_batch_heatmaps (
200
- input , target , '{}_hm_gt.jpg' . format ( heatDir )
205
+ input , target , heatDir
201
206
)
202
207
if config .DEBUG .SAVE_HEATMAPS_PRED :
203
208
save_batch_heatmaps (
204
- input , output , '{}_hm_pred.jpg' . format ( heatDir )
209
+ input , output , heatDir
205
210
)
0 commit comments