Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
4ddcea8b
宇宙模拟器
项目概览
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看板
提交
4ddcea8b
编写于
7月 04, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
b26bfd5c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
4 deletion
+25
-4
tools/sim_video_3d_cap.py
tools/sim_video_3d_cap.py
+25
-4
未找到文件。
tools/sim_video_3d_cap.py
浏览文件 @
4ddcea8b
...
@@ -40,15 +40,24 @@ def screen_shot(window_img_dc):
...
@@ -40,15 +40,24 @@ def screen_shot(window_img_dc):
# 创建一个内存设备描述表
# 创建一个内存设备描述表
mem_dc
=
window_img_dc
.
CreateCompatibleDC
()
mem_dc
=
window_img_dc
.
CreateCompatibleDC
()
# 创建位图对象
# 创建位图对象
screenshot
=
win32ui
.
CreateBitmap
()
screenshot
=
win32ui
.
CreateBitmap
()
# win32ui.CreateBitmap() GetBitmapBits() MemoryError
screenshot
.
CreateCompatibleBitmap
(
window_img_dc
,
width
,
height
)
screenshot
.
CreateCompatibleBitmap
(
window_img_dc
,
width
,
height
)
mem_dc
.
SelectObject
(
screenshot
)
mem_dc
.
SelectObject
(
screenshot
)
# 截图至内存设备描述表
# 截图至内存设备描述表
mem_dc
.
BitBlt
((
0
,
0
),
(
width
,
height
),
window_img_dc
,
(
0
,
0
),
win32con
.
SRCCOPY
)
mem_dc
.
BitBlt
((
0
,
0
),
(
width
,
height
),
window_img_dc
,
(
0
,
0
),
win32con
.
SRCCOPY
)
# 将截图保存到文件中
# 将截图保存到文件中
# screenshot.SaveBitmapFile(mem_dc, 'screenshot.bmp')
# screenshot.SaveBitmapFile(mem_dc, 'screenshot.bmp')
# TODO: Traceback (most recent call last):
# File "G:\works\gitcode\universe_sim\tools\sim_video_3d_cap.py", line 79, in sim_window_screen_shot
# img = screen_shot(img_dc)
# File "G:\works\gitcode\universe_sim\tools\sim_video_3d_cap.py", line 50, in screen_shot
# signedIntsArray = screenshot.GetBitmapBits(True)
# MemoryError
signedIntsArray
=
screenshot
.
GetBitmapBits
(
True
)
signedIntsArray
=
screenshot
.
GetBitmapBits
(
True
)
# 下面3个语句都能实现转换,推荐第1个
# 下面3个语句都能实现转换,推荐第1个
# TODO: G:\works\gitcode\universe_sim\tools\sim_video_3d_cap.py:52:
# DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
# img = np.fromstring(signedIntsArray, dtype='uint8')
img
=
np
.
fromstring
(
signedIntsArray
,
dtype
=
'uint8'
)
img
=
np
.
fromstring
(
signedIntsArray
,
dtype
=
'uint8'
)
img
.
shape
=
(
height
,
width
,
4
)
img
.
shape
=
(
height
,
width
,
4
)
# 内存释放
# 内存释放
...
@@ -131,7 +140,7 @@ if __name__ == '__main__':
...
@@ -131,7 +140,7 @@ if __name__ == '__main__':
_3d_card
=
img
[
4
:
20
,
3
:
20
,
]
_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
]
index
=
int
(
_3d_card_p
[
1
])
+
int
(
_3d_card_p
[
0
])
if
index
<
last_index
:
if
index
<
last_index
:
index_base
+=
(
last_index
+
1
)
index_base
+=
(
last_index
+
1
)
...
@@ -177,8 +186,20 @@ if __name__ == '__main__':
...
@@ -177,8 +186,20 @@ if __name__ == '__main__':
continue
continue
merged_list
=
[
np
.
concatenate
((
lv
[
i
],
sublist
),
axis
=
0
)
for
i
,
sublist
in
enumerate
(
rv
)]
merged_list
=
[
np
.
concatenate
((
lv
[
i
],
sublist
),
axis
=
0
)
for
i
,
sublist
in
enumerate
(
rv
)]
# show_image(np.array(merged_list))
# show_image(np.array(merged_list))
# TODO: Traceback (most recent call last):
video
.
write
(
np
.
array
(
merged_list
))
# File "D:\Anaconda3\envs\pythoncr\lib\runpy.py", line 197, in _run_module_as_main
# return _run_code(code, main_globals, None,
# File "D:\Anaconda3\envs\pythoncr\lib\runpy.py", line 87, in _run_code
# exec(code, run_globals)
# File "G:\works\gitcode\universe_sim\tools\sim_video_3d_cap.py", line 180, in <module>
# video.write(np.array(merged_list))
# numpy.core._exceptions._ArrayMemoryError: Unable to allocate 3.80 MiB for an array with shape (864, 1536, 3) and data type uint8
try
:
video
.
write
(
np
.
array
(
merged_list
))
except
Exception
as
e
:
print
(
"video.write ERROR:"
,
str
(
e
))
traceback
.
print_exc
()
break
print
(
"视频保存中"
)
print
(
"视频保存中"
)
video
.
release
()
video
.
release
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录