views:

36

answers:

1

Hello,

i am using images that are 2048 x 500 and when I use cvShowImage, I only see half the image. This is not a big deal because the interesting part is on the top half of the image. Now, when I use the mouseHandler to get the x,y coordinates of my clicks, I noticed that the coordinate for y (the dimension that doesnt fit in the screen) is wrong.

It seems OpenCV think this is the whole image and recalibrates the coordinate system although we are only effectively showing half the image.

I would need to know how to do 2 things: - display a resized image that would fit in the screen

  • get the proper coordinate.

Did anybody encounter similar problems?

Thanks!

Update: it seems the y coordinate is divided by 2 of what it is supposed to be

code:

EXPORT void click_rect(uchar * the_img, int size_x, int size_y, int * points)
{
CvSize size;
size.height = size_y ;
size.width = size_x;

IplImage * img;
img = cvCreateImageHeader(size, IPL_DEPTH_8U, 1);
img->imageData = (char *)the_img;
img->imageDataOrigin = img->imageData;

img1 = cvCreateImage(cvSize((int)((size.width)) , (int)((size.height)) ),IPL_DEPTH_8U, 1);

cvNamedWindow("mainWin",CV_WINDOW_AUTOSIZE); 
cvMoveWindow("mainWin", 100, 100);

cvSetMouseCallback( "mainWin", mouseHandler_rect, NULL );

cvShowImage("mainWin", img1 );

//// wait for a key
cvWaitKey(0);

points[0] = x_1;
points[1] = x_2;
points[2] = y_1;
points[3] = y_2;

//// release the image
cvDestroyWindow("mainWin");
cvReleaseImage(&img1 );
cvReleaseImage(&img);
}
A: 

How are you building the window? You are not passing CV_WINDOW_AUTOSIZE to cvNamedWindow(), are you?

Share some source, @Denis.

karlphillip