MCPcopy
hub / github.com/JimmyHHua/opencv_tutorials / get_hog_descriptor

Function get_hog_descriptor

python/code_104/opencv_104.py:6–18  ·  view source on GitHub ↗
(image)

Source from the content-addressed store, hash-verified

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

Callers 2

get_dataFunction · 0.70
elec_detectFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected