def main_loop(): frame, face_data = acquire_frame(detector, embedder, vs, recognizer, le, 0.5, 0.65) for item in face_data: frame = draw_frame(frame, item) show_frame(frame)
def main_core(detector, embedder, recognizer, le, frame_queue, pframe_queue): print('[INFO] Starting:', mp.current_process().name) # time.sleep(1.0) # initialize the video stream, then allow the camera sensor to warm up ## Set Threding to start filming video_getter = VideoGet(frame_queue=frame_queue, src=0, name='Video Getter') time.sleep(1.0) # print('[INFO] Starting VideoGet...') video_getter.start() time.sleep(1.0) cpt = 0 exitbool = False fps_count = FPS(2).start() while True: frame = video_getter.frame.copy() fps_count.istime( ) # Calculate if enough time has passed for process the frame if fps_count.boolFrames: fps_count.updateactualtime() # Update the comparison time face_data = acquire_frame(detector, embedder, frame, recognizer, le, 0.5, 0.65) #,fa) pframe_queue.put(face_data) for item in face_data: # print(item[2:]) frame = draw_frame(frame, item) fps_count.update() # cpt +=1 exitbool = show_frame(frame) if exitbool or cpt == 80: # fps_count.stop() print("[INFO] elasped time fps processed: {:.2f}".format( fps_count.elapsed())) print("[INFO] approx. processed FPS: {:.2f}".format( fps_count.fps())) time.sleep(1) video_getter.stop() time.sleep(2) print('[INFO] Exiting :', mp.current_process().name) break
## Set ffmeg instance pathIn= './videorecordings/' # pathIn = './videorecordings/' + str(datetime.datetime.now().hour) + '/' ## REVISAR SI HAY UN FORMATO QUE SEA MAS COMPRIMIMDO pathOut = '/video_v1.avi' fps = 25 SV = SaveVideo(name='VideoWriter', vg=video_getter, pathIn=pathIn, pathOut=pathOut, fps=fps, encode_quality=95) print('[INFO] Starting saving Video...') SV.start() cpt=0; fps_count = FPS().start() while True: frame = video_getter.frame.copy() time.sleep(1) fps_count.update() exitbool = show_frame(frame) # cpt += 1 if exitbool or cpt > 100: SV.stop() fps_count.stop() print("[INFO] elasped time fps processed: {:.2f}".format(fps_count.elapsed())) print("[INFO] approx. processed FPS: {:.2f}".format(fps_count.fps())) time.sleep(1) video_getter.stop() # db_client.close() break
print('Prepare imagen') input('Presione cualquier boton') for j in range(4): for i in range(frames_per_person): frame = video_getter.frame.copy() #frame = imutils.resize(frame, width=500) detections = get_faces(detector, embedder, sp, frame, confianza_dec, fa) #[(face,vector,coordenada,imagen_completa)] face_data = [(*face, *recognize(face[1], recognizer, le, confianza_recon)) for face in detections] #[(face,vector,coordenada,imagen_completa, nombre, prob)] for item in face_data: print(item[4]) if item[4] == name: Coincidencias += 1 Caras += 1 show_frame(frame) fps_count.update() input('Cambio de foto') calculos[name] = (Coincidencias, Caras) print(calculos) fps_count.stop() print("[INFO] elasped time fps processed: {:.2f}".format(fps_count.elapsed())) print("[INFO] approx. processed FPS: {:.2f}".format(fps_count.fps())) time.sleep(1) video_getter.stop()