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 5945239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:39:13+00:00 2026-05-22T16:39:13+00:00

I have got OpenCV installed on vs2010/win7 however I’m seeing some behaviour that I

  • 0

I have got OpenCV installed on vs2010/win7 however I’m seeing some behaviour that I can’t figure out.

I am new to OpenCV so just have a basic program to pull frames from an avi file – it then splits that frame into single channel images and generates histograms for each of those (taken from an internet example). It actually all works fine, it’s just extremely slow. It turns out that cvFillConvexPoly is actually taking 10-15 seconds (sometimes longer) to complete – but when it eventually returns it is correct.

This is the code snippet where I call the culprit function and as you can see I also tried cvFillPoly which took the same amount of time to complete.

IplImage* DrawHistogram(CvHistogram *hist, float sX)
{
    float histMax = 0;
    cvGetMinMaxHistValue(hist, 0, &histMax, 0, 0);

    IplImage *imgHist = cvCreateImage(cvSize(256, 64), IPL_DEPTH_8U, 1);
    cvZero(imgHist);

    float histValue = 0;
    float nextValue = 0;
    for (int i = 0; i < ((BINS - 1)*sX); i++)
    {
        histValue = cvQueryHistValue_1D(hist, i);
        nextValue = cvQueryHistValue_1D(hist, i + 1);

        CvPoint p1 = cvPoint(i * sX, 64);
        CvPoint p2 = cvPoint((i + 1) * sX, 64);
        CvPoint p3 = cvPoint((i + 1) * sX, 64 - histValue*(64/histMax));
        CvPoint p4 = cvPoint(i * sX, 64 - histValue*(64/histMax));

        int n = 5;
        CvPoint pts[] = {p1, p2, p3, p4};

        cvFillConvexPoly(imgHist, pts, n, cvScalar(255));
        //cvFillPoly(imgHist, pts, &n, 1,cvScalar(255));
    }

    return imgHist;
}

Any help is appreciated.

Compiled on Win7 x64 with CMake 2.8.2/VS2010 as 32 bit. Same behaviour when debugging and when running as a standalone.

Also have it running on Ubuntu 10.10 32 bit, compiled with gcc 4.4.5 where there isn’t a problem.


Edit

I’ve tried recompiling with VS2008 and it still does the same thing. I don’t understand what would cause it to run so slowly – unless it’s the way 64bit windows “emulates” 32 bit which is causing the problem.

  • 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-22T16:39:13+00:00Added an answer on May 22, 2026 at 4:39 pm

    I can spot 2 possible bugs in your code, both of which have to do with bounds. Reading/writing outside array boundaries may result in all kinds of unexpected behavior, so it’s a wonder your programs don’t crash. Maybe GCC and/or the OpenCV library behaves differently on Ubuntu and Windows causing it not to crash on Ubuntu, but you should definitely take a look at the following 2 points.

    1. I assume sX is a scaling factor? Your for loop should run from 0 to (BINS-1) no matter this scaling, since you’re using i to index your histogram and there are BINS bins, not BINS*sX. As long as sX == 1 you won’t run into trouble but any other value will invalidate your histogram drawing code. You are already using sX in its correct way too in the cvPoint declarations.

    2. According to the docs of the cvFillConvexPoly function, n should be the number of points, which is 4 in your case, not 5.

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

Sidebar

Related Questions

have got a problem with do this kind of code , can't figure how
Have got an NSString *str = @12345.6789 and want to find out if there
I have got some code to load an assembly and get all types, which
I have got script which generates some graphic and returns it as a result,
I have a multithreaded openCV program that uses 4 threads to do the following:
I have created a new project (without code) that uses OpenCV. I the project
I have got a text field, and then I type some text onto it.
I have got some problem implementing bullet physics into my opengl game. The thing
I have got a page which lets me control some devices in a local
I have installed OpenCV C libraries from package management into my Kubuntu 9.10. I

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.