@@ -35,19 +35,19 @@ def options():
3535 parser = argparse .ArgumentParser ()
3636 kitti_parser = parser .add_argument_group ()
3737 kitti_parser .add_argument ("--base_dir" ,type = str ,default = "/data/DATA/data_odometry/dataset/" )
38- kitti_parser .add_argument ("--seq" ,type = int ,default = 0 ,choices = [i for i in range (11 )])
38+ kitti_parser .add_argument ("--seq" ,type = int ,default = 5 ,choices = [i for i in range (11 )])
3939
4040 io_parser = parser .add_argument_group ()
41- io_parser .add_argument ("--KeyFrameDir" ,type = str ,default = "../KITTI-00 /KeyFrames" )
42- io_parser .add_argument ("--FrameIdFile" ,type = str ,default = "../KITTI-00 /FrameId.yml" )
43- io_parser .add_argument ("--MapFile" ,type = str ,default = "../KITTI-00 /Map.yml" )
41+ io_parser .add_argument ("--KeyFrameDir" ,type = str ,default = "../KITTI-05 /KeyFrames" )
42+ io_parser .add_argument ("--FrameIdFile" ,type = str ,default = "../KITTI-05 /FrameId.yml" )
43+ io_parser .add_argument ("--MapFile" ,type = str ,default = "../KITTI-05 /Map.yml" )
4444 io_parser .add_argument ("--KeyFrameIdKey" ,type = str ,default = "mnId" )
4545 io_parser .add_argument ("--FrameIdKey" ,type = str ,default = "mnFrameId" )
4646 io_parser .add_argument ("--KeyPointsKey" ,type = str ,default = "mvKeysUn" )
4747 io_parser .add_argument ("--MapPointKey" ,type = str ,default = "mvpMapPointsId" )
4848 io_parser .add_argument ("--CorrKey" ,type = str ,default = "mvpCorrKeyPointsId" )
49- io_parser .add_argument ("--index_i" ,type = int ,default = 75 )
50- io_parser .add_argument ("--index_j" ,type = int ,default = 79 )
49+ io_parser .add_argument ("--index_i" ,type = int ,default = 1039 )
50+ io_parser .add_argument ("--index_j" ,type = int ,default = 1040 )
5151 io_parser .add_argument ("--debug_log" ,type = str ,default = "" )
5252 io_parser .add_argument ("--Twc_file" ,type = str ,default = "../Twc.txt" )
5353 io_parser .add_argument ("--Twl_file" ,type = str ,default = "../Twl.txt" )
@@ -165,6 +165,7 @@ def gpr_approx(idx):
165165 tgt_pcd_arr = dataStruct .get_velo (tgt_file_index )[:,:3 ] # [N, 3]
166166 src_img = np .array (dataStruct .get_cam0 (src_file_index )) # [H, W, 3]
167167 tgt_img = np .array (dataStruct .get_cam0 (tgt_file_index )) # [H, W, 3]
168+ img_shape = src_img .shape [:2 ]
168169 src_pose = dataStruct .poses [src_file_index ]
169170 tgt_pose = dataStruct .poses [tgt_file_index ]
170171 camera_motion :np .ndarray = inv_pose (tgt_pose ) @ src_pose # Tc2w * Twc1
@@ -174,6 +175,20 @@ def gpr_approx(idx):
174175 src_pcd_camcoord = nptran (src_pcd_arr , extran )
175176 proj_src_pcd , src_rev = npproj (src_pcd_camcoord , np .eye (4 ), intran , src_img .shape )
176177 src_pcd_camcoord = src_pcd_camcoord [src_rev ]
178+ tgt_pcd_camcoord = nptran (src_pcd_camcoord , camera_motion )
179+ proj_tgt_pcd , tgt_rev = npproj (tgt_pcd_camcoord , np .eye (4 ), intran , tgt_img .shape )
180+ tgt_pcd_camcoord = tgt_pcd_camcoord [tgt_rev ]
181+ plt .figure (dpi = 200 )
182+ plt .subplot (2 ,1 ,1 )
183+ plt .title ("Frame {} - {}" .format (src_file_index + 1 , tgt_file_index + 1 ))
184+ plt .imshow (src_img ,cmap = "Greys_r" )
185+ plt .scatter (proj_src_pcd [:,0 ],proj_src_pcd [:,1 ],c = src_pcd_camcoord [:,- 1 ],cmap = 'rainbow_r' ,alpha = 0.8 ,s = 0.5 )
186+ plt .axis ([0 ,img_shape [1 ],img_shape [0 ],0 ])
187+ plt .subplot (2 ,1 ,2 )
188+ plt .imshow (tgt_img ,cmap = "Greys_r" )
189+ plt .scatter (proj_tgt_pcd [:,0 ],proj_tgt_pcd [:,1 ],c = tgt_pcd_camcoord [:,- 1 ],cmap = 'rainbow_r' ,alpha = 0.8 ,s = 0.5 )
190+ plt .axis ([0 ,img_shape [1 ],img_shape [0 ],0 ])
191+ plt .show ()
177192 src_2d_kdtree = cKDTree (proj_src_pcd , leafsize = 10 )
178193 if args .depth_conflict :
179194 src_dists , src_pcd_querys = src_2d_kdtree .query (src_matched_pts , args .max_2d_nn , eps = 1e-4 , p = 2 , workers = - 1 )
@@ -228,8 +243,10 @@ def gpr_approx(idx):
228243 plt .subplot (2 ,1 ,1 )
229244 plt .title ("Frame {} - {} | Matched:{} | error:{:0.4}" .format (src_file_index + 1 , tgt_file_index + 1 , tgt_matched_pts .shape [0 ],err ))
230245 plt .imshow (draw_src_img )
246+ plt .axis ([0 ,img_shape [1 ],img_shape [0 ],0 ])
231247 plt .subplot (2 ,1 ,2 )
232248 plt .imshow (draw_tgt_img )
249+ plt .axis ([0 ,img_shape [1 ],img_shape [0 ],0 ])
233250 plt .show ()
234251
235252
0 commit comments