From c02827f4cdf0c6000055f79b46e5f5921f1951e8 Mon Sep 17 00:00:00 2001 From: nicorossini Date: Fri, 2 Feb 2024 11:31:42 +0100 Subject: [PATCH] delete send_frame.py --- ImageRecognition/send_frame.py | 59 ---------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 ImageRecognition/send_frame.py diff --git a/ImageRecognition/send_frame.py b/ImageRecognition/send_frame.py deleted file mode 100644 index 8a9f135..0000000 --- a/ImageRecognition/send_frame.py +++ /dev/null @@ -1,59 +0,0 @@ -import cv2 -import socketio -import threading - -#cameras data -cameras = { - '1': 'rtsp://192.168.1.41:80/ch0_0.264', - '2': 'rtsp://192.168.1.41:80/ch1_0.264', - '3': 'rtsp://192.168.1.41:80/ch2_0.264', - '4': 'rtsp://192.168.1.41:80/ch3_0.264', - '5': 'rtsp://192.168.1.41:80/ch4_0.264', - '6': 'rtsp://192.168.1.41:80/ch5_0.264', - '7': 'rtsp://192.168.1.41:80/ch6_0.264', - '8': 'rtsp://192.168.1.41:80/ch7_0.264', -} - -# Server settings -server_url = 'http://localhost:8080' - -sio = socketio.Client() - -def convert_frame(frame): - jpeg_frame = cv2.imencode('.jpg', frame)[1].tobytes() - return jpeg_frame - - -def send_frames(camera_id, capture, interval=0.1): - while True: - ret, frame = capture.read() - if ret: - - frame_conv = convert_frame(frame) - - sio.emit('message', {'id': camera_id, 'data': frame_conv}) - sio.sleep(interval) - - - -for camera_id, camera_url in cameras.items(): - capture = cv2.VideoCapture(camera_url) - if not capture.isOpened(): - print(f"Error stream with camera {camera_id}") - continue - - threading.Thread(target=send_frames, args=(camera_id, capture)).start() - - -@sio.event -def connect(): - print("Server connected") - -@sio.event -def disconnect(): - print("Server disconnected") - -sio.connect(server_url, transports=['websocket']) - -sio.wait() -