简体   繁体   English

使用颜色直方图使用OpenCV训练SVM

[英]Train SVM with OpenCV using colour histograms

I'm very new to OpenCV, and i want to create simple object detector, that uses SVM. 我是OpenCV的新手,我想创建一个使用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. 我想从我的对象颜色直方图中提取HOG而不是HOG(例如),但是我找不到OpenCV的任何有关它的信息,到处都在使用HOG。

And my second question: is Python implemenation for SVM has less functionality than C++ (both for OpenCV) ? 我的第二个问题:SVM的Python实现是否比C ++的功能更少(均为OpenCV)?

You can use the OpenCV function calcHist to compute histograms. 您可以使用OpenCV函数calcHist计算直方图。

calcHist(&bgr_planes[0], 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );

where, 哪里,

  • &bgr_planes[0]: The source array(s) &bgr_planes [0]:源数组
  • 1: The number of source arrays 1:源数组数
  • 0: The channel (dim) to be measured. 0:要测量的通道(暗)。 In this case it is just the intensity so we just write 0. 在这种情况下,它只是强度,因此我们只写0。
  • Mat(): A mask to be used on the source array Mat():源数组上要使用的掩码
  • b_hist: The Mat object where the histogram will be stored b_hist:将存储直方图的Mat对象
  • 1: The histogram dimensionality. 1:直方图维数。
  • histSize: The number of bins per each used dimension histSize:每个使用的维度的箱数
  • histRange: The range of values to be measured per each dimension uniform and accumulate histRange:每个维度要测量并统一累积的值的范围

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. 您也可以看看这个答案 ,其中讨论了C ++ OpenCV的SVM执行和这个答案 ,其中讨论了Python的OpenCV的SVM实现上手。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM