Perform the following steps to detect people in an image using opencv-python library functions:
- First, read the image and initialize the HOG detector using the following lines of code:
img = cv2.imread("images/walk.jpg")hog = cv2.HOGDescriptor()
- Initialize the SVM detector to be the default people detector:
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
- Run the detection algorithm, with a spatial stride of 4 pixels (horizontal and vertical), a scale stride of 1.1, and no grouping of the rectangles (to notice that HOG detects the same object at multiple scales in the scale pyramid). As you can see, 314 potential bounding boxes were detected (with multiple detections of the same object):
(found_bounding_boxes, ...