def get_rect_area_total(obj_list, window):
        if not obj_list:
            return 0.0

        area_total = 0
        box_list = get_box_list(obj_list)

        box_list_clip = np_box_list_ops.clip_to_window(box_list, window)
        box_list_norm = np_box_list_ops.change_coordinate_frame(
            box_list_clip, window)
        n_boxes = box_list_norm.num_boxes()

        index = [str(i) for i in range(n_boxes)]
        box_list_norm.add_field('index', np.asarray(index))
        box_list_norm_org = copy.deepcopy(box_list_norm)

        sign = 1
        while box_list_norm:
            area = np.sum(np_box_list_ops.area(box_list_norm))
            area_total += area * sign
            sign *= -1
            box_list_norm = np_box_list_ops.intersection_boxes(
                box_list_norm_org, box_list_norm)
        return area_total
예제 #2
0
 def test_area(self):
   areas = np_box_list_ops.area(self.boxlist1)
   expected_areas = np.array([6.0, 5.0], dtype=float)
   self.assertAllClose(expected_areas, areas)
예제 #3
0
 def test_area(self):
   areas = np_box_list_ops.area(self.boxlist1)
   expected_areas = np.array([6.0, 5.0], dtype=float)
   self.assertAllClose(expected_areas, areas)