Spaces:
Sleeping
Sleeping
Fedgo29 commited on
Commit ·
32a4579
1
Parent(s): fc04bc0
Adding changes by Fedgo 25-6-2025 11:23 PM
Browse filesFiles changed (4)
185 unmodified lines18618718818918919019119210 unmodified lines203204205206206207208209185 unmodified lines
@app.route('/frame/<int:cam_id>', methods=['GET'])def get_frame(cam_id): global cameras, fall_detector_core, cameras_ready, email_actual_user global cameras, fall_detector_core, cameras_ready, email_actual_user, id_user
wait_time = 0 while not cameras_ready and wait_time < 5:10 unmodified lines if not cap.isOpened(): return jsonify({"error": "La cámara no está abierta"}), 500
frame = fall_detector_core.process_frame(cap, email_actual_user, cam_id) frame = fall_detector_core.process_frame(cap, email_actual_user, cam_id, id_user)
if frame is None or frame.size == 0: frame = np.zeros((480, 640, 3), dtype=np.uint8)100 unmodified lines10110210310410410510610610710810928 unmodified lines13813914014114114214314314414514676 unmodified lines22322422522622622722822822923023135 unmodified lines267268269270270271272273122 unmodified lines3963973983993994004014024014024034044058 unmodified lines414415416417417418419420421422423424100 unmodified lines except Exception as e: print("Error inesperado:", e) def setfalllogtoDB(self, resident_id, email: str, precision_value, cam_id: int): def setfalllogtoDB(self, resident_id, email: str, precision_value, cam_id: int, user_id: int): try: usuario_id = self.getLastSessionOfActualUser(email) usuario_id = user_id #self.getLastSessionOfActualUser(email) fecha_hora_ingreso = datetime.now() ubicacion = "No especificada" detectado_por = "Sistema"28 unmodified lines except Exception as e: print("Error inesperado:", e)
def setResidentToDB(self, residente_id, nombre, edad, genero, habitacion, color_de_ropa, email: str, id_camera: int): def setResidentToDB(self, residente_id, nombre, edad, genero, habitacion, color_de_ropa, email: str, id_camera: int, id_user: int): try: usuario_id = self.getLastSessionOfActualUser(email) usuario_id = id_user #self.getLastSessionOfActualUser(email) fecha_ingreso = datetime.now().strftime("%Y-%m-%d %H:%M:%S") if usuario_id is None: print("No se encontró una sesión activa para el usuario con ese email.")76 unmodified lines print("❌ Error inesperado en get_db_lastcamera:", e) return 0
def setnotificationlogtoDB(self, email: str, resident_id, id_camara: int): def setnotificationlogtoDB(self, email: str, resident_id, id_camara: int, user_id): try: usuario_id = self.getLastSessionOfActualUser(email) usuario_id = user_id#self.getLastSessionOfActualUser(email) titulo = "Caída detectada" mensaje = "Se detectó una caída" caida_id = self.getfallIdDB(email)35 unmodified lines """ return np.array([lm.x, lm.y, lm.z]) def process_frame(self, cap, email: str, cam_id: int): def process_frame(self, cap, email: str, cam_id: int, user_id: int): pid = 0 #Procesa un frame de video, detecta personas, estima pose y evalúa caídas. ret, frame = cap.read()122 unmodified lines self.people[pid]["fall_time"] = time.time() self.people[pid]["fall_detected"] = True if(not self.getCheckResidentInDB(pid)): self.setResidentToDB(pid, "No definido", 0, "No definido", "No definida", "No definida", email, cam_id) self.setResidentToDB(pid, "No definido", 0, "No definido", "No definida", "No definida", email, cam_id, id_user=user_id) #self.setlogtoDB(pid, "Not set yet", email) self.setfalllogtoDB(pid, email, prediction) self.setnotificationlogtoDB(email, pid, id_camara= cam_id) self.setfalllogtoDB(pid, email, prediction, cam_id, user_id) self.setnotificationlogtoDB(email, pid, id_camara= cam_id, user_id=user_id) else: self.people[pid]["fall_detected"] = False self.people[pid]["fall_time"] = None8 unmodified lines if elapsed_time >= 1: self.setfalsesToDB("Falso Negativo", prediction, email) if(self.getCheckResidentInDB(pid)): self.setfalllogtoDB(pid, email, prediction, cam_id, user_id) self.setnotificationlogtoDB(email, pid, id_camara= cam_id) self.setnotificationlogtoDB(email, pid, id_camara= cam_id, user_id=user_id) else: if self.people[pid]["fall_detected"]: self.setfalllogtoDB(pid, email, prediction, cam_id, user_id) self.setfalsesToDB("Falso Positivo", prediction, email)
return frame12323version https://git-lfs.github.com/spec/v1oid sha256:5e77828de1723ff7e69172ba5672337ab10920379ce9b232abf288425eff90basize 53248oid sha256:72f8dddaf85f0e7f521b31bcbe88b80c45a8227b82e567258b6029a689c003f5size 73728app.py+2-2
core/__pycache__/fall_detector_core.cpython-310.pyc
core/fall_detector_core.py+13-11
guardiancare.db+2-2