I have an issue with time and face detection. When I 'am inside for loop ,the time sticks a little bit.Code:
import cv2 from datetime import datetime
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('face_detection.avi' , fourcc , 10.0 , (640 , 480))
while True: ret,frame = cap.read() font = cv2.FONT_HERSHEY_SIMPLEX date_time = str(datetime.today().strftime("%d-%m-%Y")) + ' ' + str(datetime.now().strftime("%H:%M:%S")) # show date and time video = cv2.putText(frame,date_time,(30,400),font,1,(0,0,255),2,cv2.LINE_AA) faces = cv2.CascadeClassifier('haarcascade_frontalface_default.xml').detectMultiScale(frame, 1.1, 4) for(x,y,w,h) in faces: cv2.rectangle(frame , (x,y) , (x+w , y+h) , (255,0,0) , 3)
cv2.imshow('Face Detection' , frame)
out.write(frame)
if(cv2.waitKey(1) == ord('q')):
break
cap.release() out.release() cv2.destroyAllWindows()