Skip to content

videocr_PaddleOCR.ipynb 跑demo遇到的错误 #12

Description

@marianasignal

`from videocr import save_subtitles_to_file

#@title OCR parameters
input_file_path = "example_cropped.mp4" #@PARAM {type:"string"}
output_file_path = "example.srt" #@PARAM {type:"string"}
language_code = "ch" #@PARAM {type:"string"}
use_gpu = False #@PARAM {type:"boolean"}
start_time = "00:00" #@PARAM {type:"string"}
end_time = "" #@PARAM {type:"string"}
confidence_threshold = 50 #@PARAM {type:"number"}
similarity_threshold = 80 #@PARAM {type:"number"}
frames_to_skip = 0 #@PARAM {type:"integer"}
crop_x = 40 #@PARAM {type:"integer"}
crop_y = 650 #@PARAM {type:"integer"}
crop_width = 890 #@PARAM {type:"integer"}
crop_height = 69 #@PARAM {type:"integer"}

save_subtitles_to_file(input_file_path, output_file_path, lang=language_code,
time_start=start_time, time_end=end_time,
conf_threshold=confidence_threshold, sim_threshold=similarity_threshold,
use_gpu=use_gpu,
# # Models different from the default mobile models can be downloaded here: https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.3/doc/doc_en/models_list_en.md
det_model_dir='./videocr/model/ch_det_fast', rec_model_dir='./videocr/model/ch_rec_fast',
# brightness_threshold=210, similar_image_threshold=1000 # filters might help
# use_fullframe=True, # note: videocr just assumes horizontal lines of text. vertical text scenario hasn't been implemented yet
frames_to_skip=frames_to_skip, # can skip inference for some frames to speed up the process
crop_x=crop_x, crop_y=crop_y, crop_width=crop_width, crop_height=crop_height)`

报错:
`---------------------------------------------------------------------------
error Traceback (most recent call last)
/tmp/ipykernel_8898/783819912.py in
25 # use_fullframe=True, # note: videocr just assumes horizontal lines of text. vertical text scenario hasn't been implemented yet
26 frames_to_skip=frames_to_skip, # can skip inference for some frames to speed up the process
---> 27 crop_x=crop_x, crop_y=crop_y, crop_width=crop_width, crop_height=crop_height)

~/work/y00580163/videocr-PaddleOCR/videocr/api.py in save_subtitles_to_file(video_path, file_path, lang, time_start, time_end, conf_threshold, sim_threshold, use_fullframe, det_model_dir, rec_model_dir, use_gpu, brightness_threshold, similar_image_threshold, similar_pixel_threshold, frames_to_skip, crop_x, crop_y, crop_width, crop_height)
23 f.write(get_subtitles(
24 video_path, lang, time_start, time_end, conf_threshold,
---> 25 sim_threshold, use_fullframe, det_model_dir, rec_model_dir, use_gpu, brightness_threshold, similar_image_threshold, similar_pixel_threshold, frames_to_skip, crop_x, crop_y, crop_width, crop_height))

~/work/y00580163/videocr-PaddleOCR/videocr/api.py in get_subtitles(video_path, lang, time_start, time_end, conf_threshold, sim_threshold, use_fullframe, det_model_dir, rec_model_dir, use_gpu, brightness_threshold, similar_image_threshold, similar_pixel_threshold, frames_to_skip, crop_x, crop_y, crop_width, crop_height)
10
11 v = Video(video_path, det_model_dir, rec_model_dir)
---> 12 v.run_ocr(use_gpu, lang, time_start, time_end, conf_threshold, use_fullframe, brightness_threshold, similar_image_threshold, similar_pixel_threshold, frames_to_skip, crop_x, crop_y, crop_width, crop_height)
13 return v.get_subtitles(sim_threshold)
14

~/work/y00580163/videocr-PaddleOCR/videocr/video.py in run_ocr(self, use_gpu, lang, time_start, time_end, conf_threshold, use_fullframe, brightness_threshold, similar_image_threshold, similar_pixel_threshold, frames_to_skip, crop_x, crop_y, crop_width, crop_height)
74
75 if similar_image_threshold:
---> 76 grey = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
77 if prev_grey is not None:
78 _, absdiff = cv2.threshold(cv2.absdiff(prev_grey, grey), similar_pixel_threshold, 255, cv2.THRESH_BINARY)

error: OpenCV(4.6.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'`

Activity

  1. devmaxxing commented on Mar 19, 2023

    @devmaxxing
    Owner

    你在用这个视频吗:https://github.com/oliverfei/videocr-PaddleOCR/blob/master/example_cropped.mp4
    如果在用那个视频你的crop_x,crop_y,crop_height,crop_width有问题。在README加了一个例子:
    image

    如果视频已经crop过了不用crop就用use_fullframe=True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions