From 824796b7e37709e8728c8098989cdebefd95c110 Mon Sep 17 00:00:00 2001 From: za_litvu Date: Mon, 12 May 2025 07:41:40 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=B0=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 11 ++++++----- app/ml/streaming.py | 15 +++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.env b/.env index ca63f9e..e0b7be0 100644 --- a/.env +++ b/.env @@ -1,10 +1,11 @@ -RTSP_URL=rtsp://192.168.0.169:8554/cam +RTSP_URL=rtsp://192.168.31.56:8554/cam -# MODEL_NAME=kpp\yolo11n 10epochs\yolo11n_10epochs.pt -YOLO_MODEL=/home/app/ml/models/kpp/yolo11n_10_epochs/yolo11n_10epochs.pt +# YOLO_MODEL=/home/app/ml/models/kpp/yolo11n_10_epochs/yolo11n_10epochs.pt +YOLO_MODEL=C:\project\kpp\app\ml\models\kpp\yolo11n_10_epochs\yolo11n_10epochs.pt -WEB_IP_ADDR=192.168.0.169:8000 +WEB_IP_ADDR=192.168.31.56:8001 WEB_TOKEN=local-test-key -REDIS_HOST=192.168.0.169 +REDIS_HOST=192.168.31.56 REDIS_PORT=6379 + diff --git a/app/ml/streaming.py b/app/ml/streaming.py index 772dc85..39ac8b2 100644 --- a/app/ml/streaming.py +++ b/app/ml/streaming.py @@ -123,11 +123,10 @@ def json_packer(type, data: BaseData): def server_ping(): try: - print(data) - url = f"http://{ip_addr_web}/api/recieve/" + url = f"http://{ip_addr_web}/start_recieve" headers = { - 'Authorization': f'{token}', + 'Authorization': f'', 'Content-Type': 'application/json' } @@ -143,9 +142,8 @@ def server_ping(): def data_upload_redis(value, key='ai_recieve'): try: value = json.dumps(value) + print(value) redis_con.lpush(key, value) - if redis_con.llen(key)%100==0: - server_ping() except Exception as e: error_msg = f"Ошибка {str(e)}" @@ -171,6 +169,7 @@ container = av.open( video = container.demux(video=0) video_stream = next(s for s in container.streams if s.type == 'video') +server_ping() for packet in container.demux(video_stream): for frame in packet.decode(): if 'start_time' not in locals(): @@ -184,7 +183,7 @@ for packet in container.demux(video_stream): img = frame.to_ndarray(format='bgr24') results = model.predict(img) data = {'pts': pts, - 'content': [], + 'content': {'content': []}, 'plate_text': []} for result in results: for box in result.boxes: @@ -193,7 +192,7 @@ for packet in container.demux(video_stream): if box.cls == 0 and box.conf >= 0.2: text = paddle_ocr(img, x1, y1, x2, y2) plate = Plate(text, x1, y1, x2, y2) - data['content'].append(json_packer(int(box.cls), plate)) + data['content']['content'].append(json_packer(int(box.cls), plate)) data['plate_text'].append(text) # cv2.rectangle(img, (int(x1), int(y1)), (int(x2), int(y2)), (0, 0, 255), 2) @@ -201,7 +200,7 @@ for packet in container.demux(video_stream): # выводит данные о классе 'car' elif box.cls == 1 and box.conf >= 0.50: car = Car(x1, y1, x2, y2) - data['content'].append(json_packer(int(box.cls), car)) + data['content']['content'].append(json_packer(int(box.cls), car)) # cv2.rectangle(img, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2) data_upload_redis(data)