Beispiel #1
0
            snippets.append(cv2.imread(filepath))
        final, bounding_box_array = image_processor.multiple_OTL_on_background(
            snippets, cls_ids, occlusion=False)
        if final is 0 and 0 in bounding_box_array:
            print("Error in OTL_on_background")
            i = i - steps
            continue
        save_to_files(bounding_box_array, final)
else:
    for label in classes:
        for i in range(images):
            pathname = "snippets/" + label + "/"
            filename = random.choice(os.listdir(pathname))
            filepath = pathname + filename
            OTL_cut_out = cv2.imread(filepath)
            final, bounding_box = image_processor.OTL_on_background(
                OTL_cut_out)
            if final is 0 and 0 in bounding_box:
                print("Error in OTL_on_background")
                i = i - steps
                continue
            save_to_files(bounding_box, final)

        # 5 different transformations
        # 0...overlay with some image (transparent overlay)
        # 1...delete and replace the background
        # 2...occlude the object by a more or less random percentage
        # 3...move the object to another (random) position in the image
        # 4...insert another known object into the image and provide the bounding box of that
        #
        # parameters: ("which transformation", "bounding box", "raw image", "folder for overlay/background images")
        #bounding_box_additional_object, img_processed = image_processor.transformation()