[RapidVideOCR周边] RapidVideOCR高级教程(有python基础的小伙伴)

  1. 安装使用VideoSubFinder软件

  2. 安装rapid_videocr

    pip install rapid_videocr
    
  3. 脚本运行:

    • Only OCR:
      from rapid_videocr import RapidVideOCR
      
      # RapidVideOCR有两个初始化参数
      # is_concat_rec: 是否用单张图识别,默认是False,也就是默认用单图识别
      # concat_batch: 叠图识别的图像张数,默认10,可自行调节
      # out_format: 输出格式选择,[srt, txt, all], 默认是 all
      # is_print_console: 是否打印结果,[0, 1], 默认是0,不打印
      extractor = RapidVideOCR(is_concat=False,
                                  out_format='all',
                                  is_print_console=False)
      
      # Windows端,需要这样写: rgb_dir = r'G:\ProgramFiles\_self\RapidVideOCR\test_files\RGBImages'
      # Linux / Mac 下面这样写
      rgb_dir = 'test_files/TXTImages'
      save_dir = 'result'
      extractor(rgb_dir, save_dir)
      
    • Extract + OCR:
      from rapid_videocr import RapidVideoSubFinderOCR
      
      vsf_exe = r"G:\ProgramFiles\VideoSubFinder_6.10_x64\Release_x64\VideoSubFinderWXW.exe"
      extractor = RapidVideoSubFinderOCR(vsf_exe_path=vsf_exe, is_concat_rec=True)
      
      # video_path can be directory path or video full path.
      video_path = 'test_files/tiny/2.mp4'
      save_dir = 'outputs'
      extractor(video_path, save_dir)
      
  4. 命令行运行:

    • Usage:
      $ rapid_videocr -h
      usage: rapid_videocr [-h] [-vsf VSF_EXE_PATH] [-video_dir VIDEO_DIR] [-i IMG_DIR] [-s SAVE_DIR] [-o {srt,txt,all}] [-m {single,concat}] [-b CONCAT_BATCH] [-p {0,1}]
      
      options:
      -h, --help            show this help message and exit
      -vsf VSF_EXE_PATH, --vsf_exe_path VSF_EXE_PATH
                              The full path of VideoSubFinderWXW.exe.
      -video_dir VIDEO_DIR, --video_dir VIDEO_DIR
                              The full path of video or the path of video directory.
      -i IMG_DIR, --img_dir IMG_DIR
                              The full path of RGBImages or TXTImages.
      -s SAVE_DIR, --save_dir SAVE_DIR
                              The path of saving the recognition result. Default is "outputs" under the current directory.
      -o {srt,txt,all}, --out_format {srt,txt,all}
                              Output file format. Default is "all".
      -m {single,concat}, --mode {single,concat}
                              Which mode to run (concat recognition or single recognition). Default is "single".
      -b CONCAT_BATCH, --concat_batch CONCAT_BATCH
                              The batch of concating image nums in concat recognition mode. Default is 10.
      -p {0,1}, --print_console {0,1}
                              Whether to print the subtitle results to console. 1 means to print results to console. Default is 0.
      
    • Example:
      • Only OCR:
        $ rapid_videocr -i RGBImages
        
      • Extract + OCR:
        $ rapid_videocr -vsf G:\ProgramFiles\VideoSubFinder_6.10_x64\Release_x64\VideoSubFinderWXW.exe -video_dir G:\ProgramFiles\RapidVideOCR\test_files\tiny
        
  5. 查看结果

    • 前往save_dir目录下即可查看结果。
    • 值得注意的是,如果想要让视频播放软件自动挂载srt文件,需要更改srt文件名字为视频文件名字,且放到同一目录下,亦或者手动指定加载。

PS: 详情参见RapidVideOCR

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值