Im using the following code to count the number of people in realtime webcam from morning till night
people_list = []
while True:
_, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(gray, 1.3, 5)
detections = faceCascade.detectMultiScale(gray, 1.15, 5)
for i in range(len(detections)):
face_i = detections[i]
x, y, w, h = face_i
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 222, 0), 1)
font = cv2.FONT_HERSHEY_SIMPLEX
people_list.insert(len(people_list)+1,i)
cv2.putText(frame, "id: "+str ( people_list[i]), (x, y), font, 2, (255, 255, 255), 2, cv2.LINE_AA)
# Display the resulting frame
cv2.imshow('Video', frame)
everytime when a new face is detected, the people_list count increases. However, the people_list count is being increased for every frame instead of every new faces. How can I be able to sort this out?