윤영준 윤영준 05-20
ITS url 생성 애러 수정 (인자 이름이 type인데 roadType이었음.)
@4869d8f7cdddd4e65a7c060cf7afdee5f1fc708d
ITS/api.py
--- ITS/api.py
+++ ITS/api.py
@@ -30,7 +30,7 @@
     return (
         f"{baseurl}?"
         f"apiKey={apiKey}&"
-        f"roadType={roadType}&"
+        f"type={roadType}&"
         f"cctvType={cctvType}&"
         f"minX={minX}&maxX={maxX}&minY={minY}&maxY={maxY}&"
         f"getType={getType}"
@@ -92,6 +92,6 @@
 
 
 if __name__ == "__main__":
-    df = gather_cctv_list(129.2, 129.3, 35.9, 36.07, 1, 1)
+    df = gather_cctv_list(129.2, 129.3, 35.9, 36.07, 1, "its", 1)
     pass
     # get_jpeg("http://cctvsec.ktict.co.kr:8090/74236/IM2NQs4/uHZcgnvJo3V/mjo3tswwgUj87kpcYZfR/BPxaQ4lk9agnl8ARIB9lhlgOD87VBx6RDHFl423kLkqHQ==")
(파일 끝에 줄바꿈 문자 없음)
 
config/cctv_list.csv (added)
+++ config/cctv_list.csv
@@ -0,0 +1,3 @@
+,roadsectionid,coordx,coordy,cctvresolution,filecreatetime,cctvtype,cctvformat,cctvname,cctvurl
+0,,129.245312,35.920346,,,1,HLS,[국도 7호선] 모아초교,http://cctvsec.ktict.co.kr/4463/6SqphQj32sxeB2nYIMerulhkk0HdDKP/aSEgp7hHbUY9iwTDb+UQZfTbag9pXmM/yo3a7l1usm64GwBH77/SCVEel3JF3g9BZDc+ws1es2w=
+1,,129.2005,35.921825,,,1,HLS,[국도20호선] 검단산업단지,http://cctvsec.ktict.co.kr/71187/bWDrL7fpStZDeDZgCybpJH8gagWJOynbaA/l91ExpmUPKzc3bCsHJtIblDkzG3TfmkwkLj7+PPdYAHSYBXxem4SZJpaAYFU0CtDtr5rz7DY=(파일 끝에 줄바꿈 문자 없음)
 
config/cctv_lists.csv (deleted)
--- config/cctv_lists.csv
@@ -1,0 +0,0 @@
hls_streaming/hls.py
--- hls_streaming/hls.py
+++ hls_streaming/hls.py
@@ -1,4 +1,3 @@
-import parser
 import time
 import av
 import cv2
hls_streaming/streaming_process.py
--- hls_streaming/streaming_process.py
+++ hls_streaming/streaming_process.py
@@ -1,14 +1,56 @@
-from ITS.api import gather_cctv_list
-from hls_streaming.hls import FrameCapturer
-
-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=1)
-    return api_result.loc[0]["cctvurl"]
+# 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 dotenv import load_dotenv
+    import os
+
+    load_dotenv()
+    print("PYTHONPATH:", os.getenv("PYTHONPATH"))
+    print("_____")
+    print(os.path.dirname(os.path.abspath(__file__)))
+    from ITS.api import gather_cctv_list
+    from hls_streaming.hls import FrameCapturer
+
     import argparse
-    args = argparse.ArgumentParser
-    args.add_argument("cctv_num", help="index number of cctv, see cctv_list.csv")
+    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=1, 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/cctv_list.csv")
+    cctv_info = cctv_info.iloc[0]
+
+    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, )
+        hls_streaming = FrameCapturer(cctv_url, name, 5, 15, 300, "Asia/Seoul",
+                                      endpoint= "http://localhost:12345/cctv/infer")
+        hls_streaming.start()
+
+        time.wait(60000)
+
+        hls_streaming.stop()
Add a comment
List