Exemplo n.º 1
0
import cv2 as cv
import numpy as np
import pause

#My fucntions
import my_functions


directory=r'D:\learning\Semesters\Semester 8\Image_Processing\Project\Chess_board_sampels'
imges= my_functions.load_images_from_source(directory,2)


for i in range(len(imges)):

    print("Chess_image_"+str(i+1))

    org =my_functions.resize_image(imges[i],10)
    org_2 = org
    img=cv.cvtColor(org,cv.COLOR_BGR2GRAY)
    my_functions.open_in_location(img,"Chess_image_"+str(i+1),-1347,-165)

    canny= cv.Canny(img, 80, 150)
    #canny_2=canny
    blur = cv.GaussianBlur(img, (5, 5), 3)
    my_functions.open_in_location(blur,'Gaussian Blur '+str(i+1),-905,-165)


    thrsh = cv.adaptiveThreshold(blur, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY , 11,2)
    #_, img = cv.threshold(img, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
    contours, hierarchy = cv.findContours(thrsh, mode = cv.RETR_TREE, method = cv.CHAIN_APPROX_NONE)
Exemplo n.º 2
0
import cv2 as cv
import numpy as np
# My fucntions
import my_functions

THRESHOLDING_window = 11
number_of_images_in_source = 5
source = r'D:\learning\Semesters\Semester 8\Image_Processing\Project\Chess_board_sampels_2'
directory = r'D:\learning\Semesters\Semester 8\Image_Processing\Project\all_cropped'
frame_BGR_original = my_functions.load_images_from_source(
    source, number_of_images_in_source - 1)

for c in range(number_of_images_in_source):

    frame_BGR_resized = my_functions.resize_image(frame_BGR_original[c], 10)

    frame_GRAY = cv.cvtColor(frame_BGR_resized, cv.COLOR_BGR2GRAY)
    frame_GRAY_blured = cv.GaussianBlur(frame_GRAY, (5, 5), 0)
    frame_THRESHOLDED = cv.adaptiveThreshold(frame_GRAY_blured, 255,
                                             cv.ADAPTIVE_THRESH_GAUSSIAN_C,
                                             cv.THRESH_BINARY_INV,
                                             THRESHOLDING_window, 2)

    contours, hierarchy = cv.findContours(frame_THRESHOLDED,
                                          mode=cv.RETR_TREE,
                                          method=cv.CHAIN_APPROX_NONE)

    largest_contour_index = my_functions.get_contour_max_area(contours)[0]

    # only print if interested
    # print(largest_contour_index)
Exemplo n.º 3
0
import cv2 as cv
import numpy as np

# My fucntions
import my_functions

source = r'D:\learning\Semesters\Semester 8\Image_Processing\Project\Chess_board_sampels_2'
directory = r'D:\learning\Semesters\Semester 8\Image_Processing\Project\all_cropped'
c = 0
frame_BGR_original = my_functions.load_images_from_source(source, 3)
while 1:

    frame_BGR_resized = my_functions.resize_image(frame_BGR_original[c], 10)

    cv.imshow("blur", frame_BGR_resized)
    cv.waitKey()
    cv.destroyAllWindows()

    frame_GRAY = cv.cvtColor(frame_BGR_resized, cv.COLOR_BGR2GRAY)
    frame_GRAY_blured = cv.GaussianBlur(frame_GRAY, (5, 5), 0)
    th = cv.adaptiveThreshold(frame_GRAY_blured, 255,
                              cv.ADAPTIVE_THRESH_GAUSSIAN_C,
                              cv.THRESH_BINARY_INV, 11, 2)

    GRAY_corners = cv.goodFeaturesToTrack(frame_GRAY, 100, 0.4, 5)
    corners_array = np.int0(GRAY_corners)

    #Display the corners found int he image

    for i in corners_array:
        x, y = i.ravel()