Commit b117ac95 authored by Ishankha K.C's avatar Ishankha K.C

use multiple devices

parent 7418010a
......@@ -4,10 +4,11 @@ import traceback
import cv2
import numpy as np
import logging
from fastapi import FastAPI, WebSocket
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from keras.models import load_model
from keras.utils import img_to_array
import urllib.request
from urllib.error import URLError
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
......@@ -31,12 +32,13 @@ for class_name, index in class_indices.items():
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
# Replace with your IP camera stream URL
url = 'http://192.168.1.7/cam-hi.jpg'
base_dev_url = 'http://192.168.1.7/'
img_endpoint = '/cam-hi.jpg'
@app.websocket("/ws/emotion")
async def websocket_endpoint(websocket: WebSocket):
@app.websocket("/ws/emotion/{device_uid}")
async def websocket_endpoint(websocket: WebSocket, device_uid: str):
await websocket.accept()
url = base_dev_url+device_uid+img_endpoint
try:
while True:
try:
......@@ -87,7 +89,8 @@ async def websocket_endpoint(websocket: WebSocket):
"y": int(y),
"width": int(w),
"height": int(h)
}
},
"error": False
})
logging.info(f"Detected emotions: {emotions}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment