Detecting people with HOG descriptors
OpenCV comes with a class called cv2.HOGDescriptor
, which is capable of performing people detection. The interface has some similarities to the cv2.CascadeClassifier
class that we used in Chapter 5, Detecting and Recognizing Faces. However, unlike cv2.CascadeClassifier
, cv2.HOGDescriptor
sometimes returns nested detection rectangles. In other words, cv2.HOGDescriptor
might tell us that it detected one person whose bounding rectangle is located completely inside another person's bounding rectangle. This situation really is possible; for example, a child could be standing in front of an adult, and the child's bounding rectangle could be completely inside the adult's bounding rectangle. However, in a typical situation, nested detections are probably errors, so cv2.HOGDescriptor
is often used along with code to filter out any nested detections.
Let's begin our sample script by implementing a test to determine whether one rectangle...