def test_find_sudoku_sqare():
        pic_file_path = '../resource/example_pics/sample14.dataset.jpg'
        gray_pic_array = cv2.imread(pic_file_path, 0)
        color_pic_array  = cv2.imread(pic_file_path)
        gray_pic_array = cv2_helper.resize_with_fixed_height(gray_pic_array)
        color_pic_array = cv2_helper.resize_with_fixed_height(color_pic_array)
        # threshed_pic_array = cv2.adaptiveThreshold(gray_pic_array,WHITE,
        #     cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV, 19, 2)
        ''' I've tried 3,3 19,2, 5,5 9,2'''
        threshed_pic_array = cv2.adaptiveThreshold(gray_pic_array,WHITE,
            cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV, blockSize=5, C=2)
        # cv2_helper.show_pic(color_pic_array)
        cv2_helper.show_pic(threshed_pic_array)

        max_contour = find_sudoku_sqare(threshed_pic_array)
        cv2_helper.show_contours_in_pic(color_pic_array, [max_contour])
Exemple #2
0
 def main_test(image_path):
     color_image = cv2.imread(image_path)
     gray_image = cv2.imread(image_path, 0)
     color_image = cv2_helper.resize_with_fixed_height(color_image)
     gray_image = cv2_helper.resize_with_fixed_height(gray_image)
     show_all(color_image)
Exemple #3
0
    for index, name in enumerate(all_names):
        window_name = name[len(PERFORM_PREFIX) :]
        method = globals()[name]
        show_window(the_image, window_name, index, perform_func=method)

    control_name = filter(lambda name: name.startswith(CONTROL_NAME), globals())[0]
    show_window(the_image, control_name, len(all_names), perform_func=None, control_func=globals()[control_name])

    cv2.waitKey(0)
    cv2.destroyAllWindows()


def draw_text(the_image, the_text):
    cv2.putText(the_image, the_text, (20, 20), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 255, 0))


if __name__ == "__main__":
    from minitest import *

    image_path = "./original.jpg"
    # image_path = '../../../../picture_sudoku/resource/example_pics/sample02.dataset.jpg'
    color_image = cv2.imread(image_path)
    gray_image = cv2.imread(image_path, 0)
    color_image = cv2_helper.resize_with_fixed_height(color_image)
    gray_image = cv2_helper.resize_with_fixed_height(gray_image)

    with test("blurring"):
        # show_simple_blurring(color_image)
        show_all(color_image)
        pass