Skip to content

mouse coordinates seem to be off using version 4.5 or higher #860

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

Open
UniversalAl opened this issue Jun 26, 2023 · 3 comments
Open

mouse coordinates seem to be off using version 4.5 or higher #860

UniversalAl opened this issue Jun 26, 2023 · 3 comments

Comments

@UniversalAl
Copy link

Actual behaviour

opencv version 4.4.0 seams to be still ok, but somewhere for later versions mouse reading coordinates seems to be off, is that true? Not sure what version it starts but latest 4.6 or 4.7 for sure
It could be tested in code below. It is a 2x2 image, so with mouse increase the size of the window. It should print proper mouse coordinates while hoovering with mouse over image. But latest opencv versions show proper value only for top , left quadrant for a pixel

Steps to reproduce

import numpy as np
import cv2
print(f'OpenCV version {cv2.__version__}')

img = np.zeros((2,2,3), np.uint8)
img[0, 0] = (0, 0, 255)
img[1, 0] = (0, 255, 0)
img[0, 1] = (255, 0, 0)

def mouseAction(event,x,y,flags,param=None):
    print(x,y)
    
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.setWindowProperty('image',cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_NORMAL)
cv2.setMouseCallback('image', mouseAction)
cv2.imshow('image', img)
cv2.waitKey(0)
@UniversalAl UniversalAl changed the title wrong mouse coorinates introduced with 4.5 version or higher mouse coordinates seem to be off using version 4.5 or higher Jun 26, 2023
@asmorkalov
Copy link
Collaborator

@UniversalAl What is your platform? Could you add more details on your OpenCV configuration?

@UniversalAl
Copy link
Author

UniversalAl commented Jun 26, 2023

current working setup with no issue:
---Windows 10 (but using Windows 7 was same as well 4.4.0 ok, some latest opencv versions with an issue)
---Python 3.8.10 (but using Python 3.9 same as well, ok with 4.4.0 , latest opencv versions not ok, and for latest 3.11 gave an issue as well, with 3.11 there is a problem to get older opencv 4.4.0 to work because of numpy imcompatibility, not sure what it was )
---non issue opencv is 4.4.0 , could be installed now as: pip install opencv-python==4.4.0.46 (latest opencv version or 4.6 was already with that issue)
---numpy is currently 1.17.3 , what installed during 4.4.0.46 opencv pip installation or because of current older python version (3.8), not sure, but when I tested it with latest Python versions and higher opencv and numpy, there was still that coordinate issue

So basically if using a setup for latest python 3.11, latest opencv (4.7.x ? not sure now) and Windows 10 (using now) the issue would be present
Thanks

@UniversalAl
Copy link
Author

UniversalAl commented Jun 28, 2023

No one experiences wrong pixel coordinate readings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants