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

视频聚合网站怎么做不侵权宁波做seo推广企业

视频聚合网站怎么做不侵权,宁波做seo推广企业,上海网站建设目的,软环境建设网站安装 用 Homebrew 来安装 Tesseract brew install tesseract 2. 完成 tessearact 的安装后,还需要安装中文数据包,执行以下两个操作, brew info tesseract 执行这个指令的目的,是找到 Homebrew 把 tesseract 安装在文件夹内&am…

安装

用 Homebrew 来安装 Tesseract

brew install tesseract

2. 完成 tessearact 的安装后,还需要安装中文数据包,执行以下两个操作,

brew info tesseract

执行这个指令的目的,是找到 Homebrew 把 tesseract 安装在文件夹内,例如,

/usr/local/Cellar/tesseract/3.05.02/share/tessdata/.

然后打开 Tesseract 的语言数据包的网页,点击 “chi_sim.traineddata”,电脑自动下载简体中文数据包。

git clone https://github.com/tesseract-ocr/tessdata_fast.git

git clone https://github.com/tesseract-ocr/tessdata_best.git  高清版

GitHub - tesseract-ocr/tessdata_best: Best (most accurate) trained LSTM models.

最后,把简体中文数据包chi_sim.traineddata,复制安装 tesseract 的文件夹内。

命令行用法

我们首先来看tesseract是否正确安装,同时验证版本:

$ tesseract --version
tesseract 4.1.0-rc1-56-g7fbdleptonica-1.76.0libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.4.4 : libopenjp2 2.1.2Found AVX2Found AVXFound SSE

识别的基本用法是”imagename outputbase [options…]”,4.1的版本options只能通过”-l”选择语言,比如:

tesseract test.png test -l chi_sim

它对test.png进行ocr,然后把识别结果保存在test.txt里。默认输出格式是文本文件,我们也可以让它输出pdf:

tesseract test.png test -l chi_sim pdf

除此之外,还有隐藏(extrac)的选项,需要样这个命令才会显示这些高级功能:

$ tesseract --help-extra
Usage:tesseract --help | --help-extra | --help-psm | --help-oem | --versiontesseract --list-langs [--tessdata-dir PATH]tesseract --print-parameters [options...] [configfile...]tesseract imagename|imagelist|stdin outputbase|stdout [options...] [configfile...]OCR options:--tessdata-dir PATH   Specify the location of tessdata path.--user-words PATH     Specify the location of user words file.--user-patterns PATH  Specify the location of user patterns file.--dpi VALUE           Specify DPI for input image.-l LANG[+LANG]        Specify language(s) used for OCR.-c VAR=VALUE          Set value for config variables.Multiple -c arguments are allowed.--psm NUM             Specify page segmentation mode.--oem NUM             Specify OCR Engine mode.
NOTE: These options must occur before any configfile....省略了psm和oem的详细解释,后面会介绍。

比如使用psm,很多老的文档都是:

tesseract test.png test -l chi_sim -psm 1

这在新版本会有问题,必须用–psm才行:

tesseract test.png test -l chi_sim --psm 1

参数–oem指定使用的算法,0代表老的算法;1代表LSTM算法;2代表两者的结合;3代表系统自己选择。

参数–psm指定页面切分模式:

Page segmentation modes:0    Orientation and script detection (OSD) only.1    Automatic page segmentation with OSD.2    Automatic page segmentation, but no OSD, or OCR. (not implemented)3    Fully automatic page segmentation, but no OSD. (Default)4    Assume a single column of text of variable sizes.5    Assume a single uniform block of vertically aligned text.6    Assume a single uniform block of text.7    Treat the image as a single text line.8    Treat the image as a single word.9    Treat the image as a single word in a circle.10    Treat the image as a single character.11    Sparse text. Find as much text as possible in no particular order.12    Sparse text with OSD.13    Raw line. Treat the image as a single text line,bypassing hacks that are Tesseract-specific.

默认是3,也就是自动的页面切分,但是不进行方向(Orientation)和文字(script,其实并不等同于文字,比如俄文和乌克兰文都使用相同的script,中文和日文的script也有重合的部分)的检测。如果我们要识别的是单行的文字,我可以指定7。OSD算法参考这里。我们这里已经知道文字是中文,并且方向是horizontal(从左往右再从上往下的写法,古代中国是从上往下从右往左),因此使用默认的3就可以了。

Java接口

Java接口使用的是javacpp-presets,这个项目强烈推荐Java程序员关注一下!!!它可以让Java开发者调用很多流行的C++库,包括:OpenCV、FFmpeg、OpenBLAS、CPython、LLVM、CUDA、MXNet、TensorFlow等等。当然也包括我们这里用到的Leptonica和Tesseract。

依赖
		<dependency><groupId>org.bytedeco.javacpp-presets</groupId><artifactId>tesseract-platform</artifactId><version>4.0.0-1.4.4</version></dependency>

我们这里只把C++的基本用法和按行输出用Java实现,其它的例子读者依葫芦画瓢把C++代码变成等价的Java代码就行了。javacpp-presets实现的代码和C++基本长得一样。

基本例子

完整代码在这里。

BytePointer outText;TessBaseAPI api = new TessBaseAPI();
// Initialize tesseract-ocr with English, without specifying tessdata path
if (api.Init(null, "eng") != 0) {System.err.println("Could not initialize tesseract.");System.exit(1);
}// Open input image with leptonica library
PIX image = pixRead(args.length > 0 ? args[0] : "testen-1.png");
api.SetImage(image);
// Get OCR result
outText = api.GetUTF8Text();
System.out.println("OCR output:\n" + outText.getString());// Destroy used object and release memory
api.End();
api.close();
outText.deallocate();
pixDestroy(image);

上面的代码和C++的基本长得一样,因为C++没有GC,因此需要下面那些销毁对象的操作。如果要识别中文,那么需要修改Init的第二个参数:

if (api.Init(null, "chi_sim") != 0) {

但是如果直接执行,会出现如下错误:

Error opening data file /home/travis/build/javacpp-presets/tesseract/cppbuild/linux-x86_64/share/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Could not initialize tesseract.

也就是默认会去”/home/travis/build/…“找模型,这是travis ci的路径,我们的机器当然没有。

为了解决这个问题有两种办法,第一种是运行程序是设置环境变量:

# 读者需要改成自己的路径
export TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata
java -cp .....

另外一种方法就是调用init的时候指定路径:

if (api.Init("/usr/share/tesseract-ocr/4.00/tessdata", "eng") != 0) {System.err.println("Could not initialize tesseract.");System.exit(1);
}
按行输出

完整代码在这里。

BOXA boxes = api.GetComponentImages(tesseract.RIL_TEXTLINE, true, (PointerPointer) null, null);
System.out.print(String.format("Found %d textline image components.\n", boxes.n()));
for (int i = 0; i < boxes.n(); i++) {BOX box = boxes.box(i);api.SetRectangle(box.x(), box.y(), box.w(), box.h());BytePointer text = api.GetUTF8Text();int conf = api.MeanTextConf();System.out.println(String.format("Box[%d]: x=%d, y=%d, w=%d, h=%d, confidence: %d, text: %s",i, box.x(), box.y(), box.w(), box.h(), conf, text.getString()));text.deallocate();
}

另还有一种方法

<!--tess4J ocr图像识别-->
        <dependency>
            <groupId>net.sourceforge.tess4j</groupId>
            <artifactId>tess4j</artifactId>
            <version>4.4.1</version>

        </dependency>
                        
原文链接:https://blog.csdn.net/qq_39522120/article/details/135503159

http://www.khdw.cn/news/3090.html

相关文章:

  • 设计师网站登录重庆seo排名扣费
  • 橙子建站 推广百度推广入口
  • 东莞网站设计建设网络营销概述ppt
  • 网络工程二本最好的出路网站seo视频
  • 成都旅游必去景点有哪些宁波seo排名方案优化公司
  • 做网站写需求企业品牌网站营销
  • 做网站建设的一般在哪儿找2345浏览器导航页
  • 建设一个网站需要什么人员国内哪个搜索引擎最好用
  • 龙华网站建设全包客源引流推广app
  • 宁乡网站建设点燃网络外贸网站有哪些
  • joomla 网站建设教程北京seo执行
  • 如何把自己做的网站放到微信上怎么做营销推广方案
  • 如何做招聘网站网络营销的新特点
  • 如何获取网站js图片郑州做网站的大公司
  • 手机网站搭建用什么软件?基本seo技术在线咨询
  • 丹东网站建设如何在各大网站发布信息
  • seo综合查询接口seo搜索引擎专员
  • 网站开发维护任职要求seo技术培训广东
  • 做一手楼房的网站西安竞价托管
  • 网站认证打款怎么做分录seo竞价培训
  • 58同城长沙回收网站建设知乎seo
  • 装修公司做网站推广能接到活吗淘宝优秀软文范例100字
  • 微信公众号商城网站开发整合营销传播的明显特征是
  • 建设网站杭州如何在百度做免费推广产品
  • 微信 网站 优劣势关联词有哪些
  • 哪家专门做特卖的网站?项目推广方式有哪些
  • 手机怎样建网站营销策略主要包括哪些
  • 深圳官网网站建设设计网站的软件
  • 网站建设控制面板怎么设置网站排名查询平台
  • WordPress修改模板seo网站编辑是做什么的