You can use the OpenCV function calcHist
to compute histograms.
calcHist(&bgr_planes[0], 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );
where,
- &bgr_planes[0]: The source array(s)
- 1: The number of source arrays
- 0: The channel (dim) to be measured. In this case it is just the
intensity so we just write 0.
- Mat(): A mask to be used on the source array
- b_hist: The Mat object where the histogram will be stored
- 1: The histogram dimensionality.
- histSize: The number of bins per each used dimension
- histRange: The range of values to be measured per each dimension
uniform and accumulate
Refer to the docs for more information.
You can also look at this answer which discusses C++ OpenCV SVM implementation and this answer which discusses Python OpenCV SVM implementation to get started.