From f9947f7a5acc961d24a1d86c694814f219341ebb Mon Sep 17 00:00:00 2001 From: sayampradhan <112542130+sayampradhan@users.noreply.github.com> Date: Fri, 14 Oct 2022 23:34:12 +0530 Subject: [PATCH] Format Code --- Basics/Detecting_Clicks_On_Images.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Basics/Detecting_Clicks_On_Images.py b/Basics/Detecting_Clicks_On_Images.py index 6948c3d..7579b5f 100644 --- a/Basics/Detecting_Clicks_On_Images.py +++ b/Basics/Detecting_Clicks_On_Images.py @@ -16,34 +16,32 @@ import cv2 import numpy as np -circles = np.zeros((4,2),np.int) +circles = np.zeros((4, 2), np.int) counter = 0 -def mousePoints(event,x,y,flags,params): + +def mousePoints(event, x, y, flags, params): global counter if event == cv2.EVENT_LBUTTONDOWN: - circles[counter] = x,y + circles[counter] = x, y counter = counter + 1 print(circles) - -img = cv2.imread('Resources/cards.jpg') +img = cv2.imread("Resources/cards.jpg") while True: - if counter == 4: - width, height = 250,350 - pts1 = np.float32([circles[0],circles[1],circles[2],circles[3]]) - pts2 = np.float32([[0,0],[width,0],[0,height],[width,height]]) - matrix = cv2.getPerspectiveTransform(pts1,pts2) - imgOutput = cv2.warpPerspective(img,matrix,(width,height)) + width, height = 250, 350 + pts1 = np.float32([circles[0], circles[1], circles[2], circles[3]]) + pts2 = np.float32([[0, 0], [width, 0], [0, height], [width, height]]) + matrix = cv2.getPerspectiveTransform(pts1, pts2) + imgOutput = cv2.warpPerspective(img, matrix, (width, height)) cv2.imshow("Output Image ", imgOutput) - - for x in range (0,4): - cv2.circle(img,(circles[x][0],circles[x][1]),3,(0,255,0),cv2.FILLED) + for x in range(0, 4): + cv2.circle(img, (circles[x][0], circles[x][1]), 3, (0, 255, 0), cv2.FILLED) cv2.imshow("Original Image ", img) cv2.setMouseCallback("Original Image ", mousePoints)