In this video we will see how to make live body detection app using opencv in jupyter notebook or any editor you want.
things required:
Python
OpenCV (pip install opencv-python)
TextEditor (preferred jupyter notebook or VSCode)
code :
import cv2
body_cascade = cv2.CascadeClassifier(“haarcascade_fullbody.xml”)
vid = cv2.VideoCapture(“Pexels Videos 26701.mp4”)
while True:
response , color_image = vid.read()
if response == False:
break
grey_image = cv2.cvtColor(color_image , cv2.COLOR_BGR2GRAY)
body = body_cascade.detectMultiScale(grey_image , 1.1 , 2)
for (x , y, w , h) in body:
cv2.rectangle(color_image , (x , y) , (x+w , y + h) , (0 , 255 , 255) , 2)
cv2.imshow(‘Detector’ , color_image)
if cv2.waitKey(1) & 0xFF == ord(‘q’):
break
vid.release()
cv2.destroyAllWindows()
#python #body detection app