首页 文章 精选 留言 我的

精选列表

搜索[博客系统],共10000篇文章
优秀的个人博客,低调大师

[雪峰磁针石博客]tesseract OCR识别工具及pytesseract

简介 可以使用pytesseract库从图像中提取文本。Tesseract是一款由Google赞助的开源OCR。 pytesseract是python包装器,它为可执行文件提供了pythonic API。 Tesseract(/'tesərækt/) 这个词的意思是"超立方体",指的是几何学里的四维标准方体,又称"正八胞体"。下图是一个正八胞体绕着两个四维空间中互相正交的平面进行双旋转时的透视投影。不过这里要讲的,是一款以其命名的开源 OCR(Optical Character Recognition, 光学字符识别) 软件。 所谓 OCR 是图像识别领域中的一个子领域,该领域专注于对图片中的文字信息进行识别并转换成能被常规文本编辑器编辑的文本。 Tesseract 已经有 30 年历史,开始它是惠普实验室的一款专利软件,然后在 2005 年开源,自 2006 年后由 Google 赞助进行后续的开发和维护。 在 1995 年 Tesseract 曾是世界前三的 OCR 引擎,而且在现在的免费 OCR 引擎中,其识别精度也仍然是出类拔萃的。因为其免费与较好的效果,许多的个人开发者以及一些较小的团队在使用着 Tesseract ,诸如验证码识别、车牌号识别等应用中,不难见到 Tesseract 的身影。 安装 以ubuntu 16.04为例 # pip3 install pytesseract # apt install tesseract-ocr tesseract-ocr-chi-sim 快速入门 #!/usr/bin/python # -*- coding: utf-8 -*- # Author: china-testing@126.com wechat:pythontesting qq群:144081101 # CreateDate: 2018-04-25 import pytesseract as pt import requests from PIL import Image #img = Image.open("textinimage.png") print("英文:") url = "https://china-testing.github.io/images/python_lib_ocr_en.png" img = Image.open(requests.get(url, stream=True).raw) text = pt.image_to_string(img) print(text) #img = Image.open("textinimage.png") print("中文:") url = "https://china-testing.github.io/images/python_lib_ocr.PNG" img = Image.open(requests.get(url, stream=True).raw) text = pt.image_to_string(img,lang='chi_sim') print(text) 执行结果 $ python3 04_10_perform_ocr.py 英文: This is an image containing text. And some numbers 123456789 And also special characters: !@#$%"&*(_+ 中文: pyth0"自动化测试人工智能 可见中文识别的效果并不太好,为此很多公司进行机器学习来改进。 另外网易的有道云笔记的OCR效果做得很不错,白描的凑合能用,qq的扫二维码也可以识别文字,但是做得比较烂。 ocr可以做python项目对初学者进行实践,请联系微信:pythontesting 本文最新代码地址,后续相关ocr的资料也会放在这里。 另外tesseract也可以命令行执行: $ tesseract test22.png stdout -l chi_sim pyth0n自动化测试人工智能 参考资料 讨论qq群144081101 591302926 567351477 钉钉免费群21745728 本文相关书籍下载 本文最新版本地址 本文涉及的python测试开发库 谢谢点赞! ImageMagick Tesseract:安装与命令行使用 Tesseract OCR:Ubuntu 16.04上的安装和使用

优秀的个人博客,低调大师

[雪峰磁针石博客]人脸识别工具:face_recognition

简介 face_recognition使用世界上最简单的人脸识别工具,在Python或命令行中识别和操作人脸。 使用dlib最先进的人脸识别技术构建而成,并具有深度学习功能。 该模型在Labeled Faces in the Wild基准中的准确率为99.38%。 另外还提供了face_recognition命令行工具! 快速入门 本节我们基于ubuntu16.04,python3,使用如下图片: image.png 快速入门 face_recognition import face_recognition image = face_recognition.load_image_file("test0.jpg") face_locations = face_recognition.face_locations(image,model="cnn") print(face_locations) 执行结果: $ python3 quick.py [(203, 391, 447, 147)] model选择模型,默认为hog,该模式很多图片是无法识别的,为此一般用采用更精确但是速度更慢的cnn模型。 显示图片: quick2.py import face_recognition from PIL import Image image = face_recognition.load_image_file("test0.jpg") face_locations = face_recognition.face_locations(image,model="cnn") top, right, bottom, left = face_locations[0] print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right)) face_image = image[top:bottom, left:right] pil_image = Image.fromarray(face_image) pil_image.show() pil_image.save("quick2.jpg") 执行后会在当前目录生成quick2.jpg,并在屏幕显示美女头像。 image.png 上口红 quick3.py import face_recognition from PIL import Image, ImageDraw image = face_recognition.load_image_file("test1.jpg") face_landmarks_list = face_recognition.face_landmarks(image) print(face_landmarks_list) for face_landmarks in face_landmarks_list: pil_image = Image.fromarray(image) d = ImageDraw.Draw(pil_image, 'RGBA') # Gloss the lips d.polygon(face_landmarks['top_lip'], fill=(150, 0, 0, 128)) d.polygon(face_landmarks['bottom_lip'], fill=(150, 0, 0, 128)) d.line(face_landmarks['top_lip'], fill=(150, 0, 0, 64), width=3) d.line(face_landmarks['bottom_lip'], fill=(150, 0, 0, 64), width=3) pil_image.show() pil_image.save("quick3.jpg") 上口红之前: image.png 上口红之后: image.png 个人总是觉得没上口红的更好看,偏偏有那么多喜欢化成妖怪的女人。 框选 下面代码把脸部框选出来,注意:face_locations返回的图片和PIL使用的坐标不同,为此需要一定的转换。 quick4.py import face_recognition from PIL import Image, ImageDraw image = face_recognition.load_image_file("test1.jpg") locations = face_recognition.face_locations(image) print(locations) pos = locations[0] pil_image = Image.fromarray(image) d = ImageDraw.Draw(pil_image, 'RGBA') d.rectangle((pos[3], pos[0], pos[1], pos[2])) pil_image.show() pil_image.save("quick4.jpg") image.png 本文代码地址: https://github.com/china-testing/python-api-tesing/tree/master/python3_libraries/face_recognition 其他 旋转 face_recognition只能识别头在上嘴在下的图片比较好,如果你的照片是横向的,有可能要旋转才能识别。 image.png sleep.py import face_recognition from PIL import Image, ImageDraw image = face_recognition.load_image_file("sleep.jpg") locations = face_recognition.face_locations(image) print(locations) img = Image.open("sleep.jpg") img = img.rotate(90,expand=1) img.save("/tmp/tmp.jpg") image = face_recognition.load_image_file("/tmp/tmp.jpg") locations = face_recognition.face_locations(image) print(locations) pil_image = Image.fromarray(image) pil_image.show() 执行结果: [] [(166, 424, 255, 335)] 当然此图使用cnn模式不用旋转也是可以识别的,但是我们实验中发现一些图片,比如戴墨镜的横向图片,还是要旋转才能识别。 注意旋转方向是逆时针的。 参考资料 本文涉及的python测试开发库 请在github上点赞,谢谢! 讨论 钉钉免费群21745728 qq群144081101 567351477 本文相关海量书籍下载 https://github.com/ageitgey/face_recognition

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册