Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3953646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:00:00+00:00 2026-05-20T02:00:00+00:00

i am using images that are 2048 x 500 and when I use cvShowImage,

  • 0

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:00:01+00:00Added an answer on May 20, 2026 at 2:00 am

    I am having the same problem with OpenCV 2.1 using it with Windows and mingw compiler. It took me forever to find out what was wrong. As you describe it, cvSetMouseCallback gets too large y coordinates. This is apparently due to the image and the cvNamedWindow it is shown in being bigger than my screen resolution; thus I cannot see the bottom of the image.

    As a solution I resize the images to a fixed size, such that they fit on the screen (in this case with resolution 800×600, which can be any other values:

    // g_input_image, g_output_image and g_resized_image are global IplImage* pointers.
    
    int img_w = cvGetSize(g_input_image).width;
    int img_h = cvGetSize(g_input_image).height;
    
    // If the height/width ratio is greater than 6/8 resize height to 600.
    if (img_h > (img_w*6)/8) {
        g_resized_image = cvCreateImage(cvSize((img_w*600)/img_h, 600), 8, 3);
    }
    // else adjust width to 800.
    else {
        g_resized_image = cvCreateImage(cvSize(800, (img_h*800)/img_w), 8, 3);
    }
    
    cvResize(g_output_image, g_resized_image);
    

    Not a perfect solution, but works for me…

    Cheers,
    Linus

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PHP/MySQL to handle the image uploading. I want all images that
I need to draw a gridded image using opengl. I've read that images created
I'm using flex and have a few images that I need to sequence through.
I'm working with multiple images that need to be compressed using the DXT/S3TC format
I usually download images that are larger in size and shrink them using an
I'm running an app that pulls images using a URL into a gridView, the
I am using PHP and I have an array of user images that I
I'm currently developing an Android application that fetches images using http requests. It would
I am downloading images using the NSURLConnection sendSynchronousRequest method and that works fine. However,
I have an app that will show some images using UIImageView, now I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.