@@ -84,10 +84,20 @@ def save_image_with_joints(batch_joints, file_name, meta):
84
84
joint_coord = pano .getOriginalCoord (image , joint_coord )
85
85
joint_gt_coord = pano .getOriginalCoord (image , joint_gt_coord )
86
86
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 )
87
+ if joint_vis [0 ]:
88
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_coord [0 ])+ 4 , int (joint_coord [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
89
+ [255 , 0 , 0 ], 1 )
90
+ cv2 .circle (image , (int (joint_coord [0 ]), int (joint_coord [1 ])), 2 , [255 , 0 , 0 ], 2 )
91
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_gt_coord [0 ])+ 4 , int (joint_gt_coord [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
92
+ [0 ,255 , 0 ], 1 )
93
+ cv2 .circle (image , (int (joint_gt_coord [0 ]), int (joint_gt_coord [1 ])), 1 , [0 ,255 , 0 ], 2 )
94
+ else :
95
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_coord [0 ])+ 4 , int (joint_coord [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
96
+ [255 , 255 , 0 ], 1 )
97
+ cv2 .circle (image , (int (joint_coord [0 ]), int (joint_coord [1 ])), 2 , [255 , 255 , 0 ], 2 )
98
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_gt_coord [0 ])+ 4 , int (joint_gt_coord [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
99
+ [0 , 255 , 255 ], 1 )
100
+ cv2 .circle (image , (int (joint_gt_coord [0 ]), int (joint_gt_coord [1 ])), 1 , [0 , 255 , 255 ], 2 )
91
101
92
102
cv2 .imwrite (file_name , image )
93
103
@@ -208,3 +218,60 @@ def save_result_images(config, input, meta, target, joints_pred, output,
208
218
save_batch_heatmaps (
209
219
input , output , heatDir
210
220
)
221
+
222
+ def save_images_landmark (meta , batch_landmark , batch_classification , prefix , i ):
223
+ '''
224
+ batch_image: [1, channel, height, width]
225
+ batch_landmark: [1, 64],
226
+ batch_classification: [1, 32],
227
+ batch_joints: [1, 32, 3],
228
+ '''
229
+
230
+ if not os .path .exists (prefix ):
231
+ os .makedirs (prefix )
232
+
233
+ file_name = '{}_{}.jpg' .format (os .path .join (prefix , 'test' ), i )
234
+
235
+ pano = PANODataset (None )
236
+ image = cv2 .imread (meta ["filename" ][0 ], cv2 .IMREAD_COLOR )
237
+
238
+ joints_gt = meta ['joints' ][0 ]
239
+
240
+ cv2 .putText (image , 'pred' , (250 , 100 ), cv2 .FONT_ITALIC , 1.5 , [255 , 0 , 0 ], 3 )
241
+ cv2 .circle (image , (200 , 100 ), 3 , [255 , 0 , 0 ], 2 )
242
+ cv2 .putText (image , 'gt' , (250 , 170 ), cv2 .FONT_ITALIC , 1.5 , [0 , 255 , 0 ], 3 )
243
+ cv2 .circle (image , (200 , 170 ), 3 , [0 , 255 , 0 ], 2 )
244
+
245
+ batch_landmark = batch_landmark .reshape (1 , 32 , 2 )
246
+
247
+ for i , (joint_gt ) in enumerate (joints_gt ):
248
+
249
+ teeth_num = {1 : '18' , 2 : '17' , 3 : '16' , 4 : '15' , 5 : '14' , 6 : '13' , 7 : '12' , 8 : '11' ,
250
+ 9 : '21' , 10 : '22' , 11 : '23' , 12 : '24' , 13 : '25' , 14 : '26' , 15 : '27' , 16 : '28' ,
251
+ 17 : '48' , 18 : '47' , 19 : '46' , 20 : '45' , 21 : '44' , 22 : '43' , 23 : '42' , 24 : '41' ,
252
+ 25 : '31' , 26 : '32' , 27 : '33' , 28 : '34' , 29 : '35' , 30 : '36' , 31 : '37' , 32 : '38' }
253
+
254
+ joint_gt_coord = joint_gt [:2 ]
255
+ joint_gt_coord = pano .getOriginalCoord (image , joint_gt_coord )
256
+
257
+ joint_lm = batch_landmark [0 ][i ]
258
+ joint_lm = pano .getOriginalCoord (image , joint_lm )
259
+
260
+ cls = batch_classification [0 ][i ]
261
+
262
+ if cls > 0 :
263
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_lm [0 ])+ 4 , int (joint_lm [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
264
+ [255 , 0 , 0 ], 1 )
265
+ cv2 .circle (image , (int (joint_lm [0 ]), int (joint_lm [1 ])), 2 , [255 , 0 , 0 ], 2 )
266
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_gt_coord [0 ])+ 4 , int (joint_gt_coord [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
267
+ [0 ,255 , 0 ], 1 )
268
+ cv2 .circle (image , (int (joint_gt_coord [0 ]), int (joint_gt_coord [1 ])), 1 , [0 ,255 , 0 ], 2 )
269
+ else :
270
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_lm [0 ])+ 4 , int (joint_lm [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
271
+ [255 , 255 , 0 ], 1 )
272
+ cv2 .circle (image , (int (joint_lm [0 ]), int (joint_lm [1 ])), 2 , [255 , 255 , 0 ], 2 )
273
+ cv2 .putText (image , teeth_num [i + 1 ], (int (joint_gt_coord [0 ])+ 4 , int (joint_gt_coord [1 ])+ 4 ), cv2 .FONT_ITALIC , 0.4 ,
274
+ [0 , 255 , 255 ], 1 )
275
+ cv2 .circle (image , (int (joint_gt_coord [0 ]), int (joint_gt_coord [1 ])), 1 , [0 , 255 , 255 ], 2 )
276
+
277
+ cv2 .imwrite (file_name , image )
0 commit comments