3d 目標檢測 判斷點雲是否在bbox中

2021-10-07 08:37:44 字數 4097 閱讀 1260

有時候需要判斷某些點是否在點雲的凸包內,例如3d object detection 中找到了bbox,判斷場景中的點雲哪些在這個bbox中,這裡以2d點為例:

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.collections import polycollection, linecollection

from scipy.spatial import delaunay

lidar_file =

"/home/seivl/pcdet/data/kitti/training/velodyne/000000.bin"

pts = np.fromfile(lidar_file, dtype=np.float32)

.reshape(-1

,4)print

(pts)

print

(pts.shape)

defin_hull

(p, hull)

:"""

test if points in `p` are in `hull`

`p` should be a `nxk` coordinates of `n` points in `k` dimensions

`hull` is either a scipy.spatial.delaunay object or the `mxk` array of the

coordinates of `m` points in `k`dimensions for which delaunay triangulation

will be computed

"""from scipy.spatial import delaunay

ifnotisinstance

(hull,delaunay)

: hull = delaunay(hull)

return hull.find_******x(p)

>=

0, hull.find_******x(p)

<

0def

plot_in_hull

(p, hull)

:"""

plot relative to `in_hull` for 2d data

"""ifnot

isinstance

(hull,delaunay)

: hull = delaunay(hull)

# plot triangulation

poly = polycollection(hull.points[hull.vertices]

, facecolors=

'w', edgecolors=

'b')

plt.clf(

) plt.title(

'in hull'

) plt.gca(

).add_collection(poly)

# plt.plot(hull.points[:,0], hull.points[:,1], 'o', hold=1)

plt.plot(hull.points[:,

0], hull.points[:,

1],'o'

)# plot the convex hull

edges =

set(

) edge_points =

defadd_edge

(i, j)

:"""add a line between the i-th and j-th points, if not in the list already"""

if(i, j)

in edges or

(j, i)

in edges:

# already added

return

edges.add(

(i, j)

)[i, j]])

for ia, ib in hull.convex_hull:

add_edge(ia, ib)

lines = linecollection(edge_points, color=

'g')

plt.gca(

).add_collection(lines)

plt.show(

)# plot tested points `p` - black are inside hull, red outside

inside, out = in_hull(p,hull)

plt.plot(p[inside,0]

,p[inside,1]

,'.k'

) plt.plot(p[out,0]

,p[out,1]

,'.r'

)# plt.plot(p[-inside,0],p[-inside,1],'.r')

plt.show(

)if __name__ ==

'__main__'

: p1 = pts[

2000,0

:2] p2 = pts[

12782,0

:2] p3 = pts[

48772,0

:2] p4 = pts[

38217,0

:2] p_in = np.vstack(

(p1, p2, p3, p4)

) plot_in_hull(pts[:,

0:2]

, p_in)

# 方法 2

3D目標檢測之AM3D

accurate monocular object detection via color embedded 3d reconstructionfor autonomous driving 參考戳這裡 先用2d目標檢測網路和單目深度估計網路分別檢測2d box和深度資訊,然後將深度資訊轉化為三維點雲...

單目3D目標檢測調研

現有的單目3d目標檢測方案主要方案主要分為兩類,分別為基於的方法和基於偽雷達點雲的方法。基於的方法一般通過2d 3d之間的幾何約束來學習,包括目標形狀資訊,地面資訊,以及關鍵點等等,通過這些資訊在損失函式中約束3d檢測學習得更好。基於偽雷達點雲的方法首先從2d中估計出單目深度資訊來,然後利用單目深度...

3D點雲目標的識別與抓取

這是2016年乙個點雲目標識別研究的簡單描述。點雲目標識別,顧名思義,需要有標準的目標點雲或者標準的點雲特徵描述向量 對實時採集的點雲資料,在裡面尋找與目標點雲相似度最高的點雲塊。圖2.1 點雲在xy平面的投影圖像 圖2.2 圓環點雲採集影象 常用點雲濾波有帶通濾波 統計濾波 半徑濾波 去除背景平面...