(imgs)
| 58 | return labels |
| 59 | |
| 60 | def get_features(imgs): |
| 61 | features = [] |
| 62 | hog = cv2.HOGDescriptor('hog.xml') |
| 63 | |
| 64 | # 二值化 |
| 65 | for i in range(len(imgs)): |
| 66 | cv_img = imgs[i].astype(np.uint8) |
| 67 | cv2.threshold(cv_img,25,255,cv2.cv.CV_THRESH_BINARY_INV,imgs[i]) |
| 68 | |
| 69 | for img in imgs: |
| 70 | cv_img = img.astype(np.uint8) |
| 71 | |
| 72 | hog_feature = hog.compute(cv_img) |
| 73 | hog_feature = np.transpose(hog_feature) |
| 74 | |
| 75 | features.append(hog_feature) |
| 76 | |
| 77 | return np.array(features) |
| 78 | |
| 79 | def get_hog_features(): |
| 80 | # trainset features |