当前位置: 首页 > news >正文

离线视频ocr识别

sudo apt-get install libleptonica-dev libtesseract-dev
sudo apt-get install tesseract-ocr-chi-sim
python -m pip  install video-ocr

windows安装方法:
下载安装
https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-5.3.3.20231005.exe

下载

wget https://github.com/simonflueckiger/tesserocr-windows_build/releases/download/tesserocr-v2.6.0-tesseract-5.3.1/tesserocr-2.6.0-cp311-cp311-win_amd64.whl
pip install tesserocr-2.6.0-cp311-cp311-win_amd64.whl
git clone https://github.com/PinkFloyded/video-ocr.git
cd video-ocr
notepad setup.py

去掉版本依赖,修改如下:

 install_requires=["tesserocr","scipy","opencv-python","numpy","tqdm","click","Pillow",],

之后安装

python setup.py install

如果遇到

RuntimeError: Failed to init API, possibly an invalid tessdata path: ./

则需要设置环境变量TESSDATA_PREFIX为C:\Program Files\Tesseract-OCR\tessdata\

默认只能识别英文,所以要把包改掉

查看默认位置:

Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import video_ocr
>>> video_ocr.__file__
'/home/catcatyu/.local/lib/python3.10/site-packages/video_ocr.py'
>>>
nano /home/catcatyu/.local/lib/python3.10/site-packages/video_ocr.py

修改124行添加lang=chi_sim 参数。

def _ocr(frame):pil_image = Image.fromarray(frame.image)text = tesserocr.image_to_text(pil_image,lang="chi_sim") #这行frame.text = textpbar.update()return frame

之后使用

video-ocr --sample_rate 10  1.mp4

即可识别。
效果:

在这里插入图片描述
在这里插入图片描述

使用--sample_rate 参数可以提高精度数字越大越好

http://www.lryc.cn/news/225778.html

相关文章:

  • 双十一流量卡选购指南:不要只看月租,性价比高才是硬道理!
  • 时序预测 | MATLAB实现WOA-CNN-GRU-Attention时间序列预测(SE注意力机制)
  • 华为防火墙二层透明模式下双机热备负载分担配置(两端为路由器)
  • “基于RflySim平台飞控底层算法开发”系列专题培训 (第三期)
  • Leetcode刷题详解——全排列 II
  • 音频——解析 PCM 数据
  • win10 下 ros + Qt 工程CMakeLists.txt
  • Scala中编写多线程爬虫程序并做可视化处理
  • 使用 huggingface_hub 镜像下载 大模型
  • 路径加密(替换空格),剑指offer,力扣
  • HarmonyOS开发:UI开展前的阶段总结
  • Linux安装Libreoffice
  • 如何将系统盘MBR转GPT?无损教程分享!
  • 基于element-plus定义表单配置化
  • LeetCode算法题解(贪心)|LeetCode122. 买卖股票的最佳时机 II、LeetCoed55. 跳跃游戏、LeetCode45. 跳跃游戏 II
  • 计蒜客详解合集(2)期
  • 华为防火墙vrrp+hrp双机热备主备备份(两端为交换机)
  • Angular 由一个bug说起之一:List / Grid的性能问题
  • 第12章 PyTorch图像分割代码框架-3:推理与部署
  • MYSQL---基础篇
  • 【启扬方案】启扬安卓屏一体机在医疗自助服务终端上的应用解决方案
  • 收藏!7个国内「小众」的程序员社区
  • LeetCode(4)删除有序数组中的重复项 II【数组/字符串】【中等】
  • C++ 同构字符串/ 单词规律
  • oracle 中 %TYPE %ROWTYPE
  • Pytorch实战教程(五)-计算机视觉基础
  • 51单片机PCF8591数字电压表数码管显示设计( proteus仿真+程序+设计报告+讲解视频)
  • 普华永道于进博会首发“企业数据资源会计处理一体化平台”
  • IDEA 使用Reset Current Branch to Here 进行git 版本控制,图文操作
  • 有趣的 TCP 抢带宽行为