- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 OpenCV 的 CPU 版本的定向梯度直方图 (HOG)。我使用的是 32x32 图像,其中包含 4x4 单元格、4x4 block 、 block 之间没有重叠以及 15 个方向箱。 OpenCV 的 HOGDescriptor
给了我一个长度为 960 的一维特征向量。这是有道理的,因为(32*32 像素)*(15 个方向)/(4*4 个单元格)= 960。
但是,我不确定这 960 个数字在内存中的布局方式。我的猜测是这样的:
vector<float> descriptorsValues =
[15 bins for cell 0, 0]
[15 bins for cell 0, 1]
...
[15 bins for cell 0, 7]
....
[15 bins for cell 7, 0]
[15 bins for cell 7, 1]
...
[15 bins for cell 7, 7]
当然,这是一个平面化为一维的二维问题,所以它实际上看起来像这样:
[cell 0, 0] [cell 0, 1] ... [cell 7, 0] ... [cell 7, 7]
这是我的示例代码:
using namespace cv;
//32x32 image, 4x4 blocks, 4x4 cells, 4x4 blockStride
vector<float> hogExample(cv::Mat img)
{
img = img.rowRange(0, 32).colRange(0,32); //trim image to 32x32
bool gamma_corr = true;
cv::Size win_size(img.rows, img.cols); //using just one window
int c = 4;
cv::Size block_size(c,c);
cv::Size block_stride(c,c); //no overlapping blocks
cv::Size cell_size(c,c);
int nOri = 15; //number of orientation bins
cv::HOGDescriptor d(win_size, block_size, block_stride, cell_size, nOri, 1, -1,
cv::HOGDescriptor::L2Hys, 0.2, gamma_corr, cv::HOGDescriptor::DEFAULT_NLEVELS);
vector<float> descriptorsValues;
vector<cv::Point> locations;
d.compute(img, descriptorsValues, cv::Size(0,0), cv::Size(0,0), locations);
printf("descriptorsValues.size() = %d \n", descriptorsValues.size()); //prints 960
return descriptorsValues;
}
相关资源: This StackOverflow post和 this tutorial帮助我开始使用 OpenCV HOGDescriptor。
最佳答案
我相信您的想法是正确的。
在其原始论文中Histograms of Oriented Gradients for Human Detection (第 2 页),它说
[...] The detector window is tiled with a grid of overlapping blocks in which Histogram of Oriented Gradient feature vectors are extracted. [...]
[...] Tiling the detection window with a dense (in fact, overlapping) grid of HOG descriptors andusing the combined feature vector [...]
它谈论的只是tiling他们在一起。尽管没有介绍如何将它们准确地拼贴在一起的详细信息。我想这里不应该发生任何奇特的事情(否则他们会谈论它),即只是定期连接它们(从左到右,从上到下)。
毕竟,这是合理且最简单的数据布局方式。
编辑:如果您查看how people access and visualize the data,您将更加说服自己。 .
for (int blockx=0; blockx<blocks_in_x_dir; blockx++)
{
for (int blocky=0; blocky<blocks_in_y_dir; blocky++)
{
for (int cellNr=0; cellNr<4; cellNr++)
{
for (int bin=0; bin<gradientBinSize; bin++)
{
float gradientStrength = descriptorValues[ descriptorDataIdx ];
descriptorDataIdx++;
// ... ...
} // for (all bins)
} // for (all cells)
} // for (all block x pos)
} // for (all block y pos)
关于c++ - OpenCV HOG特征数据布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13351913/
我打算将 hog 特征描述符与 SVM 分类器结合用于对象检测项目。 scikit-image 中提供的 hog 在分类阶段产生了非常好的结果。但是,它运行得非常慢(手头每张图像 20 秒)。另一方面
在 OpenCV 中,有一个 CvSVM 类,它接受样本矩阵来训练 SVM。矩阵是二维的,样本在行中。 我创建了自己的方法来根据视频源生成定向梯度 (HOG) 直方图。为此,我创建了一个 9 chan
我有一段 MATLAB 代码,它从图像中提取一个 91x91 的像素 block ,然后用苹果 HOG 提取其特征向量。我想用 Python 重写函数。我一直在努力寻找如何在 Python 中获得与在
使用时从图像中提取HOG功能时 bin_n = 16 # Number of bins def hog(img): gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
在 openCV 中似乎没有任何 HOG 训练的实现,关于 HOG 训练如何工作的资料也很少。根据我收集到的信息,HOG 训练可以实时完成。但是培训的要求是什么?培训过程实际上是如何进行的? 最佳答案
我们有一个项目可以从图像中识别 Logo 。我们最初使用 Haar 分类器,但训练 Haar 分类器需要很多时间(在我们的 Core i5 机器上每个 Logo 需要 4 天)。为 300 多个 Lo
我在试图理解本文中 HOG 特征的大小时感到困惑。 Mid-level Elements for Object Detection. .在Dalal的工作中,一个64*128像素的窗口是由一个4*9*
我想检测显微镜图像细胞内的物体。我有很多带注释的图像(大约 50,000 张带有对象的图像和 500,000 张没有对象的图像)。 到目前为止,我尝试使用 HOG 提取特征并使用逻辑回归和 Linea
我正在从事杂草检测工作。我已经开始从 HoG 描述符中提取特征。正如从 HoG 文献中研究的那样,HoG 不是旋转不变的。我总共有 18 张草类杂草的图像,有两类。在我的训练和测试数据库中,我将每个图
我正在从事杂草检测工作。我已经开始从 HoG 描述符中提取特征。正如从 HoG 文献中研究的那样,HoG 不是旋转不变的。我总共有 18 张草类杂草的图像,有两类。在我的训练和测试数据库中,我将每个图
根据HOG过程,如论文人体检测定向梯度直方图(请参阅下面的链接)中所述,对比度归一化步骤在合并和加权投票后完成。 我一无所知-如果我已经计算了像元的加权梯度,那么图像对比度的标准化现在对我有什么帮助?
我无法理解 HOG 特征向量的大小... 场景:我拍摄了一张 286x286 图像。然后我计算了每个 8x8 补丁的 HOG。这意味着我得到了 8x8x2=128 个数字,由每个补丁的 9 bin 直
我从 hog.compute 函数中提取了特征,然后使用这些特征来训练 SVM 分类器。我使用了在网上找到的一个脚本来从分类文件中分离出 rho 和支持向量。 tree = ET.parse('svm
我是使用 HOG 检测器检测路上行人的新手,我已经编写了代码并尝试运行它,但它总是在这一行出现错误:“hog.setSVMDetector(HOGDescriptor: :getDefaultPeop
跟踪对象时,我希望能够在遮挡后重新检测到它。 在 OpenCV 3.4.5 (C++) 上,我尝试了模板匹配和光流分割。但是现在,我想使用 HOG 描述符实现更稳健的算法。 我举了一个小例子来说明这个
在谈论 Linux 内核时,“stack hog”是什么意思? 我在一些 Linux 内核书籍(Wolfgang Mauerer 的 Professional Linux Kernel Archite
在我的应用程序中,我必须使用静态摄像头跟踪大学讲座中的讲师。目前我正在使用 Emgu CV 的默认 GPUHOGDescriptor,如果讲师的整个 body 都可见,它会很好用。在讲师站在 tabl
我正在研究真菌孢子检测。我有大约 359 张正图像(真菌颗粒的裁剪图像)和 171 张负图像(灰尘颗粒的裁剪图像)。 pos/nag 图像的实际大小与粒子大小相同,约为 8x8,但对于 SVM 训练,
我已经使用 HOG 实现了汽车检测器,目前工作正常。不幸的是,我对分类器有很多误报。 到目前为止我做了什么 我将样本的比率(正:负)从 1:1 更改为 1:3 并将误报率降低到一定程度。有人可以帮助减
我有 5000 张图像,每张图像可以生成一个大约 1000 维的向量(hog 特征),但是有些图像非常相似,所以我想删除相似的图像。有办法实现吗? ==========================
我是一名优秀的程序员,十分优秀!