윤영준 윤영준 05-21
한글 인코딩 문제 해결
@46ada5657224c1e05e89310d0ffa8d7523675e46
hls_streaming/hls.py
--- hls_streaming/hls.py
+++ hls_streaming/hls.py
@@ -3,6 +3,7 @@
 import cv2
 import numpy as np
 import requests
+import base64
 from requests_toolbelt.multipart.encoder import MultipartEncoder
 from zoneinfo import ZoneInfo
 from datetime import datetime
@@ -99,7 +100,7 @@
         header = {
             'Content-Type': f'image/{image_type}',
             'x-time-sent': time_sent,
-            'x-cctv-info': str(self.cctvid),
+            'x-cctv-info': base64.b64encode(str(self.cctvid).encode('utf-8')).decode('ascii'),
             'x-cctv-latitude' : str(self.lat),
             'x-cctv-longitude' : str(self.lon),
         }
@@ -133,20 +134,20 @@
         self.input_stream.close()
 
 
-# # Example usage
-# if __name__ == "__main__":
-#     capturer = FrameCapturer(
-#         'http://cctvsec.ktict.co.kr/5545/LFkDslDT81tcSYh3G4306+mcGlLb3yShF9rx2vcPfltwUL4+I950kcBlD15uWm6K0cKCtAMlxsIptMkCDo5lGQiLlARP+SyUloz8vIMNB18=',
-#         101, 10, 5
-#     )
-#     t1 = time.time()
-#     try:
-#         capturer.start()
-#         time.sleep(600000)
-#     finally:
-#         capturer.stop()
-#         del capturer
-#         t2 = time.time()
-#         with open("result.txt", "w") as file:
-#             file.write(f'{t2-t1} seconds before terminating')
-#         exit()
+# Example usage
+if __name__ == "__main__":
+    capturer = FrameCapturer(
+        'http://cctvsec.ktict.co.kr/5545/LFkDslDT81tcSYh3G4306+mcGlLb3yShF9rx2vcPfltwUL4+I950kcBlD15uWm6K0cKCtAMlxsIptMkCDo5lGQiLlARP+SyUloz8vIMNB18=',
+        "[국도] 테해란로", 10, 5
+    )
+    t1 = time.time()
+    try:
+        capturer.start()
+        time.sleep(600000)
+    finally:
+        capturer.stop()
+        del capturer
+        t2 = time.time()
+        with open("result.txt", "w") as file:
+            file.write(f'{t2-t1} seconds before terminating')
+        exit()
test.py
--- test.py
+++ test.py
@@ -2,6 +2,7 @@
 from flask_restx import Api, Resource, fields
 import os
 from datetime import datetime
+import base64
 # from yoloseg.inference_ import Inference
 
 app = Flask(__name__)
@@ -34,7 +35,7 @@
         if 'file' not in request.files:
             ns.abort(400, 'No image part in the request')
         image = request.files['file']
-        cctv_info = request.headers.get('x-cctv-info', '')
+        cctv_info = base64.b64decode(request.headers.get('x-cctv-info', '')).decode('UTF-8')
         print(cctv_info)
         time_sent = request.headers.get('x-time-sent', '')
         cctv_latitude = request.headers.get('x-cctv-latitude', 'Not provided')
Add a comment
List