【视觉调试】ZH视觉调试SVM笔记

//识别验证
int ::() {
cv::Mat src = http://www.kingceram.com/post/cv::(".//测试集/1.bmp");
if (src.empty()) {
-1;
= time(0);
char [64];
(, (), "%Y-%m-%d %H-%M-%S", (&)); //年-月-日 时-分-秒
std::= ;
std::= ".//测试集/" ++ ".jpg";
std::= ".//测试集/" ++ ".bmp";
cv::(, src);
(".//测试集/1.bmp");
//cv::("src", cv::);
//cv::("src", src);
//cv::Mat dst1;
//(src, dst1);
//cv::("dst1", cv::);
//cv::("dst1", dst1);
//cv::(0);
//dst1.(src);
//cv::("2", cv::);
//cv::("2", src);
//cv::(0);
cv::>model = cv::ml::SVM::();
model = cv::::>(".//.xml");
if (model->empty()) {
-2;
cv:: Myhog;
cv::Mat= model->();
int= model->();
int svdim = model->();
int= .rows;
cv::Mat= cv::Mat::zeros(, svdim, );
cv::Mat= cv::Mat::zeros(1, , );
float rho = model->(0, , );
cv::Mat ;
.(, );
= -1 ** ;
std:: vec;
for (int i = 0; i < svdim; ++i) {
vec.(.at(0, i));
vec.(rho);//
【【视觉调试】ZH视觉调试SVM笔记】Myhog.(vec);
std::> found, ;//矩形框数组
//Myhog.(src, found, 0, cv::Size(8, 8), cv::Size(8, 8), 1.051, 30.0);//对图片进行多尺度检测 src, found, 0, cv::Size(16, 16), cv::Size(32, 32), 2.5, 20
Myhog.(src, found, 0, cv::Size(16, 16), cv::Size(16, 16), 1.051, 3);//4相对3检测不到且变慢 。变大3减少误分类 。5最终红色木块参数
//Myhog.(src, found, 0, cv::Size(32, 32), cv::Size(32, 32), 1.05, 30);
if (found.size() == 0) {
//Myhog.(src, found, 0, cv::Size(8, 8), cv::Size(8, 8), 1.05, 2);//检测不到木块cv::Size(8, 8)太小
Myhog.(src, found, 0, cv::Size(8, 8), cv::Size(8, 8), 1.05, 2);//对图片进行多尺度检测 src, found, 0, cv::Size(8, 8), cv::Size(8, 8), 1.05, 2
//找出所有没有嵌套的矩形框r,并放入中,如果有嵌套的话,则取外面最大的那个矩形框放入中
for (int i = 0; i < found.size(); i++) {
if (0 > found[i].width || found[i].width > 4000)
;
cv::Rect r = found[i];
int j = 0;
for (; j < found.size(); j++)
if (j != i && (r & found[j]) == r)
break;
if (j == found.size())
.(r);
for (int i = 0; i < .size(); i++) {
cv::Rect r = [i];
(src, r.tl(), r.br(), cv::(255), 7);
//cv::(".//测试集/1.jpg", src);
cv::("", cv::);
cv::(, src);
cv::("", src);
cv::(0);
cv::();
1;
构造函数:
cv:: hog(cv::Size(576, 576), cv::Size(192, 192), cv::Size(96, 96), cv::Size(96, 96), 9);//HOG检测器,用来计算HOG描述子的,依次为检测窗口,块尺寸,块步长,cell尺寸,直方图个数
/**@briefthe HOGandwith.
aqual to (Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 )
*/
() : (192,192), (64,64), (32,32),
(32,32), nbins(9), (1), (-1),
(::L2Hys), (0.2), (true),
(-1.f), (::), (false)
{}
/** @
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsets nbins with given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
@paramsetswith given value.
*/
(Size , Size , Size ,
Size , int , int =1,=-1,
:: =::L2Hys,
=0.2, bool =false,
int =::, bool =false)
: (), (), (), (),
nbins(), (), (),
(), (),
(), (-1.f), (), ()
{}
——HOG详解的博客-CSDN博客
::()有些限制
1.only
2.==
/** @briefofsizes in the input image. Theareas a list
of .
@param imgof the type CV_8U oran image whereare .
@paramofwhere eachthe.