geometry.py
Go to the documentation of this file.
1 def get_overlap_of_aabb(box1, box2, return_volumes=False):
2  x11, y11, z11, x12, y12, z12 = box1
3  dim_x1 = x12 - x11
4  dim_y1 = y12 - y11
5  dim_z1 = z12 - z11
6 
7  x21, y21, z21, x22, y22, z22 = box2
8  dim_x2 = x22 - x21
9  dim_y2 = y22 - y21
10  dim_z2 = z22 - z21
11 
12  if ((x11 <= x22 and x12 >= x21) and
13  (y11 <= y22 and y12 >= y21) and
14  (z11 <= z22 and z12 >= z21)):
15  # has intersect
16  dim_x3 = min(x12, x22) - max(x11, x21)
17  dim_y3 = min(y12, y22) - max(y11, y21)
18  dim_z3 = min(z12, z22) - max(z11, z21)
19  else:
20  dim_x3 = dim_y3 = dim_z3 = 0
21 
22  intersect = dim_x3 * dim_y3 * dim_z3
23  union = (dim_x1 * dim_y1 * dim_z1) + (dim_x2 * dim_y2 * dim_z2) - intersect
24  iu = 1. * intersect / union
25  if return_volumes:
26  return iu, intersect, union
27  else:
28  return iu
def get_overlap_of_aabb(box1, box2, return_volumes=False)
Definition: geometry.py:1


jsk_recognition_utils
Author(s):
autogenerated on Mon May 3 2021 03:03:03