후처리 모듈 및 메인 서버 전달을 위한 수정 1. ITS cctv 스트리밍 정보를 하나의 프로세스가 하나의 영상을 담당하여 처리 및 실행하기 위한 스크립트와 bash 스크립트 2. FrameCapturer 객체에 위경도 정보 필수 arg
1. ITS cctv 스트리밍 정보를 하나의 프로세스가 하나의 영상을 담당하여 처리 및 실행하기 위한 스크립트와 bash 스크립트 2. FrameCapturer 객체에 위경도 정보 필수 arg
@c6b375d9b9e56f85998c7afa187b46bf5d0601ec
--- ITS_api_test.py
+++ ITS_api_test.py
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 |
lon = df.loc[0]["coordy"] |
10 | 10 |
apiKey = os.getenv("ITS_API") |
11 | 11 |
lat_lon_interval = 0.000001 |
12 |
-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) |
|
12 |
+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) |
|
13 | 13 |
|
14 | 14 |
name_of_requested = api_result.loc[0]["cctvname"] |
15 | 15 |
|
--- hls_streaming/hls.py
+++ hls_streaming/hls.py
... | ... | @@ -10,10 +10,21 @@ |
10 | 10 |
|
11 | 11 |
|
12 | 12 |
class FrameCapturer: |
13 |
- 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"): |
|
13 |
+ def __init__( |
|
14 |
+ self, |
|
15 |
+ hls_url, |
|
16 |
+ cctv_name, |
|
17 |
+ lat, |
|
18 |
+ lon, |
|
19 |
+ interval=5, |
|
20 |
+ buffer_duration=15, |
|
21 |
+ buffer_size=600, |
|
22 |
+ time_zone="Asia/Seoul", |
|
23 |
+ endpoint="http://localhost:12345/cctv/infer" |
|
24 |
+ ): |
|
14 | 25 |
''' |
15 | 26 |
:param hls_url: hls address |
16 |
- :param cctv_id: cctv_id number(whatever it is, this exists to distinguish from where. Further disscusion is needed with frontend developers.) |
|
27 |
+ :param cctv_name: CCTV_name gathered from ITS api |
|
17 | 28 |
:param interval: interval of sampling in seconds |
18 | 29 |
:param buffer_duration: video buffer, 15 seconds is default for ITS HLS video streaming |
19 | 30 |
:param time_zone: default Asia/Seoul |
... | ... | @@ -36,9 +47,12 @@ |
36 | 47 |
self.fps = self.video_stream.guessed_rate.numerator |
37 | 48 |
self.capture_interval = 1 / self.fps |
38 | 49 |
|
39 |
- self.cctvid = cctv_id |
|
50 |
+ self.cctvid = cctv_name |
|
40 | 51 |
self.time_zone = ZoneInfo(time_zone) |
41 | 52 |
self.endpoint = endpoint |
53 |
+ |
|
54 |
+ self.lat = lat |
|
55 |
+ self.lon = lon |
|
42 | 56 |
|
43 | 57 |
def __call__(self, *args, **kwargs): |
44 | 58 |
return self.current_frame |
... | ... | @@ -85,8 +99,8 @@ |
85 | 99 |
'Content-Type': f'image/{image_type}', |
86 | 100 |
'x-time-sent': time_sent, |
87 | 101 |
'x-cctv-info': str(self.cctvid), |
88 |
- 'x-cctv-latitude' : '', |
|
89 |
- 'x-cctv-longitude' : '', |
|
102 |
+ 'x-cctv-latitude' : self.lat, |
|
103 |
+ 'x-cctv-longitude' : self.lon, |
|
90 | 104 |
} |
91 | 105 |
session = requests.Session() |
92 | 106 |
try: |
--- hls_streaming/streaming_process.py
+++ hls_streaming/streaming_process.py
... | ... | @@ -18,11 +18,11 @@ |
18 | 18 |
import time |
19 | 19 |
|
20 | 20 |
|
21 |
- def refresh_hls_address(lat, lon, lat_lon_interval=0.000001): |
|
21 |
+ def refresh_hls_address(lat, lon, lat_lon_interval=0.00001): |
|
22 | 22 |
api_result = gather_cctv_list( |
23 | 23 |
xmin=lat - lat_lon_interval, ymin=lon - lat_lon_interval, |
24 | 24 |
xmax=lat + lat_lon_interval, ymax=lon + lat_lon_interval, |
25 |
- intervals=1, roadType=1, cctvType=1 |
|
25 |
+ intervals=1, roadType="its", cctvType=1 |
|
26 | 26 |
) |
27 | 27 |
return api_result.loc[0]["cctvurl"] |
28 | 28 |
|
... | ... | @@ -51,6 +51,6 @@ |
51 | 51 |
endpoint= "http://localhost:12345/cctv/infer") |
52 | 52 |
hls_streaming.start() |
53 | 53 |
|
54 |
- time.wait(60000) |
|
54 |
+ time.sleep(60000) |
|
55 | 55 |
|
56 | 56 |
hls_streaming.stop() |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?