Horje
how to detect the body with cv2 Code Example
how to detect the body with cv2
import numpy as np
import cv2


def inside(r, q):
    rx, ry, rw, rh = r
    qx, qy, qw, qh = q
    return rx > qx and ry > qy and rx + rw < qx + qw and ry + rh < qy + qh


def draw_detections(img, rects, thickness = 1):
    for x, y, w, h in rects:
     
        pad_w, pad_h = int(0.15*w), int(0.05*h)
        cv2.rectangle(img, (x+pad_w, y+pad_h), (x+w-pad_w, y+h-pad_h), (0, 255, 0), thickness)


if __name__ == '__main__':

    hog = cv2.HOGDescriptor()
    hog.setSVMDetector( cv2.HOGDescriptor_getDefaultPeopleDetector() )
    cap=cv2.VideoCapture('vid.avi')
    while True:
        _,frame=cap.read()
        found,w=hog.detectMultiScale(frame, winStride=(8,8), padding=(32,32), scale=1.05)
        draw_detections(frame,found)
        cv2.imshow('feed',frame)
        ch = 0xFF & cv2.waitKey(1)
        if ch == 27:
            break
    cv2.destroyAllWindows()




Python

Related
pandas column rgeex doesnot contain Code Example pandas column rgeex doesnot contain Code Example
save gif python Code Example save gif python Code Example
how to run ewa requirement.txt file Code Example how to run ewa requirement.txt file Code Example
Use the "map" function to find all the odd numbers and the even numbers in the list. Print 0 for odd and 1 for even. in python Code Example Use the "map" function to find all the odd numbers and the even numbers in the list. Print 0 for odd and 1 for even. in python Code Example
operation that returns True if all values are equal Code Example operation that returns True if all values are equal Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7