Beispiel #1
0
if only_snippets:
    motor.cleanUp()
    print('finished creating snippets')
    exit()

multiple_classes = False
cls_ids = [f for f, _ in enumerate(classes)]
if multiple_classes == True:
    for i in range(images):
        snippets = []
        for k in classes:
            pathname = "snippets/" + k + "/"
            filename = random.choice(os.listdir(pathname))
            filepath = pathname + filename
            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: