I’m doing face recognition with python opencv. I will run this project on a server. When running on my computer, there is a delay of more than 10 seconds and fps drops. To solve this, I took the last frame and made it skip the following frames. Now the image is skipping. How can I make it more fluent? The camera I use is Hikvision. No face recognition feature.
ip='rtsp://admin:@10.29.214.120'
cap = cv2.VideoCapture(1)
i,j = 0,0
while 1:
_,frame = cap.read()
faces = extract_faces(frame)
for (x,y,w,h) in faces:
cv2.rectangle(frame,(x, y), (x+w, y+h), (255, 0, 20), 2)
cv2.putText(frame,f'Images Captured: {i}/100',(50,50),cv2.FONT_HERSHEY_SIMPLEX,1,(255, 0, 20),2,cv2.LINE_AA)
if j%10==0:
name = newusername+'_'+str(i)+'.jpg'
cv2.imwrite(userimagefolder+'/'+name,frame[y:y+h,x:x+w])
i+=1
j+=1
if j==1000:
break
cv2.imshow('Adding new User',frame)
if cv2.waitKey(1)==27:
break
cap.release()
cv2.destroyAllWindows()
print('Training Model')
train_model()