Beispiel #1
0
def original_demo(image):
    orig = image.copy()

    # <---- RESIZING -----> #
    image, ratio = functions.standard_resize(image, new_width=100.0)
    # <---- RESIZING -----> #

    processed = functions.colorOps(image)
    points = functions.contour_method(processed)
    detection = cv2.drawContours(image.copy(), [points], -1, (0, 255, 0), 2)
    final = functions.finalize(orig, points, ratio)

    images = [orig, detection, final]
    functions.plot_images(images)
Beispiel #2
0
def text_region_method2(image):
    orig = image.copy()

    edged = functions.text_edging(orig.copy())
    kernel = np.ones((9, 9), np.uint8)  # original 9x9
    dilated = cv2.dilate(
        edged, kernel,
        iterations=7)  # original was 5 iterations. This works a little better?

    points = functions.minRectMethod(dilated)
    detection = cv2.drawContours(image.copy(), [points], -1, (0, 255, 0), 2)
    final = functions.finalize(orig.copy(), points)
    functions.plot_images(
        [orig, edged, dilated, detection, final],
        ["Original", "Edged", "Dilated", "Detection", "Final"])
Beispiel #3
0
def occlusion_demo(image):
    orig = image.copy()

    # <---- RESIZING -----> #
    image, ratio = functions.standard_resize(image, new_width=100.0)
    # <---- RESIZING -----> #

    edged = functions.colorOps(image)
    processed = functions.closed_inversion(edged)
    points = functions.minRectMethod(processed)
    imutils.negative_coords(points, processed.shape[1], processed.shape[0])
    # points = functions.minRectMethod(edged)
    detection = cv2.drawContours(image.copy(), [points], -1, (0, 255, 0), 2)
    final = functions.finalize(orig.copy(), points, ratio)

    # cv2.imwrite('processed/final.jpg', final)
    functions.plot_images([orig, edged, processed, detection, final], [
        "Original", "Edge Detection", "Morpohological Operations",
        "Contour Finding", "Perspective Transform"
    ])