From ef865433db4c1e2028e77cf262a569e18618b237 Mon Sep 17 00:00:00 2001 From: AZcookiecat <155637917+AZcookiecat@users.noreply.github.com> Date: Tue, 31 Mar 2026 23:37:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=95=E5=88=B6=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=87=BA=E7=8E=B0=E8=89=B2=E5=B7=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- llm/main_ai.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/llm/main_ai.py b/llm/main_ai.py index bcec3ac..03f89e0 100644 --- a/llm/main_ai.py +++ b/llm/main_ai.py @@ -1249,14 +1249,15 @@ async def _recording_loop(self): image = self.image_queue.get() # 转换为numpy数组 import numpy as np - img = np.frombuffer(image.raw_data, dtype=np.uint8) - img = img.reshape((image.height, image.width, 4)) # BGRA - img = img[:, :, :3] # 转换为BGR - img = img[:, :, ::-1] # 转换为RGB + import cv2 + array = np.frombuffer(image.raw_data, dtype=np.uint8) + array = array.reshape((image.height, image.width, 4)) + array = array[:, :, :3] + img_rgb = array[:, :, ::-1] + img_bgr = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2BGR) # 写入视频文件 if self.video_writer is None: - import cv2 fourcc = cv2.VideoWriter_fourcc(*'mp4v') self.video_writer = cv2.VideoWriter( self.recording_output_path, @@ -1266,7 +1267,7 @@ async def _recording_loop(self): ) app_logger.info(f"📹 视频写入器已创建") - self.video_writer.write(img) + self.video_writer.write(img_bgr) self.recording_frame_count += 1 await asyncio.sleep(frame_interval)