Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cv2/numpy
#1
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.

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
Reply


Messages In This Thread
cv2/numpy - by d8a988 - Apr-29-2020, 02:18 PM
RE: cv2/numpy - by astral_travel - Apr-29-2020, 03:23 PM
RE: cv2/numpy - by d8a988 - Apr-29-2020, 03:29 PM
RE: cv2/numpy - by astral_travel - Apr-29-2020, 03:33 PM
RE: cv2/numpy - by d8a988 - Apr-29-2020, 03:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 866 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,742 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 3,074 Apr-09-2019, 04:54 PM
Last Post: PhysChem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020