How can I change car recognition to people recognition?
There is a code like this that highlights cars, how do I make people stand out? I tried to play with the settings, it turns out badly. ps I'm just learning and figuring it out.
while True:
ret, frame = cap.read() # import image
if ret: # if there is a frame continue with code
image = cv2.resize( frame, (0 , 0 ), None, ratio, ratio) # resize image
gray = cv2.cvtColor( image, cv2.COLOR_BGR2GRAY) # converts image to gray
fgmask = fgbg.apply(gray) # uses the background subtraction
# applies different thresholds to fgmask to try and isolate cars
# just have to keep playing around with settings until cars are easily identifiable
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5)) # kernel to apply to the morphology
closing = cv2.morphologyEx( fgmask, cv2.MORPH_CLOSE, kernel)
opening = cv2.morphologyEx( closing, cv2.MORPH_OPEN, kernel)
dilation = cv2.dilate(opening, kernel)
retvalbin, bins = cv2.threshold(dilation, 220, 255, cv2.THRESH_BINARY) # removes the shadows
# creates contours
im2, contours, hierarchy = cv2.findContours( bins, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# use convex hull to create polygon around contours
hull = [cv2.convexHull(c) for c in contours]
# draw contours
cv2.drawContours( image, hull, - 1 , ( 0 , 255 , 0 ), 3)
your code does not "recognize" anything, it just highlights "things in motion".
maybe you want to put this approach aside for a moment, and take a look at cnn basede object detection usng one of the pretrained models.
also: https://github.com/opencv/opencv/blob...