error: (-215) (winSize.width - blockSize.width) % blockStride.width == 0 && (winSize.height - blockS

原创 2018年03月09日 09:55:59

又出问题了。。应该是hog滑动窗口descriptors block的大小问题
先附上2个宝贵经验贴:
http://blog.csdn.net/qq_39451109/article/details/77327213
http://blog.sciencenet.cn/blog-605185-487959.html
这里写图片描述

通过调用函数hog.setSVMDetector(detector);来加载训练好的分类器数据时,千万要注意detector的维数必须是3780,否则运行到这个语句就会报错。detector的维数即为HOG特征的维数,由样本的宽高,窗口(win)、块(block)、单元(cell)以及单元的滑移步长决定,它的维数对检测的正确有很大影响。

我的代码:
//第二个参数,即矩阵的列是由下面的descriptors的大小决定的,可以由descriptors.size()得到,且对于不同大小的输入训练图片,这个值是不同的

data_mat = Mat::zeros(nImgNum, 3780, CV_32FC1);

//类型矩阵,存储每个样本的类型标志
Mat res_mat(nImgNum, 1, CV_32SC1);

HOGDescriptor *hog = new HOGDescriptor(cvSize(ImgWidht, ImgHeight), cvSize(16, 16), cvSize(8, 8), cvSize(8, 8), 9);

size_t HOGDescriptor::getDescriptorSize() const
{
CV_Assert(blockSize.width % cellSize.width == 0 &&
blockSize.height % cellSize.height == 0);
CV_Assert((winSize.width - blockSize.width) % blockStride.width == 0 &&
(winSize.height - blockSize.height) % blockStride.height == 0 );
return (size_t)nbins*
(blockSize.width/cellSize.width)*
(blockSize.height/cellSize.height)*
((winSize.width - blockSize.width)/blockStride.width + 1)*
((winSize.height - blockSize.height)/blockStride.height + 1);
}

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dlh_sycamore/article/details/79493362

[Opencv源码阅读]HogDescriptor

Opencv中hog特征提取写在类HOGDescriptor中  默认的构造函数如下: CV_WRAP HOGDescriptor() : winSize(64,128), blo...
  • kfqcome
  • kfqcome
  • 2014-12-31 17:33:50
  • 1607

【已解决】error: (-215) size.width>0 && size.height>0 in function imshow

关于使用Python和OpenCV处理图像报error:(-215)错误的解决方法import cv2 image = cv2.imread("./image/jurassic-park-tour-j...
  • sinat_39150454
  • sinat_39150454
  • 2017-07-04 13:23:39
  • 4235

opencv报错 error: (-215) size.width>0 && size.height>0 in function cv::imshow

源代码如下 import cv2   img = cv2.imread('F:\222.jpg',2) cv2.imshow('image',img) k=cv2.waitKey(0)  ...
  • zzw000000
  • zzw000000
  • 2015-10-06 09:00:54
  • 4207

opencv cvtColor dtype issue(error: (-215) )

opencv cvtColor dtype issue(error: (-215) )更详细的错误信息如下,color.cpp:9710: error: (-215) depth == CV_8U |...
  • lanchunhui
  • lanchunhui
  • 2017-04-28 23:39:34
  • 1453

error: (-215) data0.dims <= 2 && type == CV_32F && K > 0

error: (-215) data0.dims 0
  • jacke121
  • jacke121
  • 2017-08-12 23:07:45
  • 918

【python】error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize

【python】error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize
  • qq_30214939
  • qq_30214939
  • 2017-08-20 20:21:54
  • 5409

解决Opencv的error: (-215) size.width>0 && size.height>0 in function cv::imshow

&amp;gt;&amp;gt;&amp;gt; import cv2 as cv im &amp;gt;&amp;gt;&amp;gt; img = cv.imread(&quot;D:\桌面入口\...
  • qq_39380075
  • qq_39380075
  • 2018-03-28 10:33:51
  • 31

error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize

运行环境:win10+python3.52+opencv3.0(64位) import cv2 import numpy as np img = cv2.imread(r'D:/中文/test....
  • u012222949
  • u012222949
  • 2017-05-10 15:46:20
  • 6472

sources\modules\core\src\matrix.cpp:362: error: (-215) u != 0 in function cv::Mat::create

这个报错,坑了我好久,所以特意记录一下。sources\modules\core\src\matrix.cpp:362: error: (-215) u != 0 in function cv::Ma...
  • hust_bochu_xuchao
  • hust_bochu_xuchao
  • 2018-03-16 20:05:29
  • 152

OpenCV Error: Assertion failed (dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0)) in unknown fun

[RESOLVED] HOGDescriptor Error: Assertion Failed! HOGDescriptor assertion error asked Jun 13 '13...
  • CVAIDL
  • CVAIDL
  • 2017-10-18 16:21:40
  • 267
收藏助手
不良信息举报
您举报文章:error: (-215) (winSize.width - blockSize.width) % blockStride.width == 0 && (winSize.height - blockS
举报原因:
原因补充:

(最多只允许输入30个字)