Ask Your Question
0

How to get position of the mouse in large images

asked 2013-04-09 10:33:00 -0600

Vuong Bui gravatar image

updated 2013-04-11 11:40:08 -0600

When I click my mouse on large images, position of the mouse pointer that is returned is wrong. How do I get the correct position when I clicked mouse on large image? I don't prefer to use cv_window_keepratio* to adjust the window.

Update

My images is 1600 x 1000, my screen is 1366 x 768

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-04-09 12:10:16 -0600

Basically, the namedWindows generated by openCV only work well within the ranges of your screen resolution. Many topics mention that coördinates go wrong when going over that range.

Look at : http://answers.opencv.org/question/9284/drawing-limited-by-size-of-int-in-opencv/

Simple solution is like I already suggested in the suggested topic, using region of interest and looping over your large images in specific windows. It is the only OpenCV way to get 100% correct coördinates inside larger images. I am using it for 25000 x 25000 pixels and it works perfectly.

Mat window = inputImage( Rect( x, y, width, heigth) );

Basically the problem is the way the functionality is written. I do not feel like updating the source code, but just using this simple roi approach, since displaying images larger than your screen is basically useless.

edit flag offensive delete link more

Comments

Looking at your ratio comment, I would suggest splitting your image into 4 containers and loop over them. Please try this and tell us if it helped.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-11 11:41:39 -0600 )edit
1

+1 cause of "coördinates" :p

Guanta gravatar imageGuanta ( 2013-04-11 13:13:27 -0600 )edit

It can't. My images is 1600 x 1000. My screen is 1366 x 768

Vuong Bui gravatar imageVuong Bui ( 2013-04-11 21:33:17 -0600 )edit
1

Ok listen now, just keep repeating you can't is stupid, since this code is running for me. Basically you want code else you wont stop telling it is wrong. Take a look at this pseudo code.

 Mat large = Mat(1600, 1000, CV_8UC1
 int stepsize_width = 800;
 int stepsize_height = 500;

 for(int i = 0; i < 2; i++){
     for(int j = 0; j<2; j++){ 
          Rect region_of_interest(i*step_width, j*step_heigth, width, heigth);
          Mat small = large(region_of_interest);
          // Process here - add coordinates
          // Do not forget to add width and height to your retrieved coordinates depending on which window you are at.
     }
 }
StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-12 01:11:41 -0600 )edit

Question Tools

Stats

Asked: 2013-04-09 10:33:00 -0600

Seen: 2,179 times

Last updated: Apr 11 '13