当前位置:网站首页>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)
边栏推荐
- 2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
- Build a secure and trusted computing platform based on Kunpeng's native security
- Custom thread pool rejection policy
- THINKPHP框架的优秀开源系统推荐
- Laravel Form-builder使用
- Excellent open source system recommendation of ThinkPHP framework
- MySQL error 28 and solution
- 搜索框效果的实现【每日一题】
- My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
- Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
猜你喜欢

2022-7-7 Leetcode 844. Compare strings with backspace

社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生

如何让join跑得更快?

Evolution of customer service hotline of dewu

Help tenants

Show the mathematical formula in El table

The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)

"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?

118. 杨辉三角

Navicat运行sql文件导入数据不全或导入失败
随机推荐
[high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
648. Word replacement: the classic application of dictionary tree
请问指南针股票软件可靠吗?交易股票安全吗?
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
2022-7-6 Leetcode 977. Square of ordered array
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
Oracle advanced (V) schema solution
High end for 8 years, how is Yadi now?
Flask session forged hctf admin
为租客提供帮助
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
PHP - laravel cache
Split screen bug notes
3D Detection: 3D Box和点云 快速可视化
【堡垒机】云堡垒机和普通堡垒机的区别是什么?
室内ROS机器人导航调试记录(膨胀半径的选取经验)
How far can it go to adopt a cow by selling the concept to the market?
mysql 局域网内访问不到的问题
Toraw and markraw