from inference2 import *
if __name__ == '__main__':
cfg_file = "pointpillar.yaml"
#cfg_file = "pointrcnn.yaml"
#cfg_file = "second.yaml"
#cfg_file = "voxel_rcnn_car.yaml"
#cfg_file = "pv_rcnn.yaml"
data_path = "000000.bin"
#data_path = "000008.bin"
ckpt_path = "pointpillar_7728.pth"
#ckpt_path = "pointrcnn_7870.pth"
#ckpt_path = "second_7862.pth"
#ckpt_path = "voxel_rcnn_car_84.54.pth"
#ckpt_path = "pv_rcnn_8369.pth"
pred_dict, pcd = model_inference(cfg_file=cfg_file, data_path=data_path, ckpt_path=ckpt_path)
print(pred_dict['pred_scores'])
vis = open3d.visualization.Visualizer()
vis.create_window(window_name="kitti")
vis.get_render_option().point_size = 2.0
vis.get_render_option().background_color = np.zeros(3)
axis_pcd = open3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0, origin=[0, 0, 0])
vis.add_geometry(axis_pcd)
pts = open3d.geometry.PointCloud()
pts.points = open3d.utility.Vector3dVector(pcd)
pts.colors = open3d.utility.Vector3dVector(np.ones((len(pcd), 3)))
vis.add_geometry(pts)
box_color = [[0,1,0],[0,1,1],[1,1,0],[1,1,1]]
for i in range(len(pred_dict['pred_boxes'])):
if pred_dict['pred_scores'][i] > 0.5: # 0.5 이상만 바운딩 박스
print(pred_dict['pred_scores'][i]) # print로 결과 출력
center = pred_dict['pred_boxes'][i][0:3]
lwh = pred_dict['pred_boxes'][i][3:6]
axis_angles = np.array([0, 0, pred_dict['pred_boxes'][i][6]])
rot = open3d.geometry.get_rotation_matrix_from_axis_angle(axis_angles)
box3d = open3d.geometry.OrientedBoundingBox(center, rot, lwh)
box3d.color = box_color[pred_dict['pred_labels'][i]-1]
vis.add_geometry(box3d)
vis.run()
vis.destroy_window()