윤영준 윤영준 05-08
First Commit
@24d2cdc31f25264b30387f0faf9e26400a63144e
 
ITS/api.py (added)
+++ ITS/api.py
@@ -0,0 +1,82 @@
+import json
+import time
+import cv2
+import requests
+import pandas as pd
+import os
+import numpy as np
+from dotenv import load_dotenv
+
+
+def create_url(apiKey, type, cctvType, minX, maxX, minY, maxY, getType="json",
+               baseurl="https://openapi.its.go.kr:9443/cctvInfo"):
+    '''
+    국가교통정보센터 예제 실행
+    https://www.its.go.kr/opendata/openApiEx?service=cctv 참고
+    :param apiKey: ``str`` 국가교통정보센터에서 발급받은 api 키
+    :param type: ``str`` 도로 유형 ('ex' : 고속도로, 'its' : 국도)
+    :param cctvType: ``int`` CCTV 유형 (1. 실시간 스트리밍(HLS) / 2. 동영상 파일(m3u8) / 3. 정지 영상(JPEG))
+    :param minX: 최소 경도 영역
+    :param maxX: 최대 경도 영역
+    :param minY: 최소 위도 영역
+    :param maxY: 최대 경도 영역
+    :param getType: 출력 결과 형식 ("xml" or "json")
+    :return: api 요청 url
+    '''
+    assert type != "ex" or "its", 'Error! type should be either "ex" or "its"'
+    assert cctvType != 1 or 2 or 3, 'Error! cctvType should be one of 1, 2, 3!'
+    assert getType != "json" or "xml", 'Error! gettype should be either "json" or "xml"!'
+
+    return (
+        f"{baseurl}?"
+        f"apiKey={apiKey}&"
+        f"type={type}&"
+        f"cctvType={cctvType}&"
+        f"minX={minX}&maxX={maxX}&minY={minY}&maxY={maxY}&"
+        f"getType={getType}"
+    )
+
+def gather_cctv_list(xmin, xmax, ymin, ymax, intervals, cctvtype):
+    dotenv = load_dotenv()
+    apiKey= os.getenv("ITS_API")
+    x_values = np.linspace(xmin, xmax, intervals+1)
+    y_values = np.linspace(ymin, ymax, intervals+1)
+
+    all_data_df = pd.DataFrame()
+
+    for i in range(len(x_values) - 1):
+        for j in range(len(y_values) - 1):
+            x = x_values[i]
+            y = y_values[j]
+
+            x_next = x_values[i + 1]
+            y_next = y_values[j + 1]
+
+            url = create_url(apiKey, 'its', cctvtype,
+                             x, x_next, y, y_next)
+            response = requests.get(url)
+            response_json = json.loads(response.text)
+            if response_json['response']['datacount'] == 1:
+                new_df = pd.json_normalize(response_json['response']['data'])
+                all_data_df = pd.concat([all_data_df, new_df], ignore_index=True)
+                # df.to_csv(f"result/pohang/listofcctv_포항_{x}_{y}.csv", index=False)
+            elif response_json['response']['datacount'] != 0:
+                new_df = pd.DataFrame(response_json['response']['data'])
+                all_data_df = pd.concat([all_data_df, new_df], ignore_index=True)
+                # df.to_csv(f"result/pohang/listofcctv_포항_{x}_{y}.csv", index=False)
+            time.sleep(1)
+            print(f"{i}, {j}")
+    return all_data_df
+
+def get_jpeg(url):
+    response = requests.get(url)
+    encoded_img = np.frombuffer(response.content, dtype=np.uint8)
+    img = cv2.imdecode(encoded_img, cv2.IMREAD_COLOR)
+    return img
+
+
+
+if __name__ == "__main__":
+    df = gather_cctv_list(129.28, 129.35, 35.999, 36.07, 1, 1)
+    pass
+    # get_jpeg("http://cctvsec.ktict.co.kr:8090/74236/IM2NQs4/uHZcgnvJo3V/mjo3tswwgUj87kpcYZfR/BPxaQ4lk9agnl8ARIB9lhlgOD87VBx6RDHFl423kLkqHQ==")(파일 끝에 줄바꿈 문자 없음)
 
README.md (added)
+++ README.md
@@ -0,0 +1,1 @@
+# 2024-솔팩SW시제품
 
hls_streaming/captured_frame_/2024-05-07 18:32:40.497320_captured_frame_0.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 18:32:40.497320_captured_frame_0.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 18:37:40.502782_captured_frame_1.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 18:37:40.502782_captured_frame_1.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 18:42:40.579021_captured_frame_2.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 18:42:40.579021_captured_frame_2.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 18:47:40.579907_captured_frame_3.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 18:47:40.579907_captured_frame_3.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 18:52:40.616010_captured_frame_4.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 18:52:40.616010_captured_frame_4.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 18:57:40.653891_captured_frame_5.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 18:57:40.653891_captured_frame_5.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:02:40.687858_captured_frame_6.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:02:40.687858_captured_frame_6.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:07:40.695026_captured_frame_7.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:07:40.695026_captured_frame_7.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:12:40.792749_captured_frame_8.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:12:40.792749_captured_frame_8.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:17:40.823494_captured_frame_9.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:17:40.823494_captured_frame_9.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:22:40.909893_captured_frame_10.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:22:40.909893_captured_frame_10.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:27:41.001104_captured_frame_11.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:27:41.001104_captured_frame_11.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:32:41.007518_captured_frame_12.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:32:41.007518_captured_frame_12.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:37:41.030042_captured_frame_13.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:37:41.030042_captured_frame_13.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:42:41.039646_captured_frame_14.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:42:41.039646_captured_frame_14.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:47:41.051450_captured_frame_15.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:47:41.051450_captured_frame_15.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:52:41.096156_captured_frame_16.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:52:41.096156_captured_frame_16.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 19:57:41.124661_captured_frame_17.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 19:57:41.124661_captured_frame_17.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:02:41.171300_captured_frame_18.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:02:41.171300_captured_frame_18.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:07:41.269192_captured_frame_19.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:07:41.269192_captured_frame_19.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:12:41.364544_captured_frame_20.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:12:41.364544_captured_frame_20.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:17:41.425624_captured_frame_21.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:17:41.425624_captured_frame_21.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:22:41.472469_captured_frame_22.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:22:41.472469_captured_frame_22.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:27:41.501834_captured_frame_23.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:27:41.501834_captured_frame_23.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:32:41.538025_captured_frame_24.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:32:41.538025_captured_frame_24.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:37:41.550344_captured_frame_25.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:37:41.550344_captured_frame_25.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:42:41.565371_captured_frame_26.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:42:41.565371_captured_frame_26.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:47:41.660797_captured_frame_27.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:47:41.660797_captured_frame_27.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:52:41.667282_captured_frame_28.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:52:41.667282_captured_frame_28.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 20:57:41.693692_captured_frame_29.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 20:57:41.693692_captured_frame_29.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:02:41.721790_captured_frame_30.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:02:41.721790_captured_frame_30.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:07:41.754760_captured_frame_31.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:07:41.754760_captured_frame_31.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:12:41.791607_captured_frame_32.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:12:41.791607_captured_frame_32.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:17:41.828643_captured_frame_33.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:17:41.828643_captured_frame_33.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:22:41.834543_captured_frame_34.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:22:41.834543_captured_frame_34.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:27:41.927953_captured_frame_35.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:27:41.927953_captured_frame_35.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:32:41.993226_captured_frame_36.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:32:41.993226_captured_frame_36.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:37:42.030863_captured_frame_37.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:37:42.030863_captured_frame_37.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:42:42.043692_captured_frame_38.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:42:42.043692_captured_frame_38.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:47:42.124020_captured_frame_39.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:47:42.124020_captured_frame_39.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:52:42.159839_captured_frame_40.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:52:42.159839_captured_frame_40.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 21:57:42.196815_captured_frame_41.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 21:57:42.196815_captured_frame_41.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:02:42.207873_captured_frame_42.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:02:42.207873_captured_frame_42.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:07:42.255001_captured_frame_43.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:07:42.255001_captured_frame_43.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:12:42.304034_captured_frame_44.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:12:42.304034_captured_frame_44.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:17:42.338696_captured_frame_45.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:17:42.338696_captured_frame_45.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:22:42.349684_captured_frame_46.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:22:42.349684_captured_frame_46.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:27:42.382503_captured_frame_47.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:27:42.382503_captured_frame_47.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:32:42.391337_captured_frame_48.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:32:42.391337_captured_frame_48.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:37:42.424517_captured_frame_49.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:37:42.424517_captured_frame_49.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:42:42.448217_captured_frame_50.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:42:42.448217_captured_frame_50.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:47:42.493646_captured_frame_51.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:47:42.493646_captured_frame_51.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:52:42.523427_captured_frame_52.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:52:42.523427_captured_frame_52.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 22:57:42.557813_captured_frame_53.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 22:57:42.557813_captured_frame_53.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:02:42.601307_captured_frame_54.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:02:42.601307_captured_frame_54.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:07:42.635126_captured_frame_55.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:07:42.635126_captured_frame_55.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:12:42.682218_captured_frame_56.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:12:42.682218_captured_frame_56.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:17:42.724449_captured_frame_57.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:17:42.724449_captured_frame_57.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:22:42.767956_captured_frame_58.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:22:42.767956_captured_frame_58.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:27:42.848590_captured_frame_59.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:27:42.848590_captured_frame_59.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:32:42.893293_captured_frame_60.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:32:42.893293_captured_frame_60.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:37:42.922747_captured_frame_61.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:37:42.922747_captured_frame_61.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:42:42.954281_captured_frame_62.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:42:42.954281_captured_frame_62.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:47:42.971019_captured_frame_63.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:47:42.971019_captured_frame_63.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:52:43.062536_captured_frame_64.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:52:43.062536_captured_frame_64.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-07 23:57:43.066043_captured_frame_65.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-07 23:57:43.066043_captured_frame_65.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:02:43.153025_captured_frame_66.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:02:43.153025_captured_frame_66.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:07:43.173694_captured_frame_67.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:07:43.173694_captured_frame_67.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:12:43.199560_captured_frame_68.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:12:43.199560_captured_frame_68.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:17:43.300925_captured_frame_69.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:17:43.300925_captured_frame_69.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:22:43.347876_captured_frame_70.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:22:43.347876_captured_frame_70.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:27:43.365754_captured_frame_71.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:27:43.365754_captured_frame_71.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:32:43.440897_captured_frame_72.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:32:43.440897_captured_frame_72.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:37:43.540462_captured_frame_73.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:37:43.540462_captured_frame_73.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:42:43.638664_captured_frame_74.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:42:43.638664_captured_frame_74.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:47:43.690263_captured_frame_75.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:47:43.690263_captured_frame_75.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:52:43.735337_captured_frame_76.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:52:43.735337_captured_frame_76.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 00:57:43.735970_captured_frame_77.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 00:57:43.735970_captured_frame_77.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:02:43.779411_captured_frame_78.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:02:43.779411_captured_frame_78.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:07:43.846346_captured_frame_79.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:07:43.846346_captured_frame_79.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:12:43.883210_captured_frame_80.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:12:43.883210_captured_frame_80.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:17:43.891351_captured_frame_81.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:17:43.891351_captured_frame_81.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:22:43.931253_captured_frame_82.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:22:43.931253_captured_frame_82.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:27:43.970761_captured_frame_83.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:27:43.970761_captured_frame_83.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:32:44.006982_captured_frame_84.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:32:44.006982_captured_frame_84.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:37:44.103114_captured_frame_85.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:37:44.103114_captured_frame_85.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:42:44.144241_captured_frame_86.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:42:44.144241_captured_frame_86.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:47:44.178473_captured_frame_87.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:47:44.178473_captured_frame_87.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:52:44.201132_captured_frame_88.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:52:44.201132_captured_frame_88.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 01:57:44.216987_captured_frame_89.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 01:57:44.216987_captured_frame_89.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:02:44.227948_captured_frame_90.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:02:44.227948_captured_frame_90.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:07:44.260602_captured_frame_91.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:07:44.260602_captured_frame_91.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:12:44.319142_captured_frame_92.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:12:44.319142_captured_frame_92.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:17:44.381586_captured_frame_93.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:17:44.381586_captured_frame_93.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:22:44.443666_captured_frame_94.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:22:44.443666_captured_frame_94.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:27:44.492667_captured_frame_95.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:27:44.492667_captured_frame_95.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:32:44.591100_captured_frame_96.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:32:44.591100_captured_frame_96.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:37:44.643152_captured_frame_97.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:37:44.643152_captured_frame_97.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:42:44.664627_captured_frame_98.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:42:44.664627_captured_frame_98.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:47:44.707388_captured_frame_99.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:47:44.707388_captured_frame_99.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:52:44.726383_captured_frame_100.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:52:44.726383_captured_frame_100.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 02:57:44.737433_captured_frame_101.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 02:57:44.737433_captured_frame_101.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:02:44.814908_captured_frame_102.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:02:44.814908_captured_frame_102.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:07:44.819226_captured_frame_103.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:07:44.819226_captured_frame_103.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:12:44.827575_captured_frame_104.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:12:44.827575_captured_frame_104.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:17:44.899651_captured_frame_105.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:17:44.899651_captured_frame_105.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:22:44.934952_captured_frame_106.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:22:44.934952_captured_frame_106.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:27:44.966791_captured_frame_107.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:27:44.966791_captured_frame_107.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:32:45.008211_captured_frame_108.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:32:45.008211_captured_frame_108.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:37:45.018493_captured_frame_109.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:37:45.018493_captured_frame_109.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:42:45.030083_captured_frame_110.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:42:45.030083_captured_frame_110.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:47:45.057323_captured_frame_111.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:47:45.057323_captured_frame_111.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:52:45.107915_captured_frame_112.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:52:45.107915_captured_frame_112.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 03:57:45.157591_captured_frame_113.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 03:57:45.157591_captured_frame_113.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:02:45.193810_captured_frame_114.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:02:45.193810_captured_frame_114.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:07:45.220361_captured_frame_115.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:07:45.220361_captured_frame_115.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:12:45.221789_captured_frame_116.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:12:45.221789_captured_frame_116.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:17:45.239388_captured_frame_117.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:17:45.239388_captured_frame_117.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:22:45.330362_captured_frame_118.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:22:45.330362_captured_frame_118.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:27:45.374669_captured_frame_119.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:27:45.374669_captured_frame_119.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:32:45.401053_captured_frame_120.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:32:45.401053_captured_frame_120.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:37:45.437917_captured_frame_121.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:37:45.437917_captured_frame_121.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:42:45.461922_captured_frame_122.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:42:45.461922_captured_frame_122.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:47:45.503682_captured_frame_123.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:47:45.503682_captured_frame_123.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:52:45.580192_captured_frame_124.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:52:45.580192_captured_frame_124.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 04:57:45.625241_captured_frame_125.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 04:57:45.625241_captured_frame_125.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:02:45.659804_captured_frame_126.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:02:45.659804_captured_frame_126.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:07:45.714172_captured_frame_127.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:07:45.714172_captured_frame_127.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:12:45.720629_captured_frame_128.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:12:45.720629_captured_frame_128.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:17:45.742179_captured_frame_129.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:17:45.742179_captured_frame_129.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:22:45.782340_captured_frame_130.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:22:45.782340_captured_frame_130.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:27:45.804583_captured_frame_131.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:27:45.804583_captured_frame_131.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:32:45.902838_captured_frame_132.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:32:45.902838_captured_frame_132.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:37:45.913247_captured_frame_133.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:37:45.913247_captured_frame_133.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:42:45.918754_captured_frame_134.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:42:45.918754_captured_frame_134.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:47:45.956584_captured_frame_135.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:47:45.956584_captured_frame_135.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:52:46.005816_captured_frame_136.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:52:46.005816_captured_frame_136.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 05:57:46.042982_captured_frame_137.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 05:57:46.042982_captured_frame_137.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:02:46.082034_captured_frame_138.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:02:46.082034_captured_frame_138.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:07:46.161327_captured_frame_139.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:07:46.161327_captured_frame_139.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:12:46.203575_captured_frame_140.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:12:46.203575_captured_frame_140.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:17:46.299139_captured_frame_141.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:17:46.299139_captured_frame_141.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:22:46.386825_captured_frame_142.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:22:46.386825_captured_frame_142.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:27:46.481340_captured_frame_143.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:27:46.481340_captured_frame_143.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:32:46.570643_captured_frame_144.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:32:46.570643_captured_frame_144.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:37:46.576270_captured_frame_145.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:37:46.576270_captured_frame_145.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:42:46.593852_captured_frame_146.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:42:46.593852_captured_frame_146.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:47:46.631535_captured_frame_147.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:47:46.631535_captured_frame_147.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:52:46.672242_captured_frame_148.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:52:46.672242_captured_frame_148.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 06:57:46.719295_captured_frame_149.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 06:57:46.719295_captured_frame_149.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:02:46.765380_captured_frame_150.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:02:46.765380_captured_frame_150.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:07:46.788089_captured_frame_151.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:07:46.788089_captured_frame_151.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:12:46.838490_captured_frame_152.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:12:46.838490_captured_frame_152.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:17:46.886790_captured_frame_153.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:17:46.886790_captured_frame_153.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:22:46.969893_captured_frame_154.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:22:46.969893_captured_frame_154.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:27:47.000199_captured_frame_155.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:27:47.000199_captured_frame_155.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:32:47.037296_captured_frame_156.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:32:47.037296_captured_frame_156.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:37:47.044202_captured_frame_157.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:37:47.044202_captured_frame_157.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:42:47.087622_captured_frame_158.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:42:47.087622_captured_frame_158.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:47:47.131433_captured_frame_159.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:47:47.131433_captured_frame_159.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:52:47.160197_captured_frame_160.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:52:47.160197_captured_frame_160.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 07:57:47.244315_captured_frame_161.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 07:57:47.244315_captured_frame_161.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:02:47.308492_captured_frame_162.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:02:47.308492_captured_frame_162.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:07:47.356100_captured_frame_163.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:07:47.356100_captured_frame_163.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:12:47.409948_captured_frame_164.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:12:47.409948_captured_frame_164.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:17:47.451823_captured_frame_165.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:17:47.451823_captured_frame_165.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:22:47.498511_captured_frame_166.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:22:47.498511_captured_frame_166.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:27:47.522951_captured_frame_167.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:27:47.522951_captured_frame_167.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:32:47.537032_captured_frame_168.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:32:47.537032_captured_frame_168.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:37:47.554573_captured_frame_169.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:37:47.554573_captured_frame_169.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:42:47.557926_captured_frame_170.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:42:47.557926_captured_frame_170.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:47:47.593329_captured_frame_171.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:47:47.593329_captured_frame_171.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:52:47.646175_captured_frame_172.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:52:47.646175_captured_frame_172.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 08:57:47.693021_captured_frame_173.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 08:57:47.693021_captured_frame_173.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 09:02:47.699658_captured_frame_174.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 09:02:47.699658_captured_frame_174.jpg
Binary file is not shown
 
hls_streaming/captured_frame_/2024-05-08 09:07:47.756147_captured_frame_175.jpg (Binary) (added)
+++ hls_streaming/captured_frame_/2024-05-08 09:07:47.756147_captured_frame_175.jpg
Binary file is not shown
 
hls_streaming/hls.py (added)
+++ hls_streaming/hls.py
@@ -0,0 +1,115 @@
+import time
+import av
+import cv2
+import numpy as np
+import requests
+from zoneinfo import ZoneInfo
+from datetime import datetime
+from threading import Lock, Thread, Event
+
+
+class FrameCapturer:
+    def __init__(self, hls_url, cctv_id, interval=5, buffer_duration=15, buffer_size=600, time_zone="Asia/Seoul", endpoint="localhost:12345"):
+        '''
+        :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 interval: interval of sampling in seconds
+        :param buffer_duration: video buffer, 15 seconds is default for ITS video streaming
+        :param time_zone: default Asia/Seoul
+        '''
+        self.hls_url = hls_url
+        self.interval = interval
+        self.buffer_duration = buffer_duration
+        self.buffer_size = 600
+        self.frame_buffer = []
+        self.frame_buffer_lock = Lock()
+        self.captured_frame_count = 0
+        self.last_capture_time = 0
+        self.start_time = time.time()
+        self.stop_event = Event()
+        self.setup_stream()
+        self.cctvid = cctv_id
+        self.time_zone = ZoneInfo(time_zone)
+        self.endpoint = endpoint
+
+    def setup_stream(self):
+        self.input_stream = av.open(self.hls_url)
+        self.video_stream = next(s for s in self.input_stream.streams if s.type == 'video')
+        self.fps = self.video_stream.guessed_rate.numerator
+        self.capture_interval = 1 / self.fps
+
+    # ```capture_frames``` and ```process_frames``` work asynchronously (called with Thread)
+    #  so that it always run as intended (for every '''interval''' sec, send a photo)
+    #  regardless of what buffer frames are now.
+    # They are triggered by ```start``` and halts by ```stop```
+    def capture_frames(self):
+        for packet in self.input_stream.demux(self.video_stream):
+            for frame in packet.decode():
+                with self.frame_buffer_lock:
+                    self.frame_buffer.append(frame)
+                time.sleep(self.capture_interval)
+
+    def process_frames(self):
+        while not self.stop_event.is_set():
+            current_time = time.time()
+            if current_time - self.start_time >= self.buffer_duration:
+                if self.last_capture_time == 0 or current_time - self.last_capture_time >= self.interval:
+                    with self.frame_buffer_lock:
+                        if self.frame_buffer:
+                            if len(self.frame_buffer) > self.buffer_size:
+                                self.frame_buffer = self.frame_buffer[-self.buffer_size:]
+                            buffered_frame = self.frame_buffer[-1]
+                            print(len(self.frame_buffer))
+                            img = buffered_frame.to_image()
+                            img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
+                            frame_name = f"captured_frame_{self.captured_frame_count}.jpg"
+                            img_binary = cv2.imencode('.png', img)
+                            self.send_image_to_server(img_binary, self.endpoint)
+                            cv2.imwrite(f'hls_streaming/captured_frame_/{datetime.now()}_{frame_name}', img)
+                            self.last_capture_time = current_time
+                            print(f"Captured {frame_name} at time: {current_time - self.start_time:.2f}s")
+                            self.captured_frame_count +=1
+
+            time.sleep(0.1)
+
+    def send_image_to_server(self, image, endpoint, image_type="png"):
+        time_sent = datetime.now(self.time_zone).strftime("yyyy-MM-dd'T'HH:mm:ss'Z'")
+        header = {
+            'Content-Type': f'image/{image_type}',
+            'x-time-sent': time_sent,
+            'x-cctv-info': str(self.cctvid),
+        }
+        try:
+            requests.post(endpoint, headers=header, files=image)
+        except:
+            print("Can not connect to the analyzer server. Check the endpoint address or connection.")
+
+    def start(self):
+        self.capture_thread = Thread(target=self.capture_frames)
+        self.process_thread = Thread(target=self.process_frames)
+        self.capture_thread.start()
+        self.process_thread.start()
+
+    def stop(self):
+        self.stop_event.set()
+        self.capture_thread.join()
+        self.process_thread.join()
+        self.input_stream.close()
+
+
+# Example usage
+if __name__ == "__main__":
+    capturer = FrameCapturer(
+        'http://cctvsec.ktict.co.kr/73496/'
+        '7xhDlyfDPK1AtaOUkAUDUJgZvfqvRXYYZUmRLxgPgKXk+eEtIJIfGkiC/gcQmysaz7zhDW2Jd8qhPCxgpo7cn5VqArnowyKjUePjdAmuQQ8=',
+        101, 300
+    )
+    t1 = time.time()
+    try:
+        capturer.start()
+        time.sleep(600000)
+    finally:
+        capturer.stop()
+        t2 = time.time()
+        with open("result.txt", "w") as file:
+            file.write(f'{t2-t1} seconds before terminating')
Add a comment
List