Commit fca8dfbc authored by wux51's avatar wux51

fix:ocr algorithm issue with no subtitle

parent 9b46d4c7
...@@ -580,6 +580,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she ...@@ -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) video.set(cv2.CAP_PROP_POS_MSEC, begin * 1000)
pre_state = state[0] pre_state = state[0]
ocr_h = None ocr_h = None
fl = False
while True: while True:
_, frame = video.read() _, frame = video.read()
if frame is None: if frame is None:
...@@ -605,7 +606,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she ...@@ -605,7 +606,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
break break
# 每秒取4帧画面左右 # 每秒取4帧画面左右
# TODO 取帧算法优化 # TODO 取帧算法优化
fl = False
if cnt % int(fps / 4) == 0: if cnt % int(fps / 4) == 0:
# 更新当前工程的检测进度 # 更新当前工程的检测进度
if pre_state is None: if pre_state is None:
...@@ -625,6 +626,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she ...@@ -625,6 +626,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she
if len(subTitle) == 0: if len(subTitle) == 0:
subTitle = None subTitle = None
if fl: if fl:
print('QQQQQ')
if subTitle is None: if subTitle is None:
continue continue
else : else :
...@@ -642,12 +644,16 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she ...@@ -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, '']) # 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) 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 start_time = cur_time
lastSubTitle = subTitle
last_confidence = confidence
lastConf = conf
else : else :
lastSubTitle = subTitle if conf > lastConf else lastSubTitle lastSubTitle = subTitle if conf > lastConf else lastSubTitle
lastConf = max(lastConf, conf) lastConf = max(lastConf, conf)
fl = False fl = False
continue
# 第一次找到字幕 # 第一次找到字幕
if lastSubTitle is None and subTitle is not None: if lastSubTitle is None and subTitle is not None:
if cur_ocr_h != None: if cur_ocr_h != None:
...@@ -656,7 +662,7 @@ def process_video(video_path: str, begin: float, end: float, book_path: str, she ...@@ -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: elif lastSubTitle is not None and subTitle is None:
fl = False fl = True
cur_time1 = cur_time cur_time1 = cur_time
continue continue
# end_time = cur_time # end_time = cur_time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment