我是opencv的新手,我想计算HSV直方图。我指的是此链接中提供的代码。https://docs.opencv.org/3.0-beta/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.html
我正在使用 opencv 3.3.1 版并面临以下错误错误。
使用相同的代码,除了更改 HSV 直方图的图像外,我没有对代码进行任何更改。其中 detectPerson 是视频帧,hsv 是 cv mat 对象。
任何人请帮助我被困在这里。
int h_bins = 50, s_bins = 60;
int histSize[] = {h_bins, s_bins};
// hue varies from 0 to 179, saturation from 0 to 255
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
// Use the 0-th and 1-st channels
int channels[] = { 0, 1 };
cv::Mat hist_hsv, hist_hsv2;
cvtColor(detectPerson, hsv, COLOR_BGR2HSV );
calcHist( &hsv, 1, 0, Mat(), hist_hsv, 2, histSize, ranges, true, false );
normalize( hist_hsv, hist_hsv, 0, 1, NORM_MINMAX, -1, Mat() );
错误
int channels[] = { 0, 1 };
error: too many initializers for 'int [0]'
int histSize[] = {h_bins, s_bins}
error: too many initializers for 'int [0]'
float h_ranges[] = { 0, 180 };
error: too many initializers for 'float [0]'
float s_ranges[] = { 0, 256 };
error: too many initializers for 'float [0]'