Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marianasignal opened this issue Mar 16, 2023 · 1 comment
Open

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

marianasignal opened this issue Mar 16, 2023 · 1 comment

Comments

@marianasignal
Copy link

`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'`

@devmaxxing
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants