0

I'm very new to OpenCV, and i want to create simple object detector, that uses SVM. Instead of HOG, i would like to extract from my object color histograms(for example), but i couldn't find any information about it for OpenCV, everywhere is using HOG.

And my second question: is Python implemenation for SVM has less functionality than C++ (both for OpenCV) ?

pavel_s
  • 465
  • 1
  • 7
  • 27

1 Answers1

2

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.

Community
  • 1
  • 1
Ujjwal
  • 3,088
  • 4
  • 28
  • 36
  • Thanks for an answer! And in &bgr_planes i should put all my positive and negative images? And after that i must teach SVM on histograms, that i will get with this function? – pavel_s Dec 19 '14 at 06:23