HOG 使用 OpenCV 实现可视化,C++ 中的 HOGDescriptor
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10862542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HOG features visualisation with OpenCV, HOGDescriptor in C++
提问by ChHaupt
I use the HOGDescriptor of the OpenCV C++ Lib to compute the feature vectors of an images. I would like to visualize the features in the source image. Can anyone help me?
我使用 OpenCV C++ Lib 的 HOGDescriptor 来计算图像的特征向量。我想可视化源图像中的特征。谁能帮我?
回答by Jürgen Brauer
I had exactly the same problem today. Computing a HOGDescriptor
vector for a 64x128 image using OpenCV's HOGDescriptor::compute()
function is easy, but there is no built-in functionality to visualize it.
我今天遇到了完全相同的问题。HOGDescriptor
使用 OpenCV 的HOGDescriptor::compute()
函数计算64x128 图像的向量很容易,但没有内置功能来可视化它。
Finally I managed to understand how the gradient orientation magnitudes are stored in the 3870 long HOG descriptor vector.
最后,我设法理解了梯度方向幅度如何存储在 3870 长的 HOG 描述符向量中。
You can find my C++ code for visualizing the HOGDescriptor
here:
您可以在HOGDescriptor
此处找到用于可视化的 C++ 代码:
Hope it helps!
希望能帮助到你!
Jürgen
于尔根
回答by Yamaneko
HOGgles1 is a method developed for HOG visualization, published on ICCV 2013. Here is an example:
HOGgles1 是一种为 HOG 可视化开发的方法,发表在 ICCV 2013 上。 下面是一个例子:
This visualization tool may be more useful than plotting the gradient vectors of HOG because one can see better why HOG failed for a given sample.
这种可视化工具可能比绘制 HOG 的梯度向量更有用,因为人们可以更好地了解 HOG 对给定样本失败的原因。
More information can be found here: http://web.mit.edu/vondrick/ihog/
更多信息可以在这里找到:http: //web.mit.edu/vondrick/ihog/
1C. Vondrick, A. Khosla, T. Malisiewicz, A. Torralba. "HOGgles: Visualizing Object Detection Features" International Conference on Computer Vision (ICCV), Sydney, Australia, December 2013.
1C。Vondrick、A. Khosla、T. Malisiewicz、A. Torralba。“HOGgles: Visualizing Object Detection Features”国际计算机视觉会议 (ICCV),澳大利亚悉尼,2013 年 12 月。
回答by KobeJohn
Thisopencv group discussion leads to a library written at Brown University.
这个opencv 小组讨论导致了一个在布朗大学编写的图书馆。
In HOGpicture.m
you should be able to get an idea how to visualize the descriptors. Here is the relevant (matlab) code. Is it enough for you to make something for yourself?
在HOGpicture.m
你应该能够得到一个想法如何形象化描述。这是相关的(matlab)代码。你自己做点东西就够了吗?
(below code is released under an MIT license)
(以下代码是在MIT 许可下发布的)
function im = HOGpicture(w, bs)
% HOGpicture(w, bs)
% Make picture of positive HOG weights.
% construct a "glyph" for each orientation
bim1 = zeros(bs, bs);
bim1(:,round(bs/2):round(bs/2)+1) = 1;
bim = zeros([size(bim1) 9]);
bim(:,:,1) = bim1;
for i = 2:9,
bim(:,:,i) = imrotate(bim1, -(i-1)*20, 'crop');
end
% make pictures of positive weights bs adding up weighted glyphs
s = size(w);
w(w < 0) = 0;
im = zeros(bs*s(1), bs*s(2));
for i = 1:s(1),
iis = (i-1)*bs+1:i*bs;
for j = 1:s(2),
jjs = (j-1)*bs+1:j*bs;
for k = 1:9,
im(iis,jjs) = im(iis,jjs) + bim(:,:,k) * w(i,j,k);
end
end
end
回答by Zhiqiang Zhou
I reimplement HOGImage for any blockSize
and cellSize
, which is based on Jürgen Brauer's. See https://github.com/zhouzq-thu/HOGImage.
我为 anyblockSize
和重新实现了 HOGImage cellSize
,它基于 Jürgen Brauer 的。见https://github.com/zhouzq-thu/HOGImage。