def __init__(self, seismometer_id, directory): self.seismometer_id = seismometer_id self.directory = directory self.last_saved_hour = datetime.today().hour self.last_saved_minute = datetime.today().minute self.stream_manager = StreamManager(self.directory / MSEED_FILES_DIRECTORY) self.stream_plotter = StreamPlotter(self.directory / IMAGE_FILES_DIRECTORY)
MODEL_DIR = 'model' UPLOAD_INTERVAL = 1 # sec DETECTION_TYPE_NOTHING = 'nothing' DETECTION_TYPE_SUCCESS = 'success' DETECTION_TYPE_UNIDENTIFIED = 'unidentified' DETECTION_BUFFER_SIZE = 10000 IMG_WIDTH = 960 IMG_HEIGHT = 540 # Main thread onnx = ONNXRuntimeModelDeploy() stream_manager = StreamManager(onnx) app = Flask(__name__) @app.route('/prediction', methods=['GET']) def prediction(): # print(onnx.last_prediction) # onnx.last_prediction cam_id = request.args.get('cam_id') s = stream_manager.get_stream_by_id(cam_id) return json.dumps(s.last_prediction) @app.route('/metrics', methods=['GET'])
import asyncio import logging import signal import threading import cv2 import requests import uvicorn from fastapi import FastAPI from pydantic import BaseModel from stream_manager import StreamManager logger = logging.getLogger(__name__) stream_manager = StreamManager() app = FastAPI() class Stream(BaseModel): stream_id: str rtsp: str fps: float endpoint: str @app.get("/") async def index(): # FIXME number_of_streams = 0 infos = [] for stream in stream_manager.get_streams():
def __init__(self, asm_file): self.stream_manager = StreamManager(asm_file)
from stream_manager import StreamManager sm = StreamManager() from flask import Flask, request, render_template, jsonify import json app = Flask(__name__) @app.route('/') def main_page(): return render_template('index.html') @app.route('/control', methods=['POST']) def radio_control(): ret = {} if request.method == 'POST': data = request.get_json() if data['submit'] == 'Play': print('play') sm.play_stream() print(sm.get_current_radio()) ret['response'] = sm.get_current_radio() elif data['submit'] == 'Stop': print('stop') sm.stop_stream() ret['response'] = sm.get_current_radio() if data['submit'] == 'Previous': print('previous') sm.select_stream(False)
import time # initialize the output frame and a lock used to ensure thread-safe # exchanges of the output frames (useful when multiple browsers/tabs are viewing the stream) camera_id = 1 lock = threading.Lock() # Initialize a flask object app = Flask(__name__) # Init Stream Manager camera_streams_urls = [ "rtmp://62.113.210.250/medienasa-live/rbw_high", "rtmp://62.113.210.250/medienasa-live/rbw_high" ] stream_manager = StreamManager(camera_streams_urls) class CameraStream: def __init__(self, id, url): self.id = id self.vcap = cv2.VideoCapture(url) # Function thaat takes in frame and proccess frames def process_frame(camera, frame): #TODO - Run Yolo model here # Right now displaying frame for testing purposes if camera == 1: