From 2dc3a808e5c8a55fc1870f236169e5a696cab876 Mon Sep 17 00:00:00 2001 From: march3 Date: Mon, 27 Nov 2023 14:06:38 +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 --- sim_scenes/fiction/earth_orbit_stopped.py | 2 +- tools/sim_video_cap.py | 26 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/sim_scenes/fiction/earth_orbit_stopped.py b/sim_scenes/fiction/earth_orbit_stopped.py index c6c2464..b67571f 100644 --- a/sim_scenes/fiction/earth_orbit_stopped.py +++ b/sim_scenes/fiction/earth_orbit_stopped.py @@ -259,7 +259,7 @@ if __name__ == '__main__': # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- # position=(0, 0, 0) 的位置是站在地球视角,可以观看月相变化的过程 - ursina_run(sim.bodies, SECONDS_PER_DAY, position=(0, 0.0001 * AU, -0.8 * AU), + ursina_run(sim.bodies, SECONDS_PER_DAY/2.5, position=(0, 0.0001 * AU, -0.8 * AU), show_camera_info=False, show_control_info=False, show_timer=True, diff --git a/tools/sim_video_cap.py b/tools/sim_video_cap.py index 7cb7b7a..9293c4c 100644 --- a/tools/sim_video_cap.py +++ b/tools/sim_video_cap.py @@ -82,9 +82,10 @@ def wait_sec(sec=0): return -def sim_window_screen_shot(wait_ses=-1): +def sim_window_screen_shot(wait_ses=-1, retry_times=3): times = wait_ses * 100 while True: + handle, desktop_dc, img_dc, img = None, None, None, None handle = get_window_handle() if handle > 0: desktop_dc = win32gui.GetWindowDC(handle) @@ -93,7 +94,14 @@ def sim_window_screen_shot(wait_ses=-1): img = screen_shot(img_dc) except Exception as e: print("ERROR:", str(e)) + print("handle", handle) + print("desktop_dc", desktop_dc) + print("img_dc", img_dc) + print("img", img) traceback.print_exc() + if retry_times > 0: + print("retry_times", retry_times) + return sim_window_screen_shot(wait_ses, retry_times - 1) return None return img if wait_ses < 0: @@ -118,6 +126,11 @@ def create_video(args, height, width): # print(image.size) # 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数 # image.show() +def get_current_time(): + import datetime + current_time = datetime.datetime.now() + return current_time + if __name__ == '__main__': args = get_args() @@ -135,11 +148,16 @@ if __name__ == '__main__': # show_image(img) video = create_video(args, img.shape[0], img.shape[1]) imageNum = 0 - print("开始录屏") + # import datetime + # + # current_time = datetime.datetime.now() + # # print("当前时间:", current_time) + + print("开始录屏时间:", get_current_time()) while True: img = sim_window_screen_shot() if img is None: - print("\n模拟器窗口已关闭,退出录屏") + print("\n模拟器窗口已关闭,退出录屏时间:", get_current_time()) break # if is_blank_screen(img): @@ -164,5 +182,5 @@ if __name__ == '__main__': video.release() cv2.destroyAllWindows() # crop('video.mp4') - print("视频保存完成") + print("视频保存完成时间:", get_current_time()) print(args.save_name) -- GitLab