当前位置:网站首页>3D detection: fast visualization of 3D box and point cloud
3D detection: fast visualization of 3D box and point cloud
2022-07-07 13:55:00 【Roast zongzi】
3D testing , be used for 3D box, Quick visualization of point cloud , auxiliary debug And analysis :
(Nuscenes,mmdet3d,OpenPCDet And so on )
Be careful : The code is applicable to a variety of models , But notice BEVDet Series and FCOS3D(front View) Choose different series box transformation .
3D box Projection to bev visualization :
import matplotlib.pyplot as plt
import torch
def box3d2x0y0wh(boxes_3d):
# BEVDet/CenterPoints
import numpy as np
n = boxes_3d.shape[0]
box2d = np.zeros((n,4))
# 3dbox --> xywh
box2d[:,:2] = boxes_3d[:,:2]
box2d[:,2] = boxes_3d[:,3]
box2d[:,3] = boxes_3d[:,4] # 2xywh
#
# xyxy = np.ones_like(box2d)
box2d[:,0] = box2d[:, 0] - box2d[:, 2] / 2
box2d[:,1] = box2d[:, 1] + box2d[:, 3] / 2 # NOTE: Lower left corner
return box2d
def box3d2x0y0wh_2(boxes_3d):
# FCOS3D: front view--> BEV
import numpy as np
n = boxes_3d.shape[0]
box2d = np.zeros((n,4))
# 3dbox --> xywh Lower left corner
box2d[:, 0] = boxes_3d[:, 0]
box2d[:, 1] = boxes_3d[:, 2]
box2d[:, 2] = boxes_3d[:, 4]
box2d[:, 3] = boxes_3d[:, 5] # 2xywh
#
# xyxy = np.ones_like(box2d)
box2d[:,0] = box2d[:, 0] - box2d[:, 2] / 2
box2d[:,1] = box2d[:, 1] + box2d[:, 3] / 2 # NOTE
return box2d
# Drawing according to coordinates
def draw_boxes(pred_boxes_3d, target_boxes_3d, path):
# pred_boxes xywh
import matplotlib.pyplot as plt
import matplotlib.patches as patches
pred_boxes = box3d2x0y0wh(pred_boxes_3d)
target_boxes = box3d2x0y0wh(target_boxes_3d)
fig, ax = plt.subplots()
ax.plot()
# ax.add_patch(patches.Rectangle((1, 1),0.5,0.5,edgecolor = 'blue',facecolor = 'red',fill=True) )
#
for index, coord in enumerate(pred_boxes):
rect = patches.Rectangle((coord[0], coord[1]), coord[2], coord[3],
linewidth=1, edgecolor='r',facecolor='none')
ax.add_patch(rect)
for index, coord in enumerate(target_boxes):
rect = patches.Rectangle((coord[0], coord[1]), coord[2], coord[3],
linewidth=1, edgecolor='g',facecolor='none')
ax.add_patch(rect)
# plt.legend(loc='best',edgecolor='g')
if os.path.exists(path):
os.remove(path)
fig.savefig(path, dpi=90, bbox_inches='tight')
# print(0)
plt.close(fig)
print('Successfully saved')
Quick visualization of point cloud :
def draw_pts(points, save_path, show=False):
''' points: [N,3+c] '''
assert len(points.shape) == 2
if isinstance(points, torch.Tensor):
points = points.cpu().numpy()
points = points.copy()
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# point_range = range(0, points.shape[0], skip) # skip points to prevent crash
point_range = range(0, points.shape[0])
ax.scatter(points[point_range, 0], # x
points[point_range, 1], # y
points[point_range, 2], # z
c=points[point_range, 2], # height data for color
cmap=plt.get_cmap("Spectral"),
marker="x")
ax.axis('auto') # {equal, scaled}
if show:
plt.show()
if save_path is not None:
fig.savefig(save_path, dpi=90, bbox_inches='tight')
plt.close(fig)
边栏推荐
- Solve the cache breakdown problem
- 得物客服热线的演进之路
- Xshell connection server changes key login to password login
- How far can it go to adopt a cow by selling the concept to the market?
- PHP中用下划线开头的变量含义
- mysql 局域网内访问不到的问题
- Shell batch file name (excluding extension) lowercase to uppercase
- 566. Reshaping the matrix
- Did login metamask
- Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
猜你喜欢
Getting started with cinnamon applet
室内ROS机器人导航调试记录(膨胀半径的选取经验)
Show the mathematical formula in El table
118. Yanghui triangle
TPG x AIDU | AI leading talent recruitment plan in progress!
Esp32 ① compilation environment
高等数学---第八章多元函数微分学1
Supply chain supply and demand estimation - [time series]
2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
带你掌握三层架构(建议收藏)
随机推荐
How to make join run faster?
Ogre introduction
Flink | 多流转换
move base参数解析及经验总结
Deep understanding of array related problems in C language
flask session伪造之hctf admin
Navicat run SQL file import data incomplete or import failed
手里的闲钱是炒股票还是买理财产品好?
"New red flag Cup" desktop application creativity competition 2022
2022-7-7 Leetcode 844.比较含退格的字符串
Redis can only cache? Too out!
使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
Xshell connection server changes key login to password login
Custom thread pool rejection policy
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
FCOS3D label assignment
2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out