From b318d5443aee8c7c21d7064a792e6dc906e5b865 Mon Sep 17 00:00:00 2001 From: march3 Date: Tue, 4 Jul 2023 13:15:11 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/consts.py | 2 ++ tools/sim_video_3d_cap.py | 32 +++++++++++++++++++++++++++----- tools/sim_video_cap.py | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/common/consts.py b/common/consts.py index 3b0bb4e..0dda5e0 100644 --- a/common/consts.py +++ b/common/consts.py @@ -7,6 +7,8 @@ # python_version :3.8 # ============================================================================== +# 模拟器的标题 +WINDOW_TITLE = "" """ 太阳质量是用于测量恒星或如星系类大型天体的质量单位。 diff --git a/tools/sim_video_3d_cap.py b/tools/sim_video_3d_cap.py index 47d9c2a..7d6141b 100644 --- a/tools/sim_video_3d_cap.py +++ b/tools/sim_video_3d_cap.py @@ -118,8 +118,10 @@ if __name__ == '__main__': # show_image(img) video = create_video(args, img.shape[0], img.shape[1]) imageNum = 0 - r_frames = [] - l_frames = [] + index_base = 0 + last_index = 0 + r_frames = {} + l_frames = {} print("开始录屏") while True: img = sim_window_screen_shot() @@ -128,15 +130,24 @@ if __name__ == '__main__': break _3d_card = img[4:20, 3:20, ] - _3d_card_p = _3d_card[10, 10, ] + _3d_card_p = _3d_card[10, 10,] + index = _3d_card_p[1] + _3d_card_p[0] + if index < last_index: + index_base += (last_index + 1) + + last_index = index + index = index + index_base + if _3d_card_p[2] < 100: _3d_card_color = "b" _3d_card_direct = "right" - r_frames.append((_3d_card_p[1]+_3d_card_p[0], img[:432, :768, ])) + if index not in r_frames.keys(): + r_frames[index] = img[:864, :768, ] else: _3d_card_color = "w" _3d_card_direct = "left" - l_frames.append((_3d_card_p[1]+_3d_card_p[0], img[:432, :768, ])) + if index not in l_frames.keys(): + l_frames[index] = img[:864, :768, ] # if is_blank_screen(img): # if imageNum % args.fps == 0: @@ -156,6 +167,17 @@ if __name__ == '__main__': # # img = img[:432,:768,] # # show_image(frame) # video.write(img) + min_index = min(r_frames.keys()) + max_index = max(r_frames.keys()) + for index in range(min_index, max_index + 1): + rv = r_frames.get(index, None) + lv = l_frames.get(index, None) + if rv is None or lv is None: + continue + merged_list = [np.concatenate((lv[i], sublist), axis=0) for i, sublist in enumerate(rv)] + # show_image(np.array(merged_list)) + + video.write(np.array(merged_list)) print("视频保存中") video.release() diff --git a/tools/sim_video_cap.py b/tools/sim_video_cap.py index 4750e5d..68f5422 100644 --- a/tools/sim_video_cap.py +++ b/tools/sim_video_cap.py @@ -11,7 +11,7 @@ import win32api import traceback -def get_window_handle(window_name="universe_sim"): +def get_window_handle(window_name="宇宙模拟器(universe sim)"): """ 获取模拟器窗口句柄 @param window_name: -- GitLab