我正试图像在https://hal.inria.fr/hal-00725627/document中那样计算视频的密集特征轨迹。我试图使用像这样的openCV hog描述符:
winSize = (32,32)
blockSize = (32,32)
blockStride = (2,2)
cellSize = (2,2)
nbins = 9
hog = cv2.HOGDescriptor(winSize,blockSize,blockStride,cellSize,nbins)
hist = hog.compute(img)但是,这会返回一个非常大的大小特征向量:(160563456,1)。
什么是窗户?(winSize)什么是街区?什么是细胞?这些文档对于解释这些参数中的每一个并不特别有帮助。
在http://www.learnopencv.com/histogram-of-oriented-gradients/中,我看到为了计算HOGs,我们为图像补丁中的每个单元创建了一个直方图,然后在该补丁上进行标准化。
我想要的是我的图像的每个(32,32)个贴片的49 9bin直方图,它应该从这个贴片的(16,16)个细胞的直方图中计算出来。因此,我期望40716大小的猪的最后特征是(480,640)图像。
((32*32)/(16*16)* 9) *((480-16*640-16)/(32*32)*4)= 40716
((PatchSize /单元大小)* numBins) * numPatches = hogSize
我也见过人们做这样的事情:
winStride = (8,8)
padding = (8,8)
locations = ((10,20),)
hist = hog.compute(image,winStride,padding,locations)但是,我不明白locations参数的作用是什么,因为我不希望只计算单个位置的HOG特性,而只计算图像的所有(32,32)个补丁。
发布于 2017-07-10 09:32:25
cell_size = (16, 16) # h x w in pixels
block_size = (2, 2) # h x w in cells
nbins = 9 # number of orientation bins
# winSize is the size of the image cropped to an multiple of the cell size
# cell_size is the size of the cells of the img patch over which to calculate the histograms
# block_size is the number of cells which fit in the patch
hog = cv2.HOGDescriptor(_winSize=(img.shape[1] // cell_size[1] * cell_size[1],
img.shape[0] // cell_size[0] * cell_size[0]),
_blockSize=(block_size[1] * cell_size[1],
block_size[0] * cell_size[0]),
_blockStride=(cell_size[1], cell_size[0]),
_cellSize=(cell_size[1], cell_size[0]),
_nbins=nbins)
self.hog = hog.compute(img)发布于 2017-07-07 16:37:50
我们将图像划分为mxn像素的单元格。比方说8x8。因此,64x64图像将导致8x8单元的8x8像素。
为了减少整体亮度效应,我们在特征计算中增加了一个归一化停止。一个块包含多个单元格。我们没有对每个单元进行规范化,而是跨块进行正常化。32x32像素块将包含4x4 8x8像素单元。
窗口是我们计算特征描述符的图像的一部分。假设您想在大图像中找到64x64像素的东西。然后,您将在图像中滑动一个64x64像素的窗口,并计算每个位置的特征描述符,然后您将使用它来找到最佳匹配的位置。
都在文件里。只要读一读,试一试,直到你明白。如果您不能遵循这些文档,请阅读源代码并逐行查看发生了什么。
https://stackoverflow.com/questions/44972099
复制相似问题