Beispiel #1
0
        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:
            continue
        cv2.drawContours(img_raw, object_contour, -1, (0, 255, 0), 3)
        #print(bounding_box)
        cv2.rectangle(img_raw, bounding_box[0], bounding_box[1], (0, 255, 0),
                      2)
        # display stuff