Apr-29-2020, 02:18 PM
I am trying to obtain x,y coordinates by clicking on a graph in png format.
The following code works properly but it looks like that
x and y have a strange range, for instance y decreases its value the further you go up.
What exactly should I implement in the following code in order to pre-establish
the x and y range?
I have tried with numpy, but it does not work.
The following code works properly but it looks like that
x and y have a strange range, for instance y decreases its value the further you go up.
What exactly should I implement in the following code in order to pre-establish
the x and y range?
I have tried with numpy, but it does not work.
import cv2 import numpy as np def click_event(event, x, y, flags, param): #x=np.linspace(0,10,1) when enabled they #y=np.linspace(0,5,1) just print [0.] [0.] for every mouse click if event == cv2.EVENT_LBUTTONDOWN: print (x, y) file_name= (r"\Users\Desktop\pic.png") img = cv2.imread(file_name) print(img.shape) cv2.imshow('original', img) cv2.setMouseCallback("original", click_event) cv2.waitKey(0) cv2.destroyAllWindows