Skip to content

format code with autopep8 #2958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions Matching shapes/matching_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()