윤영준 윤영준 05-20
후처리 모듈 및 메인 서버 전달을 위한 수정 1. ITS cctv 스트리밍 정보를 하나의 프로세스가 하나의 영상을 담당하여 처리 및 실행하기 위한 스크립트와 bash 스크립트 2. FrameCapturer 객체에 위경도 정보 필수 arg
1. ITS cctv 스트리밍 정보를 하나의 프로세스가 하나의 영상을 담당하여 처리 및 실행하기 위한 스크립트와 bash 스크립트
2. FrameCapturer 객체에 위경도 정보 필수 arg
@c6b375d9b9e56f85998c7afa187b46bf5d0601ec
ITS_api_test.py
--- ITS_api_test.py
+++ ITS_api_test.py
@@ -9,7 +9,7 @@
 lon = df.loc[0]["coordy"]
 apiKey = os.getenv("ITS_API")
 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)
+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)
 
 name_of_requested = api_result.loc[0]["cctvname"]
 
hls_streaming/hls.py
--- hls_streaming/hls.py
+++ hls_streaming/hls.py
@@ -10,10 +10,21 @@
 
 
 class FrameCapturer:
-    def __init__(self, hls_url, cctv_id, interval=5, buffer_duration=15, buffer_size=600, time_zone="Asia/Seoul", endpoint="http://localhost:12345/cctv/infer"):
+    def __init__(
+            self,
+            hls_url,
+            cctv_name,
+            lat,
+            lon,
+            interval=5,
+            buffer_duration=15,
+            buffer_size=600,
+            time_zone="Asia/Seoul",
+            endpoint="http://localhost:12345/cctv/infer"
+    ):
         '''
         :param hls_url: hls address
-        :param cctv_id: cctv_id number(whatever it is, this exists to distinguish from where. Further disscusion is needed with frontend developers.)
+        :param cctv_name: CCTV_name gathered from ITS api
         :param interval: interval of sampling in seconds
         :param buffer_duration: video buffer, 15 seconds is default for ITS HLS video streaming
         :param time_zone: default Asia/Seoul
@@ -36,9 +47,12 @@
         self.fps = self.video_stream.guessed_rate.numerator
         self.capture_interval = 1 / self.fps
 
-        self.cctvid = cctv_id
+        self.cctvid = cctv_name
         self.time_zone = ZoneInfo(time_zone)
         self.endpoint = endpoint
+
+        self.lat = lat
+        self.lon = lon
 
     def __call__(self, *args, **kwargs):
         return self.current_frame
@@ -85,8 +99,8 @@
             'Content-Type': f'image/{image_type}',
             'x-time-sent': time_sent,
             'x-cctv-info': str(self.cctvid),
-            'x-cctv-latitude' : '',
-            'x-cctv-longitude' : '',
+            'x-cctv-latitude' : self.lat,
+            'x-cctv-longitude' : self.lon,
         }
         session = requests.Session()
         try:
hls_streaming/streaming_process.py
--- hls_streaming/streaming_process.py
+++ hls_streaming/streaming_process.py
@@ -18,11 +18,11 @@
     import time
 
 
-    def refresh_hls_address(lat, lon, lat_lon_interval=0.000001):
+    def refresh_hls_address(lat, lon, lat_lon_interval=0.00001):
         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
+            intervals=1, roadType="its", cctvType=1
         )
         return api_result.loc[0]["cctvurl"]
 
@@ -51,6 +51,6 @@
                                       endpoint= "http://localhost:12345/cctv/infer")
         hls_streaming.start()
 
-        time.wait(60000)
+        time.sleep(60000)
 
         hls_streaming.stop()
Add a comment
List