Ejemplo n.º 1
0
 def perturb_frame(frame, params):
     dims = frame.image.get_hw()
     rand_affine = RandomPerturber.generate_random_affine(
         dims / 2, dims, params)
     perturbed_frame = Frame(frame.image_path, copy.deepcopy(frame.objects))
     perturbed_frame.image = rand_affine.apply_to_image(frame.image, dims)
     for i, obj in enumerate(frame.objects):
         perturbed_frame.objects[i].box = rand_affine.apply_to_box(obj.box)
     return perturbed_frame
Ejemplo n.º 2
0
 def perturb_frame(frame,params):
     dims = frame.image.get_hw()
     rand_affine = RandomPerturber.generate_random_affine(dims/2,dims,params)
     perturbed_frame = Frame(frame.image_path)
     perturbed_frame.image = rand_affine.apply_to_image(frame.image,dims)
     for i,obj in enumerate(frame.objects):
         # filter out completely out of bound objects
         perturbed_obj_box = rand_affine.apply_to_box(obj.box)
         perturbed_polygons = rand_affine.apply_to_polygons(obj.polygons)
         if Box.intersection(perturbed_obj_box,perturbed_frame.image.get_bounding_box()) is not None:
             obj_copy = copy.deepcopy(obj)
             obj_copy.box = perturbed_obj_box
             obj_copy.polygons = perturbed_polygons
             perturbed_frame.objects.append(obj_copy)
     return perturbed_frame
Ejemplo n.º 3
0
def apply_affine_to_frame(frame, affine, output_size):
    perturbed_frame = Frame(frame.image_path)
    perturbed_frame.image = affine.apply_to_image(frame.image, output_size)
    for i, obj in enumerate(frame.objects):
        # filter out completely out of bound objects
        perturbed_obj_box = affine.apply_to_box(obj.box)
        perturbed_polygons = affine.apply_to_polygons(obj.polygons)
        if Box.intersection(
                perturbed_obj_box,
                perturbed_frame.image.get_bounding_box()) is not None:
            obj_copy = copy.deepcopy(obj)
            obj_copy.box = perturbed_obj_box
            obj_copy.polygons = perturbed_polygons
            perturbed_frame.objects.append(obj_copy)
    return perturbed_frame