MCPcopy Create free account
hub / github.com/JimmyHHua/opencv_tutorials / get_hog_descriptor

Function get_hog_descriptor

python/code_103/opencv_103.py:7–19  ·  view source on GitHub ↗
(image)

Source from the content-addressed store, hash-verified

5
6# 把目标图放在64x128的灰色图片中间,方便计算描述子
7def get_hog_descriptor(image):
8 hog = cv.HOGDescriptor()
9 h, w = image.shape[:2]
10 rate = 64 / w
11 image = cv.resize(image, (64, np.int(rate*h)))
12 gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
13 bg = np.zeros((128, 64), dtype=np.uint8)
14 bg[:,:] = 127
15 h, w = gray.shape
16 dy = (128 - h) // 2
17 bg[dy:h+dy,:] = gray
18 fv = hog.compute(bg, winStride=(8, 8), padding=(0, 0))
19 return fv
20
21def get_data(train_data, labels, path, lableType):
22 for file_name in os.listdir(path):

Callers 1

get_dataFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected