# This script only works if this is the main process. # This script must be executed with bash script that is located in the root directory of this project # This is by design, and is a way to circumvent GIL of python, because the server needs to handle multiple video streaming at once. if __name__ == "__main__": from ITS.api import gather_cctv_list from hls_streaming.hls import FrameCapturer import argparse import pandas as pd import time def refresh_hls_address(lat, lon, lat_lon_interval=0.000001): api_result = gather_cctv_list( xmin=lat - lat_lon_interval, ymin=lon - lat_lon_interval, xmax=lat + lat_lon_interval, ymax=lon + lat_lon_interval, intervals=1, roadType="its", cctvType=1 ) return api_result.loc[0]["cctvurl"] args = argparse.ArgumentParser() args.add_argument("--cctv_num", type=int, help="index number of cctv, see cctv_list.csv") args = args.parse_args() cctv_ind = args.cctv_num cctv_info = pd.read_csv("config_files/cctv_list.csv") cctv_info = cctv_info.iloc[cctv_ind] lat = cctv_info["coordx"] lon = cctv_info["coordy"] name = cctv_info["cctvname"] if name.find("국도"): roadtype = 'its' else: roadtype = 'ex' # initiate ITS CCTV streaming via hls while True: cctv_url = refresh_hls_address(lat, lon, ) print(name) hls_streaming = FrameCapturer(cctv_url, name, lat, lon, 5, 15, 300, "Asia/Seoul", endpoint= "http://localhost:12345/cctv/infer") hls_streaming.start() time.sleep(60000) hls_streaming.stop()