opencv / opencv/opencv-python

mouse coordinates seem to be off using version 4.5 or higher

Open
#860 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.4k
Forks
1k
Avg merge
22h 17m
Merged PRs (30d)
3

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied Python reproducer and compare its mouse coordinates under OpenCV 4.4.0 and the later versions named in the issue. Trace whether the mismatch belongs to the Python package or the underlying window and mouse-callback behavior; done means a confirmed version boundary, expected coordinates, and a reproducible diagnosis.

Written by the indexing model from the issue text.

Assessment

Tech stack
opencv, python
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.