色调直方图示例opencv

色调直方图示例opencv,opencv,Opencv,我已经尝试在这里搜索,并找到了许多答复,但我仍然无法找到我的问题 我正在尝试从彩色图像创建色调直方图。我的代码如下: Mat input = imread("jan31/class4Jan31.jpg",1); Mat hsv_input; cvtColor( input, hsv_input, CV_BGR2HSV ); int h_bins = 5; int histSize[] = { h_bins}; float h_ranges

我已经尝试在这里搜索,并找到了许多答复,但我仍然无法找到我的问题

我正在尝试从彩色图像创建色调直方图。我的代码如下:

    Mat input = imread("jan31/class4Jan31.jpg",1);

    Mat hsv_input;

    cvtColor( input, hsv_input, CV_BGR2HSV );

    int h_bins = 5; 
    int histSize[] = { h_bins}; 
    float h_ranges[] = { 0, 180 };

    const float* ranges[] = { h_ranges };
    int channels[] = { 0 };

    MatND hist_input;
    calcHist( &hsv_input, 1, channels, Mat(), hist_input, 2, histSize, ranges, true, false );
    normalize( hist_input, hist_input, 0, 1, NORM_MINMAX, -1, Mat() );
但我得到了以下错误:
OpenCV错误:setSize中的断言失败(s>=0)

我应该使用以下代码:

 calcHist( &hsv_input, 1, channels, Mat(), hist_input, 1, histSize, ranges, true, false );