Ask Your Question
0

How can I change car recognition to people recognition?

asked 2020-01-20 21:48:16 -0600

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)
edit retag flag offensive close merge delete

Comments

2

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.

berak gravatar imageberak ( 2020-01-21 02:46:52 -0600 )edit
1
berak gravatar imageberak ( 2020-01-21 11:00:42 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-01-21 04:52:49 -0600

thank you, I'll take your advice.)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-01-20 21:48:16 -0600

Seen: 265 times

Last updated: Jan 20 '20