(image)
| 4 | |
| 5 | # 把目标图放在64x128的灰色图片中间,方便计算描述子 |
| 6 | def 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 | |
| 20 | def get_data(train_data, labels, path, lableType): |
| 21 | for file_name in os.listdir(path): |
no outgoing calls
no test coverage detected