Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
d344eb33
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d344eb33
编写于
7月 04, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
5552d087
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
16 deletion
+48
-16
sim_scenes/func.py
sim_scenes/func.py
+22
-4
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+1
-1
tools/sim_video_3d_cap.py
tools/sim_video_3d_cap.py
+25
-11
未找到文件。
sim_scenes/func.py
浏览文件 @
d344eb33
...
@@ -306,18 +306,36 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02):
...
@@ -306,18 +306,36 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02):
scale
=
(
width
,
height
),
scale
=
(
width
,
height
),
position
=
(
left
,
top
,
0
)
position
=
(
left
,
top
,
0
)
)
)
panel
.
color
=
color
.
rgba
(
0
,
0
,
0
,
1
)
panel
.
switch_flag
=
0
panel
.
switch_flag
=
0
panel
.
switch_count
=
[
0
,
0
]
def
switch_count_inc
():
num1
=
panel
.
switch_count
[
1
]
if
num1
>=
255
:
panel
.
switch_count
[
1
]
=
0
panel
.
switch_count
[
0
]
=
0
num0
=
panel
.
switch_count
[
0
]
if
num0
>=
255
:
panel
.
switch_count
[
1
]
+=
1
else
:
panel
.
switch_count
[
0
]
+=
1
def
get_switch_index
():
return
panel
.
switch_count
[
1
]
+
panel
.
switch_count
[
0
]
def
switch_color
():
def
switch_color
():
if
panel
.
color
==
color
.
black
:
if
panel
.
color
.
r
==
0
:
panel
.
color
=
color
.
white
panel
.
color
=
color
.
rgba
(
255
,
panel
.
switch_count
[
1
],
panel
.
switch_count
[
0
],
255
)
panel
.
switch_flag
=
1
panel
.
switch_flag
=
1
else
:
else
:
panel
.
color
=
color
.
black
panel
.
color
=
color
.
rgba
(
0
,
panel
.
switch_count
[
1
],
panel
.
switch_count
[
0
],
255
)
panel
.
switch_flag
=
0
panel
.
switch_flag
=
0
switch_count_inc
()
panel
.
switch_color
=
switch_color
panel
.
switch_color
=
switch_color
panel
.
get_switch_index
=
get_switch_index
return
panel
return
panel
...
...
simulators/ursina_simulator.py
浏览文件 @
d344eb33
...
@@ -37,7 +37,7 @@ class UrsinaSimulator(Simulator):
...
@@ -37,7 +37,7 @@ class UrsinaSimulator(Simulator):
def
__init__
(
self
,
bodies_sys
:
System
):
def
__init__
(
self
,
bodies_sys
:
System
):
# window.borderless = False
# window.borderless = False
window
.
title
=
'universe_sim'
# '宇宙模拟器'
window
.
title
=
'
宇宙模拟器(universe sim)'
# '
universe_sim' # '宇宙模拟器'
icon
=
find_file
(
"images/icon.ico"
)
icon
=
find_file
(
"images/icon.ico"
)
window
.
icon
=
icon
window
.
icon
=
icon
self
.
app
=
Ursina
()
self
.
app
=
Ursina
()
...
...
tools/sim_video_3d_cap.py
浏览文件 @
d344eb33
...
@@ -11,7 +11,7 @@ import win32api
...
@@ -11,7 +11,7 @@ import win32api
import
traceback
import
traceback
def
get_window_handle
(
window_name
=
"
universe_sim
"
):
def
get_window_handle
(
window_name
=
"
宇宙模拟器(universe sim)
"
):
"""
"""
获取模拟器窗口句柄
获取模拟器窗口句柄
@param window_name:
@param window_name:
...
@@ -96,13 +96,13 @@ def create_video(args, height, width):
...
@@ -96,13 +96,13 @@ def create_video(args, height, width):
return
video
return
video
#
def show_image(img):
def
show_image
(
img
):
#
from PIL import Image
from
PIL
import
Image
#
image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
image
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_RGB2BGR
)
#
image = Image.fromarray(image)
image
=
Image
.
fromarray
(
image
)
#
print(type(image)) # 结果为<class 'PIL.JpegImagePlugin.JpegImageFile'>
print
(
type
(
image
))
# 结果为<class 'PIL.JpegImagePlugin.JpegImageFile'>
#
print(image.size) # 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数
print
(
image
.
size
)
# 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数
#
image.show()
image
.
show
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
@@ -118,6 +118,8 @@ if __name__ == '__main__':
...
@@ -118,6 +118,8 @@ if __name__ == '__main__':
# show_image(img)
# show_image(img)
video
=
create_video
(
args
,
img
.
shape
[
0
],
img
.
shape
[
1
])
video
=
create_video
(
args
,
img
.
shape
[
0
],
img
.
shape
[
1
])
imageNum
=
0
imageNum
=
0
r_frames
=
[]
l_frames
=
[]
print
(
"开始录屏"
)
print
(
"开始录屏"
)
while
True
:
while
True
:
img
=
sim_window_screen_shot
()
img
=
sim_window_screen_shot
()
...
@@ -125,6 +127,17 @@ if __name__ == '__main__':
...
@@ -125,6 +127,17 @@ if __name__ == '__main__':
print
(
"
\n
模拟器窗口已关闭,退出录屏"
)
print
(
"
\n
模拟器窗口已关闭,退出录屏"
)
break
break
_3d_card
=
img
[
4
:
20
,
3
:
20
,
]
_3d_card_p
=
_3d_card
[
10
,
10
,
]
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
,
]))
else
:
_3d_card_color
=
"w"
_3d_card_direct
=
"left"
l_frames
.
append
((
_3d_card_p
[
1
]
+
_3d_card_p
[
0
],
img
[:
432
,
:
768
,
]))
# if is_blank_screen(img):
# if is_blank_screen(img):
# if imageNum % args.fps == 0:
# if imageNum % args.fps == 0:
# print('x', end='')
# print('x', end='')
...
@@ -139,9 +152,10 @@ if __name__ == '__main__':
...
@@ -139,9 +152,10 @@ if __name__ == '__main__':
imageNum
+=
1
imageNum
+=
1
# frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
# frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
if
imageNum
<
args
.
fps
*
args
.
total_time
:
# if imageNum < args.fps * args.total_time:
# show_image(frame)
# # img = img[:432,:768,]
video
.
write
(
img
)
# # show_image(frame)
# video.write(img)
print
(
"视频保存中"
)
print
(
"视频保存中"
)
video
.
release
()
video
.
release
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录