提交 2dc3a808 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 53ccb51a
......@@ -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,
......
......@@ -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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册