geometry.py
Go to the documentation of this file.
00001 def get_overlap_of_aabb(box1, box2, return_volumes=False):
00002     x11, y11, z11, x12, y12, z12 = box1
00003     dim_x1 = x12 - x11
00004     dim_y1 = y12 - y11
00005     dim_z1 = z12 - z11
00006 
00007     x21, y21, z21, x22, y22, z22 = box2
00008     dim_x2 = x22 - x21
00009     dim_y2 = y22 - y21
00010     dim_z2 = z22 - z21
00011 
00012     if ((x11 <= x22 and x12 >= x21) and
00013             (y11 <= y22 and y12 >= y21) and
00014             (z11 <= z22 and z12 >= z21)):
00015         # has intersect
00016         dim_x3 = min(x12, x22) - max(x11, x21)
00017         dim_y3 = min(y12, y22) - max(y11, y21)
00018         dim_z3 = min(z12, z22) - max(z11, z21)
00019     else:
00020         dim_x3 = dim_y3 = dim_z3 = 0
00021 
00022     intersect = dim_x3 * dim_y3 * dim_z3
00023     union = (dim_x1 * dim_y1 * dim_z1) + (dim_x2 * dim_y2 * dim_z2) - intersect
00024     iu = 1. * intersect / union
00025     if return_volumes:
00026         return iu, intersect, union
00027     else:
00028         return iu


jsk_recognition_utils
Author(s):
autogenerated on Tue Jul 2 2019 19:40:37