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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:42:49+00:00 2026-05-24T03:42:49+00:00

I am getting an ambiguity error in OpenCV when I am trying to calculate

  • 0

I am getting an ambiguity error in OpenCV when I am trying to calculate a histogram and was wondering if I was missing something. I took a look at the function parameters and saw that it took one of the following:

void calcHist( const Mat* images, int nimages,
                      const int* channels, InputArray mask,
                      OutputArray hist, int dims, const int* histSize,
                      const float** ranges, bool uniform=true, bool accumulate=false );

void calcHist( const Mat* images, int nimages,
                      const int* channels, InputArray mask,
                      SparseMat& hist, int dims,
                      const int* histSize, const float** ranges,
                      bool uniform=true, bool accumulate=false );

And in my code I have the following:

if(histMat.size > 0)
{
    float hranges[2] = {0, 180};
    float* phranges = hranges;

    cv::Mat hist;
    cv::Mat hsv;
    cv::Mat hue;
    cv::Mat mask;

    cvtColor(histMat, hsv, CV_BGR2HSV);

    int _vmin = vmin, _vmax = vmax;

    inRange(hsv, cv::Scalar(0, smin, MIN(_vmin,_vmax)),
        cv::Scalar(180, 256, MAX(_vmin, _vmax)), mask);
    int ch[] = {0, 0};

    hue.create(hsv.size(), hsv.depth());
    mixChannels(&hsv, 1, &hue, 1, ch, 1);

    if(eType == MODEL)
    {
        cv::Mat roi(hue, selection), maskroi(mask, selection);
        cv::calcHist(&roi, 1, 0, maskroi, hist, 1, &hsize, &phranges);
        cv::normalize(hist, hist, 0, 255, CV_MINMAX);

        trackWindow = selection;

        histimg = cv::Scalar::all(0);
        int binW = histimg.cols / hsize;
        cv::Mat buf(1, hsize, CV_8UC3);
        for( int i = 0; i < hsize; i++ )
            buf.at<cv::Vec3b>(i) = cv::Vec3b(cv::saturate_cast<uchar>(i*180./hsize), 255, 255);
        cvtColor(buf, buf, CV_HSV2BGR);

        for( int i = 0; i < hsize; i++ )
        {
            int val = cv::saturate_cast<int>(hist.at<float>(i)*histimg.rows/255);
            cv::rectangle( histimg, cv::Point(i*binW,histimg.rows),
                cv::Point((i+1)*binW,histimg.rows - val),
                cv::Scalar(buf.at<cv::Vec3b>(i)), -1, 8 );
        }
    }
}

I am trying to figure out what I can change in order to get this code to compile. Also please note that this chunk of code is in a function for a class. I’m trying to separate most of the Histogram sample code into it’s own separate function that is called only at certain points so I am not sure if it has anything to do with the fact that phranges is set at an improper place or if my variables are set improperly.

Any advice is greatly appreciated.

Thanks

  • 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-24T03:42:51+00:00Added an answer on May 24, 2026 at 3:42 am

    As mentioned in my comment above I had to place all variables in the function scope and not in the if check itself. I am not sure why that made a difference, but maybe it had something to do during compile time.

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

Sidebar

Related Questions

Getting the above error in following code. How to rectify it. Thanks. Please look
Getting a 'marshal data too short' error when trying to install the mysql gem
Getting this error while trying to erase the last element of a list. I
here i am getting this error message: Error 5 Ambiguity between 'OPTFDashboard.Common.Modules.CNAAll.ViewModels.CNAAllViewModel.Shift' and 'OPTFDashboard.Common.Modules.CNAAll.ViewModels.CNAAllViewModel.Shift'
Getting this error while I am trying to run /compile/build a Proiject Incompatible Types
Getting the following the error : Fatal error: Call to a member function load()
Getting this error: # rails c FFI::NotFoundError: Function 'xmlRelaxNGSetParserStructuredErrors' not found in [libxml2.so, libxslt.so,
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting a rendering error for this form: 'NoneType' object has no attribute 'widget' http://dpaste.com/88585/
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to

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.