Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
accessibility_movie_2
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
赵心治
accessibility_movie_2
Commits
fca8dfbc
Commit
fca8dfbc
authored
Nov 06, 2023
by
wux51
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:ocr algorithm issue with no subtitle
parent
9b46d4c7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
detect_with_ocr.py
detect_with_ocr.py
+9
-3
No files found.
detect_with_ocr.py
View file @
fca8dfbc
...
...
@@ -580,6 +580,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
video
.
set
(
cv2
.
CAP_PROP_POS_MSEC
,
begin
*
1000
)
pre_state
=
state
[
0
]
ocr_h
=
None
fl
=
False
while
True
:
_
,
frame
=
video
.
read
()
if
frame
is
None
:
...
...
@@ -605,7 +606,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
break
# 每秒取4帧画面左右
# TODO 取帧算法优化
fl
=
False
if
cnt
%
int
(
fps
/
4
)
==
0
:
# 更新当前工程的检测进度
if
pre_state
is
None
:
...
...
@@ -625,6 +626,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
if
len
(
subTitle
)
==
0
:
subTitle
=
None
if
fl
:
print
(
'QQQQQ'
)
if
subTitle
is
None
:
continue
else
:
...
...
@@ -642,12 +644,16 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
# write_to_sheet(book_path, sheet_name, [round(start_time, 2), round(end_time, 2), lastSubTitle, ''])
add_to_list
(
mainWindow
,
"字幕"
,
[
round
(
start_time
,
3
),
round
(
end_time
,
3
),
lastSubTitle
,
''
],
ocr_h
)
print
(
">>>>>>subtitle,ocr_h2:"
+
str
(
lastSubTitle
)
+
">>>"
+
str
(
ocr_h
))
print
(
">>>>>>subtitle,ocr_h2:"
+
str
(
lastSubTitle
)
+
">>>"
+
str
(
ocr_h
)
,
'st='
,
start_time
,
'ed='
,
end_time
,
cur_time
,
cur_time1
)
start_time
=
cur_time
lastSubTitle
=
subTitle
last_confidence
=
confidence
lastConf
=
conf
else
:
lastSubTitle
=
subTitle
if
conf
>
lastConf
else
lastSubTitle
lastConf
=
max
(
lastConf
,
conf
)
fl
=
False
continue
# 第一次找到字幕
if
lastSubTitle
is
None
and
subTitle
is
not
None
:
if
cur_ocr_h
!=
None
:
...
...
@@ -656,7 +662,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
# 字幕消失
elif
lastSubTitle
is
not
None
and
subTitle
is
None
:
fl
=
Fals
e
fl
=
Tru
e
cur_time1
=
cur_time
continue
# end_time = cur_time
...
...
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