Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
waae-algorithm-tools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈铭(23研)
waae-algorithm-tools
Commits
64613518
Commit
64613518
authored
Feb 26, 2025
by
沈铭(23研)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e6f2a42b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
48 deletions
+55
-48
annotation_video.py
annotation_video.py
+34
-32
script_video.py
script_video.py
+21
-16
No files found.
annotation_video.py
View file @
64613518
...
...
@@ -10,20 +10,22 @@ parser.add_argument('--task_root_dir',type=str,required=True, help='待检测任
# 解析命令行参数
args
=
parser
.
parse_args
()
def
generate_excel
(
video_report_
list
):
def
generate_excel
(
video_report_
path
):
rule_header
=
None
rule_rows
=
[]
page_name
=
[]
for
report
in
video_report_list
:
data
=
json
.
load
(
open
(
report
,
'r'
))
for
page
in
data
:
page
=
data
[
page
]
video_path
=
page
[
"合成视频路径"
]
if
rule_header
is
None
:
rule_header
=
page
[
"判断条目"
]
result
=
page
[
"通过情况"
]
page_name
.
append
(
os
.
path
.
splitext
(
os
.
path
.
basename
(
video_path
))[
0
])
rule_rows
.
append
(
result
)
data
=
json
.
load
(
open
(
video_report_path
,
'r'
))
for
page
in
data
:
page
=
data
[
page
]
print
(
page
)
video_path
=
page
[
"合成视频路径"
]
if
rule_header
is
None
:
rule_header
=
page
[
"判断条目"
]
result
=
page
[
"通过情况"
]
page_name
.
append
(
os
.
path
.
splitext
(
os
.
path
.
basename
(
video_path
))[
0
])
rule_rows
.
append
(
result
)
df
=
pd
.
DataFrame
(
rule_rows
,
columns
=
rule_header
)
new_df
=
pd
.
DataFrame
()
for
col
in
df
.
columns
:
...
...
@@ -35,30 +37,29 @@ def generate_excel(video_report_list):
def
run
(
task_root_dir
):
video_report_
list
=
[
os
.
path
.
join
(
task_root_dir
,
task
,
'app_video_report.json'
)
for
task
in
os
.
listdir
(
task_root_dir
)]
generate_excel
(
video_report_
list
)
video_report_
path
=
os
.
path
.
join
(
task_root_dir
,
'app_video_report.json'
)
generate_excel
(
video_report_
path
)
output_img_path
=
'temp.mp4'
for
report
in
video_report_list
:
data
=
json
.
load
(
open
(
report
,
'r'
))
for
page
in
data
:
page
=
data
[
page
]
video_path
=
page
[
"合成视频路径"
]
shutil
.
copy
(
os
.
path
.
join
(
task_root_dir
,
video_path
),
output_img_path
)
rule_header
=
page
[
"判断条目"
]
result
=
page
[
"通过情况"
]
result_map
=
[[
rule_header
[
i
],
result
[
i
]]
for
i
in
range
(
len
(
rule_header
))]
user_input
=
input
(
"请输入 'n' 继续遍历下一个,输入 'c' 结束遍历: "
)
if
user_input
==
'c'
:
print
(
"程序已结束。"
)
return
0
elif
user_input
==
'n'
:
print
(
f
"视频展示在: {output_img_path}"
)
print
(
f
"原视频地址: {video_path}"
)
print
(
f
"该视频对应检测结果: {result_map}"
)
data
=
json
.
load
(
open
(
video_report_path
,
'r'
))
for
page
in
data
:
page
=
data
[
page
]
video_path
=
page
[
"合成视频路径"
]
shutil
.
copy
(
os
.
path
.
join
(
task_root_dir
,
video_path
),
output_img_path
)
rule_header
=
page
[
"判断条目"
]
result
=
page
[
"通过情况"
]
result_map
=
[[
rule_header
[
i
],
result
[
i
]]
for
i
in
range
(
len
(
rule_header
))]
user_input
=
input
(
"请输入 'n' 继续遍历下一个,输入 'c' 结束遍历: "
)
if
user_input
==
'c'
:
print
(
"程序已结束。"
)
return
0
elif
user_input
==
'n'
:
print
(
f
"视频展示在: {output_img_path}"
)
print
(
f
"原视频地址: {video_path}"
)
print
(
f
"该视频对应检测结果: {result_map}"
)
else
:
print
(
"输入无效,请输入 'n' 或 'c'。"
)
else
:
print
(
"输入无效,请输入 'n' 或 'c'。"
)
if
__name__
==
"__main__"
:
task_root_dir
=
args
.
task_root_dir
run
(
task_root_dir
)
\ No newline at end of file
script_video.py
View file @
64613518
...
...
@@ -84,6 +84,7 @@ def process(file_list, data, entry, video_save_path, save_path):
for
page_id
in
result
:
id
=
f
'{save_path}_{cnt}'
video_path
=
osp
.
join
(
video_save_path
,
f
'{app_name}-{task_id}-{page_id}.mp4'
)
print
(
video_path
)
screenshot_path
,
image_path
=
process_page
(
pages
,
page_id
)
image_path
=
osp
.
join
(
file
,
'screenshots'
,
image_path
.
split
(
'/'
)[
-
1
])
...
...
@@ -91,19 +92,23 @@ def process(file_list, data, entry, video_save_path, save_path):
# 当前页面的所有截图
screenshot_path
=
[
osp
.
join
(
file
,
'screenshots'
,
item
)
for
item
in
screenshot_path
]
# 合成视频
images_to_video
(
screenshot_path
,
video_path
,
fps
=
1
)
result_finial
[
id
]
=
{
'页面名'
:
f
'{id}'
,
'合成视频路径'
:
video_path
,
'页面截图路径'
:
image_path
,
'所有截图路径'
:
screenshot_path
}
shutil
.
copy
(
image_path
,
img_path
)
result_finial
[
id
][
'判断条目'
]
=
entry
result_finial
[
id
][
'错误条目'
]
=
result
[
page_id
]
result_finial
[
id
][
'通过情况'
]
=
process_data
(
result2
[
page_id
],
entry
)
cnt
+=
1
try
:
# 合成视频
result_finial
[
id
]
=
{
'页面名'
:
f
'{id}'
,
'合成视频路径'
:
video_path
,
'页面截图路径'
:
image_path
,
'所有截图路径'
:
screenshot_path
}
# shutil.copy(image_path, img_path)
result_finial
[
id
][
'判断条目'
]
=
entry
result_finial
[
id
][
'错误条目'
]
=
result
[
page_id
]
result_finial
[
id
][
'通过情况'
]
=
process_data
(
result2
[
page_id
],
entry
)
images_to_video
(
screenshot_path
,
video_path
,
fps
=
1
)
cnt
+=
1
except
Exception
as
e
:
with
open
(
'error_log.txt'
,
'+a'
)
as
f
:
print
(
e
)
f
.
write
(
str
(
e
)
+
'
\n
'
)
continue
# print(result_finial, )
print
(
len
(
result_finial
))
return
result_finial
...
...
@@ -117,7 +122,7 @@ def load_file_path(path):
return
file_list
def
images_to_video
(
image_files
,
output_video_path
,
fps
=
1
):
# pass
clip
=
ImageSequenceClip
(
image_files
,
fps
=
fps
)
clip
.
write_videofile
(
output_video_path
)
print
(
f
"视频已成功保存至:{output_video_path}"
)
...
...
@@ -158,4 +163,4 @@ def run(tast_dir='task_dir',map_dict_path='app_video_map.txt'):
if
__name__
==
'__main__'
:
# TODO: 使用时,传入waae数据根目录(task_dir)和检测的条目(app_video_map.txt)
run
()
\ No newline at end of file
run
(
tast_dir
=
'/developer/shenming/waae_feedback_data'
,
map_dict_path
=
'app_video_map.txt'
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment