Skip to content

fix for #4990: correct calculation of image coordinates from window coordinates - #13453

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
crackwitz:w32-opengl-mouse-position
Dec 26, 2018
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
crackwitz:w32-opengl-mouse-position

Conversation

@crackwitz

Copy link
Copy Markdown
Contributor

resolves #4990

This pullrequest changes

in HighGUIProc case WM_MOUSEMOVE as well as in MainWindowProc case WM_MOUSEWHEEL, window coordinates are turned into image coordinates. Unfortunately, the size of the image is stored nowhere explicitly and generally. It is determined by querying (icvGetBitmapData) the GDI bitmap object associated with the window. In the standard GDI case, that's the original image.

In the OpenGL case, that is instead the whole window (including chrome). The actual image is only stored in window->glDrawData, which is a pointer to cv::ogl::Texture2D and to be used by the drawing callback to OpenGL.

I've added code to determine image size according to situation.

@mshabunin mshabunin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase this PR to the 3.4 branch.

SIZE size = {0,0};
icvGetBitmapData( window, &size, 0, 0 );
#ifdef HAVE_OPENGL
if (window->useGl)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving this if-block into icvGetBitmapData?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not my call either way. I chose not to because I don't fully comprehend the naming convention of icvGetBitmapData and related functions and they seem to not deal with OpenGL at all.

I would suggest not querying whatever bitmap is stored for whatever mode, but storing the size in window explicitly when bitmap data is set. then, none of these case distinctions have to be made.

@crackwitz crackwitz closed this Dec 25, 2018
@crackwitz
crackwitz deleted the w32-opengl-mouse-position branch December 25, 2018 17:02
@crackwitz
crackwitz restored the w32-opengl-mouse-position branch December 25, 2018 17:07
@alalek

alalek commented Dec 25, 2018

Copy link
Copy Markdown
Member

This patch should go into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

So, please:

  • (done) change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR or delete branch, apply changes "inplace".

@mshabunin
mshabunin force-pushed the w32-opengl-mouse-position branch from 2aeb733 to deb8ba2 Compare December 26, 2018 12:01

@mshabunin mshabunin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's postpone refactoring for now, the whole class should be separated into two.

@opencv-pushbot
opencv-pushbot merged commit deb8ba2 into opencv:3.4 Dec 26, 2018
@crackwitz
crackwitz deleted the w32-opengl-mouse-position branch December 27, 2018 00:43
@alalek alalek mentioned this pull request Dec 27, 2018
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants