Example #1
0
def start():
    filename = filedialog.askopenfilename()
    img = cv2.imread(filename)
    img = ImageProcessing.gray(img)
    img = ImageProcessing.get_text_crop(img)
    img = numpy.asarray(img)

    img = ImageProcessing.blur(img)
    img = ImageProcessing.adaptive_thresholding(img)
    PIL.Image.fromarray(img).save("images\\3_.jpg")
    img_thr = ImageProcessing.global_thresholding(img)
    PIL.Image.fromarray(img_thr).save('images\\2_.jpg')
    img_thr = PIL.Image.fromarray(img_thr)
    ImageProcessing.print_text(img_thr)
Example #2
0
        u_v = cv2.getTrackbarPos('U - v', 'panel')
        start = cv2.getTrackbarPos(switch, 'panel')
        bool_motor = cv2.getTrackbarPos(string_motor, 'panel')

        lower_green = np.array([l_h, l_s, l_v])
        upper_green = np.array([u_h, u_s, u_v])
        # for live preview
        cv2.imshow('panel', panel)
        key = cv2.waitKey(20)
        # cut out background
        img_deleted_background, mask = image_processor.remove_background_youtube(
            img_raw, lower_green, upper_green)
        cv2.imshow('bckgrndsgmnttn', img_deleted_background)

        mask = cv2.blur(mask, (3, 3))
        img_gray = image_processor.gray(img_raw)
        # For possible future purposes
        mask_canny_edge = image_processor.canny(mask)
        img_canny_edge = image_processor.auto_canny(img_gray)
        mask_weight = 1.0
        combined_canny_edge = image_processor.combine_edges(
            mask_canny_edge, mask_weight, img_canny_edge, (1 - mask_weight))

        object_contour = image_processor.max_contour(combined_canny_edge)
        if key == ord('q'):
            cv2.destroyAllWindows()
            motor.cleanUp()
            quit()
        try:
            bounding_box = image_processor.bounding_box(object_contour)
        except:
Example #3
0
from image_capture import ImageCapture
from image_processing import ImageProcessing
import cv2
import numpy as np

camera = ImageCapture()
#camera = cv2.VideoCapture(0)
processor = ImageProcessing()

while True:
    img_raw = camera.capture()
    img_cut = img_raw[:,
                      int(np.shape(img_raw)[1] * 1 /
                          5):int(np.shape(img_raw)[1] * 4 / 5), :]
    img_gray = processor.gray(img_cut)
    edge = processor.canny(img_gray)
    contour = processor.max_contour(edge)
    cv2.drawContours(img_cut, contour, -1, (0, 255, 0), 3)
    bounding_box = processor.bounding_box(contour)
    print(bounding_box)
    #if bounding_box != -1:
    #    print("success!")
    #else:
    #    print("failure!")
    cv2.imshow('raw_image', img_raw)
    cv2.imshow('cut_image', img_cut)
    cv2.imshow('gray_image', img_gray)
    cv2.imshow('canny_image', edge)
    cv2.waitKey(20)