Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xinshuoweng committed Jul 10, 2019
1 parent 57849b2 commit 4009ba5
Show file tree
Hide file tree
Showing 90 changed files with 188,180 additions and 0 deletions.
4,849 changes: 4,849 additions & 0 deletions data/KITTI/3d_det_test/0000.txt

Large diffs are not rendered by default.

405 changes: 405 additions & 0 deletions data/KITTI/3d_det_test/0001.txt

Large diffs are not rendered by default.

1,202 changes: 1,202 additions & 0 deletions data/KITTI/3d_det_test/0002.txt

Large diffs are not rendered by default.

1,234 changes: 1,234 additions & 0 deletions data/KITTI/3d_det_test/0003.txt

Large diffs are not rendered by default.

1,065 changes: 1,065 additions & 0 deletions data/KITTI/3d_det_test/0004.txt

Large diffs are not rendered by default.

1,461 changes: 1,461 additions & 0 deletions data/KITTI/3d_det_test/0005.txt

Large diffs are not rendered by default.

282 changes: 282 additions & 0 deletions data/KITTI/3d_det_test/0006.txt

Large diffs are not rendered by default.

968 changes: 968 additions & 0 deletions data/KITTI/3d_det_test/0007.txt

Large diffs are not rendered by default.

1,286 changes: 1,286 additions & 0 deletions data/KITTI/3d_det_test/0008.txt

Large diffs are not rendered by default.

665 changes: 665 additions & 0 deletions data/KITTI/3d_det_test/0009.txt

Large diffs are not rendered by default.

4,086 changes: 4,086 additions & 0 deletions data/KITTI/3d_det_test/0010.txt

Large diffs are not rendered by default.

5,129 changes: 5,129 additions & 0 deletions data/KITTI/3d_det_test/0011.txt

Large diffs are not rendered by default.

5,640 changes: 5,640 additions & 0 deletions data/KITTI/3d_det_test/0012.txt

Large diffs are not rendered by default.

1,341 changes: 1,341 additions & 0 deletions data/KITTI/3d_det_test/0013.txt

Large diffs are not rendered by default.

6,575 changes: 6,575 additions & 0 deletions data/KITTI/3d_det_test/0014.txt

Large diffs are not rendered by default.

5,196 changes: 5,196 additions & 0 deletions data/KITTI/3d_det_test/0015.txt

Large diffs are not rendered by default.

3,034 changes: 3,034 additions & 0 deletions data/KITTI/3d_det_test/0016.txt

Large diffs are not rendered by default.

1,896 changes: 1,896 additions & 0 deletions data/KITTI/3d_det_test/0017.txt

Large diffs are not rendered by default.

1,396 changes: 1,396 additions & 0 deletions data/KITTI/3d_det_test/0018.txt

Large diffs are not rendered by default.

3,084 changes: 3,084 additions & 0 deletions data/KITTI/3d_det_test/0019.txt

Large diffs are not rendered by default.

6,678 changes: 6,678 additions & 0 deletions data/KITTI/3d_det_test/0020.txt

Large diffs are not rendered by default.

1,316 changes: 1,316 additions & 0 deletions data/KITTI/3d_det_test/0021.txt

Large diffs are not rendered by default.

3,122 changes: 3,122 additions & 0 deletions data/KITTI/3d_det_test/0022.txt

Large diffs are not rendered by default.

2,961 changes: 2,961 additions & 0 deletions data/KITTI/3d_det_test/0023.txt

Large diffs are not rendered by default.

2,150 changes: 2,150 additions & 0 deletions data/KITTI/3d_det_test/0024.txt

Large diffs are not rendered by default.

1,217 changes: 1,217 additions & 0 deletions data/KITTI/3d_det_test/0025.txt

Large diffs are not rendered by default.

723 changes: 723 additions & 0 deletions data/KITTI/3d_det_test/0026.txt

Large diffs are not rendered by default.

894 changes: 894 additions & 0 deletions data/KITTI/3d_det_test/0027.txt

Large diffs are not rendered by default.

1,085 changes: 1,085 additions & 0 deletions data/KITTI/3d_det_test/0028.txt

Large diffs are not rendered by default.

1,054 changes: 1,054 additions & 0 deletions data/KITTI/3d_det_val/0000.txt

Large diffs are not rendered by default.

4,418 changes: 4,418 additions & 0 deletions data/KITTI/3d_det_val/0001.txt

Large diffs are not rendered by default.

1,255 changes: 1,255 additions & 0 deletions data/KITTI/3d_det_val/0002.txt

Large diffs are not rendered by default.

715 changes: 715 additions & 0 deletions data/KITTI/3d_det_val/0003.txt

Large diffs are not rendered by default.

2,330 changes: 2,330 additions & 0 deletions data/KITTI/3d_det_val/0004.txt

Large diffs are not rendered by default.

1,659 changes: 1,659 additions & 0 deletions data/KITTI/3d_det_val/0005.txt

Large diffs are not rendered by default.

918 changes: 918 additions & 0 deletions data/KITTI/3d_det_val/0006.txt

Large diffs are not rendered by default.

4,219 changes: 4,219 additions & 0 deletions data/KITTI/3d_det_val/0007.txt

Large diffs are not rendered by default.

1,809 changes: 1,809 additions & 0 deletions data/KITTI/3d_det_val/0008.txt

Large diffs are not rendered by default.

4,782 changes: 4,782 additions & 0 deletions data/KITTI/3d_det_val/0009.txt

Large diffs are not rendered by default.

1,131 changes: 1,131 additions & 0 deletions data/KITTI/3d_det_val/0010.txt

Large diffs are not rendered by default.

3,814 changes: 3,814 additions & 0 deletions data/KITTI/3d_det_val/0011.txt

Large diffs are not rendered by default.

248 changes: 248 additions & 0 deletions data/KITTI/3d_det_val/0012.txt

Large diffs are not rendered by default.

1,147 changes: 1,147 additions & 0 deletions data/KITTI/3d_det_val/0013.txt

Large diffs are not rendered by default.

654 changes: 654 additions & 0 deletions data/KITTI/3d_det_val/0014.txt

Large diffs are not rendered by default.

1,738 changes: 1,738 additions & 0 deletions data/KITTI/3d_det_val/0015.txt

Large diffs are not rendered by default.

1,458 changes: 1,458 additions & 0 deletions data/KITTI/3d_det_val/0016.txt

Large diffs are not rendered by default.

296 changes: 296 additions & 0 deletions data/KITTI/3d_det_val/0017.txt

Large diffs are not rendered by default.

2,311 changes: 2,311 additions & 0 deletions data/KITTI/3d_det_val/0018.txt

Large diffs are not rendered by default.

4,699 changes: 4,699 additions & 0 deletions data/KITTI/3d_det_val/0019.txt

Large diffs are not rendered by default.

7,898 changes: 7,898 additions & 0 deletions data/KITTI/3d_det_val/0020.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions data/KITTI/test/calib/0000.txt
@@ -0,0 +1,7 @@
P0: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 0.000000000000e+00 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P1: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.875744000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P2: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 4.485728000000e+01 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.163791000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.745884000000e-03
P3: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.395242000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.199936000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.729905000000e-03
R0_rect: 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01
Tr_velo_to_cam: 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01
Tr_imu_to_velo: 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01
7 changes: 7 additions & 0 deletions data/KITTI/test/calib/0003.txt
@@ -0,0 +1,7 @@
P0: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 0.000000000000e+00 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P1: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.875744000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P2: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 4.485728000000e+01 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.163791000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.745884000000e-03
P3: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.395242000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.199936000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.729905000000e-03
R0_rect: 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01
Tr_velo_to_cam: 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01
Tr_imu_to_velo: 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01
Binary file added data/KITTI/test/image_02/0000/000010.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/KITTI/test/image_02/0000/000015.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/KITTI/test/image_02/0000/000020.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/KITTI/test/image_02/0003/000012.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/KITTI/test/image_02/0003/000017.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/KITTI/test/image_02/0003/000022.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
185 changes: 185 additions & 0 deletions evaluation/box_util.py
@@ -0,0 +1,185 @@
from scipy.spatial import ConvexHull
import numpy as np

def boxoverlap(a,b,criterion="union"):
"""
boxoverlap computes intersection over union for bbox a and b in KITTI format.
If the criterion is 'union', overlap = (a inter b) / a union b).
If the criterion is 'a', overlap = (a inter b) / a, where b should be a dontcare area.
"""

x1 = max(a.x1, b.x1)
y1 = max(a.y1, b.y1)
x2 = min(a.x2, b.x2)
y2 = min(a.y2, b.y2)

w = x2-x1
h = y2-y1

if w<=0. or h<=0.:
return 0.
inter = w*h
aarea = (a.x2-a.x1) * (a.y2-a.y1)
barea = (b.x2-b.x1) * (b.y2-b.y1)
# intersection over union overlap
if criterion.lower()=="union":
o = inter / float(aarea+barea-inter)
elif criterion.lower()=="a":
o = float(inter) / float(aarea)
else:
raise TypeError("Unkown type for criterion")
return o


def polygon_clip(subjectPolygon, clipPolygon):
""" Clip a polygon with another polygon.
Ref: https://rosettacode.org/wiki/Sutherland-Hodgman_polygon_clipping#Python
Args:
subjectPolygon: a list of (x,y) 2d points, any polygon.
clipPolygon: a list of (x,y) 2d points, has to be *convex*
Note:
**points have to be counter-clockwise ordered**
Return:
a list of (x,y) vertex point for the intersection polygon.
"""
def inside(p):
return(cp2[0]-cp1[0])*(p[1]-cp1[1]) > (cp2[1]-cp1[1])*(p[0]-cp1[0])

def computeIntersection():
dc = [ cp1[0] - cp2[0], cp1[1] - cp2[1] ]
dp = [ s[0] - e[0], s[1] - e[1] ]
n1 = cp1[0] * cp2[1] - cp1[1] * cp2[0]
n2 = s[0] * e[1] - s[1] * e[0]
n3 = 1.0 / (dc[0] * dp[1] - dc[1] * dp[0])
return [(n1*dp[0] - n2*dc[0]) * n3, (n1*dp[1] - n2*dc[1]) * n3]

outputList = subjectPolygon
cp1 = clipPolygon[-1]

for clipVertex in clipPolygon:
cp2 = clipVertex
inputList = outputList
outputList = []
s = inputList[-1]

for subjectVertex in inputList:
e = subjectVertex
if inside(e):
if not inside(s):
outputList.append(computeIntersection())
outputList.append(e)
elif inside(s):
outputList.append(computeIntersection())
s = e
cp1 = cp2
if len(outputList) == 0:
return None
return(outputList)


def poly_area(x,y):
""" Ref: http://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates """
return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1)))

def convex_hull_intersection(p1, p2):
""" Compute area of two convex hull's intersection area.
p1,p2 are a list of (x,y) tuples of hull vertices.
return a list of (x,y) for the intersection and its volume
"""
inter_p = polygon_clip(p1,p2)
if inter_p is not None:
hull_inter = ConvexHull(inter_p)
return inter_p, hull_inter.volume
else:
return None, 0.0

def box3d_vol(corners):
''' corners: (8,3) no assumption on axis direction '''
a = np.sqrt(np.sum((corners[0,:] - corners[1,:])**2))
b = np.sqrt(np.sum((corners[1,:] - corners[2,:])**2))
c = np.sqrt(np.sum((corners[0,:] - corners[4,:])**2))
return a*b*c

def box3d_iou(corners1, corners2, criterion='union'):
''' Compute 3D bounding box IoU.
Input:
corners1: numpy array (8,3), assume up direction is negative Y
corners2: numpy array (8,3), assume up direction is negative Y
Output:
iou: 3D bounding box IoU
iou_2d: bird's eye view 2D bounding box IoU
todo (rqi): add more description on corner points' orders.
'''
# corner points are in counter clockwise order
rect1 = [(corners1[i,0], corners1[i,2]) for i in range(3,-1,-1)]
rect2 = [(corners2[i,0], corners2[i,2]) for i in range(3,-1,-1)]
area1 = poly_area(np.array(rect1)[:,0], np.array(rect1)[:,1])
area2 = poly_area(np.array(rect2)[:,0], np.array(rect2)[:,1])
inter, inter_area = convex_hull_intersection(rect1, rect2)

ymax = min(corners1[0,1], corners2[0,1])
ymin = max(corners1[4,1], corners2[4,1])
inter_vol = inter_area * max(0.0, ymax-ymin)
vol1 = box3d_vol(corners1)
vol2 = box3d_vol(corners2)
if criterion.lower() == 'union':
iou = inter_vol / (vol1 + vol2 - inter_vol)
iou_2d = inter_area/(area1+area2-inter_area)
elif criterion.lower() == 'a':
iou = inter_vol / vol1
iou_2d = inter_area / area1
else:
raise TypeError("Unkown type for criterion")
return iou, iou_2d

def roty(t):
''' Rotation about the y-axis. '''
c = np.cos(t)
s = np.sin(t)
return np.array([[c, 0, s],
[0, 1, 0],
[-s, 0, c]])

def compute_box_3d(obj):
''' Takes an object and a projection matrix (P) and projects the 3d
bounding box into the image plane.
Returns:
corners_2d: (8,2) array in left image coord.
corners_3d: (8,3) array in in rect camera coord.
'''
# compute rotational matrix around yaw axis
R = roty(obj.yaw)

# 3d bounding box dimensions
l = obj.l
w = obj.w
h = obj.h

# 3d bounding box corners
x_corners = [l/2,l/2,-l/2,-l/2,l/2,l/2,-l/2,-l/2];
y_corners = [0,0,0,0,-h,-h,-h,-h];
z_corners = [w/2,-w/2,-w/2,w/2,w/2,-w/2,-w/2,w/2];

# rotate and translate 3d bounding box
corners_3d = np.dot(R, np.vstack([x_corners,y_corners,z_corners]))
#print corners_3d.shape
corners_3d[0,:] = corners_3d[0,:] + obj.X
corners_3d[1,:] = corners_3d[1,:] + obj.Y
corners_3d[2,:] = corners_3d[2,:] + obj.Z
# print('cornsers_3d: ', corners_3d)

return np.transpose(corners_3d)

def box3doverlap(aa, bb, criterion='union'):
aa_3d = compute_box_3d(aa)
bb_3d = compute_box_3d(bb)

iou3d, iou2d = box3d_iou(aa_3d, bb_3d, criterion=criterion)
# print(iou3d)
# print(iou2d)
return iou3d

0 comments on commit 4009ba5

Please sign in to comment.