Skip to content

Commit

Permalink
box generation & resize
Browse files Browse the repository at this point in the history
  • Loading branch information
williamy946 committed Jun 26, 2021
1 parent bdfe251 commit bf4c215
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def mouseReleaseEvent(self, event):
print('start:[{}, {}]'.format(self.start[0], self.start[1]))
print('end:[{}, {}]'.format(self.end[0], self.end[1]))
print(self.rect.getRect())

self.drawing = False


Expand Down
28 changes: 23 additions & 5 deletions main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,14 @@ def lower_color(self):
def test_seg(self):
if not self.hasOpen:
return
# TODO: 如何获得 box 数据
box = [[410, None], [100, 800]]

rec_pos = self.videoView.rect.getRect()
video_height = self.videoView.my_scene.height()
frame_height = self.frame.shape[0]
vf_ratio = frame_height/video_height

box = [[int(rec_pos[1]*vf_ratio), int((rec_pos[1]+rec_pos[3])*vf_ratio)],
[int(rec_pos[0]*vf_ratio), int((rec_pos[0]+rec_pos[2])*vf_ratio)]]

srt_prob_thres = float(self.srtThres.text())
seg_method = self.segMethod.itemText(self.segMethod.currentIndex())
Expand Down Expand Up @@ -165,8 +171,13 @@ def gen_time(self):
lang_box_text = self.langBox.itemText(self.langBox.currentIndex())
lang = [lang_box_text] if lang_box_text != "dual" else ['ch_sim', 'en']

# TODO: 如何获得 box 数据
box = [[410, None], [100, 800]]
rec_pos = self.videoView.rect.getRect()
video_height = self.videoView.my_scene.height()
frame_height = self.frame.shape[0]
vf_ratio = frame_height / video_height

box = [[int(rec_pos[1] * vf_ratio), int((rec_pos[1] + rec_pos[3]) * vf_ratio)],
[int(rec_pos[0] * vf_ratio), int((rec_pos[0] + rec_pos[2]) * vf_ratio)]]

# split_vision(self.video, self.video_path, upper_values, lower_values, seg_method, box,
# self.progressBar, lang, srt_prob_thres, change_prob_thres, save_frames)
Expand All @@ -177,7 +188,14 @@ def gen_time(self):
def gen_sub(self):
if not self.hasOpen:
return
box = [[410, None], [160, 760]]
rec_pos = self.videoView.rect.getRect()
video_height = self.videoView.my_scene.height()
frame_height = self.frame.shape[0]
vf_ratio = frame_height / video_height

box = [[int(rec_pos[1] * vf_ratio), int((rec_pos[1] + rec_pos[3]) * vf_ratio)],
[int(rec_pos[0] * vf_ratio), int((rec_pos[0] + rec_pos[2]) * vf_ratio)]]

ocr_method = self.ocrMethod.itemText(self.ocrMethod.currentIndex())
# lang = ['ch_sim']
lang_box_text = self.langBox.itemText(self.langBox.currentIndex())
Expand Down

0 comments on commit bf4c215

Please sign in to comment.