diff --git a/Matching shapes/matching_shapes.py b/Matching shapes/matching_shapes.py index b369443ebb..b8087723df 100644 --- a/Matching shapes/matching_shapes.py +++ b/Matching shapes/matching_shapes.py @@ -6,23 +6,24 @@ window.title("Matching shapes") window.geometry('350x200') -def image1(): # getting image 1 + +def image1(): # getting image 1 photo1 = askopenfilename() global gray1 img1 = cv2.imread(photo1) - img1 = cv2.resize(img1,(500,500)) + img1 = cv2.resize(img1, (500, 500)) gray1 = cv2.cvtColor(img1, cv2.COLOR_RGB2GRAY) - -def image2(): # getting image 2 + +def image2(): # getting image 2 photo2 = askopenfilename() global gray2 img2 = cv2.imread(photo2) - img2 = cv2.resize(img2,(500,500)) + img2 = cv2.resize(img2, (500, 500)) gray2 = cv2.cvtColor(img2, cv2.COLOR_RGB2GRAY) - -def proceeds(): # detecting shape matching using contours + +def proceeds(): # detecting shape matching using contours ret, threshold = cv2.threshold(gray1, 127, 255, 0) ret, threshold2 = cv2.threshold(gray2, 127, 255, 0) contours, hierarchy, rem1 = cv2.findContours(threshold, 2, 1) @@ -31,7 +32,9 @@ def proceeds(): # detecting shape matching using contours cnt2 = contours[0] ret = cv2.matchShapes(cnt1, cnt2, 1, 0.0) print(ret) - label = tk.Label(window, text="Probability of shapes matching: "+str(1-ret)).grid(row=4,column=1) + label = tk.Label(window, text="Probability of shapes matching: " + + str(1-ret)).grid(row=4, column=1) + label = tk.Label(window, text="Image 1").grid(row=1, column=0) label = tk.Label(window, text="Image 2").grid(row=2, column=0) @@ -40,9 +43,9 @@ def proceeds(): # detecting shape matching using contours b2 = tk.Button(window, text='choose image 2', command=image2) proceed = tk.Button(window, text='Proceed', command=proceeds) -b1.grid(row=1,column=1) -b2.grid(row=2,column=1) -proceed.grid(row=3,column=1) +b1.grid(row=1, column=1) +b2.grid(row=2, column=1) +proceed.grid(row=3, column=1) window.mainloop() cv2.destroyAllWindows()