Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
accessibility_movie_1
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
翟艳秋(20软)
accessibility_movie_1
Commits
eb8368db
Commit
eb8368db
authored
Apr 16, 2022
by
翟艳秋(20软)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified: no need to change the startTime
parent
148178b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
detect_with_ocr.py
detect_with_ocr.py
+5
-3
main_gui.py
main_gui.py
+3
-3
No files found.
detect_with_ocr.py
View file @
eb8368db
import
os
import
os
# import time
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
...
@@ -28,6 +27,8 @@ def get_position(video_path, start_time):
...
@@ -28,6 +27,8 @@ def get_position(video_path, start_time):
video
=
cv2
.
VideoCapture
(
video_path
)
video
=
cv2
.
VideoCapture
(
video_path
)
subtitle_position
=
{}
subtitle_position
=
{}
fps
=
video
.
get
(
cv2
.
CAP_PROP_FPS
)
fps
=
video
.
get
(
cv2
.
CAP_PROP_FPS
)
if
video
.
get
(
cv2
.
CAP_PROP_FRAME_COUNT
)
/
fps
>
10
*
60
:
start_time
=
start_time
+
300
start
=
int
(
start_time
*
fps
)
start
=
int
(
start_time
*
fps
)
cnt
=
0
cnt
=
0
txt_cnt
=
0
txt_cnt
=
0
...
@@ -139,7 +140,8 @@ def detect_subtitle(img):
...
@@ -139,7 +140,8 @@ def detect_subtitle(img):
:return: [str|None], 字幕信息
:return: [str|None], 字幕信息
"""
"""
subTitle
=
''
subTitle
=
''
img
=
img
[
int
(
up_b
)
-
30
:
int
(
down_b
)
+
30
]
height
=
down_b
-
up_b
img
=
img
[
int
(
up_b
-
height
*
0.6
):
int
(
down_b
+
height
*
0.6
)]
# img = cv2.resize(img, (int(img.shape[1] * 0.5), int(img.shape[0] * 0.5)))
# img = cv2.resize(img, (int(img.shape[1] * 0.5), int(img.shape[0] * 0.5)))
res
=
ocr
.
ocr
(
img
,
cls
=
True
)
res
=
ocr
.
ocr
(
img
,
cls
=
True
)
sorted
(
res
,
key
=
lambda
text
:
text
[
0
][
0
][
1
])
sorted
(
res
,
key
=
lambda
text
:
text
[
0
][
0
][
1
])
...
@@ -264,7 +266,7 @@ def detect_with_ocr(video_path, book_path, start_time, end_time, state):
...
@@ -264,7 +266,7 @@ def detect_with_ocr(video_path, book_path, start_time, end_time, state):
# 获取字幕在画面中的上下边界,方便在后续视频遍历过程中直接对字幕对应区域进行分析
# 获取字幕在画面中的上下边界,方便在后续视频遍历过程中直接对字幕对应区域进行分析
global
up_b
,
down_b
global
up_b
,
down_b
up_b
,
down_b
=
get_position
(
video_path
,
start_time
+
30
)
up_b
,
down_b
=
get_position
(
video_path
,
start_time
)
# 获取并构建输出信息
# 获取并构建输出信息
table_head
=
[[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
]]
table_head
=
[[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
]]
...
...
main_gui.py
View file @
eb8368db
...
@@ -73,10 +73,10 @@ class RunThread(threading.Thread):
...
@@ -73,10 +73,10 @@ class RunThread(threading.Thread):
try
:
try
:
self
.
_run
()
self
.
_run
()
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
self
.
exitcode
=
1
# 如果线程异常退出,将该标志位设置为1,正常退出为0
self
.
exitcode
=
1
# 如果线程异常退出,将该标志位设置为1,正常退出为0
self
.
exception
=
e
self
.
exception
=
e
self
.
exc_traceback
=
''
.
join
(
traceback
.
format_exception
(
*
sys
.
exc_info
()))
# 在改成员变量中记录异常信息
self
.
exc_traceback
=
''
.
join
(
traceback
.
format_exception
(
*
sys
.
exc_info
()))
# 在改成员变量中记录异常信息
print
(
self
.
exc_traceback
)
def
_run
(
self
):
def
_run
(
self
):
"""运行函数,并合理抛出异常
"""运行函数,并合理抛出异常
...
@@ -257,7 +257,7 @@ def start_detect():
...
@@ -257,7 +257,7 @@ def start_detect():
# 多线程同步进行检测和进度条更新
# 多线程同步进行检测和进度条更新
state
=
[
None
]
state
=
[
None
]
threads
=
[]
threads
=
[]
t
=
RunThread
(
funcName
=
start_process
,
args
=
(
progressbar_1
,
progress_1
,
state
,
1
00000
),
name
=
"startProgress1"
)
t
=
RunThread
(
funcName
=
start_process
,
args
=
(
progressbar_1
,
progress_1
,
state
,
3
00000
),
name
=
"startProgress1"
)
t
.
setDaemon
(
True
)
t
.
setDaemon
(
True
)
threads
.
append
(
t
)
threads
.
append
(
t
)
t
=
RunThread
(
funcName
=
detect
,
t
=
RunThread
(
funcName
=
detect
,
...
@@ -458,7 +458,7 @@ def start_synthesis():
...
@@ -458,7 +458,7 @@ def start_synthesis():
args
=
(
video_path
,
sheet_path
,
audio_dir
,
speed
,
caption_path
,
state
),
name
=
"ssAndExport"
)
args
=
(
video_path
,
sheet_path
,
audio_dir
,
speed
,
caption_path
,
state
),
name
=
"ssAndExport"
)
t
.
setDaemon
(
True
)
t
.
setDaemon
(
True
)
threads
.
append
(
t
)
threads
.
append
(
t
)
t
=
RunThread
(
funcName
=
start_process
,
args
=
(
progressbar_2
,
progress_2
,
state
,
1
00000
),
name
=
"startProgress2"
)
t
=
RunThread
(
funcName
=
start_process
,
args
=
(
progressbar_2
,
progress_2
,
state
,
3
00000
),
name
=
"startProgress2"
)
t
.
setDaemon
(
True
)
t
.
setDaemon
(
True
)
threads
.
append
(
t
)
threads
.
append
(
t
)
...
...
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