import cv2 cap = cv2.VideoCapture(0)# 0 is the default id of web camera face_cascade = cv2.CascadeClassifier(‘haarcascade_frontalface_default.xml’) while True: ret,frame = cap.read() #cap.read() gives two vale one is boolean thai is in ret and video stored in frame gray_frame = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) if ret == False: continue faces = face_cascade.detectMultiScale(gray_frame,1.3,5) #wait for user input-q,then stop the loop #for square frame arraound the image #x,y arethe statting point of frame #w,h are the width and height of thw frame for (x,y,w,h)in faces: cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)#(x,y)starting point of frame,(x+w,y+h) end point of frame(255,0,0),2 color of boundary cv2.imshow(“video frame”,frame)#give title to video frame and show video key_pressed = cv2.waitKey(1)&0xFF #gives a 32 bit op if key_pressed == ord(‘q’):#read image till q is pressed break cap.release() cv2.destroyAllWindows()