跳转到主要内容

为特定文本材料提供聪明、简单、直观的OCR包装功能

项目描述

OCRed

ocred

CI Documentation Status pre-commit.ci status codecov discussion

Python Versions Package Version PyPI Downloads License black

All Contributors

OCRed(发音为OCR'd)为特定文本材料提供了聪明、简单、直观的OCR包装功能。您不想学习OCR或帮助您执行OCR的库,但您需要OCR一些内容?这个友好的社区库隐藏了所有这些内容,在简单的函数ocr_meaningful_text()下。

换句话说,您不需要手动预处理,寻找OCR库,学习库,最后得到您所寻找的内容,而是使用OCRed

另一方面,如果您想学习OCR并自行使用著名的OCR库,那么这个库不适合您。但是,它仍然可以作为您旅程的良好开端!

结构

OCR使用OCR类执行,图像预处理使用Preprocessor类执行。所有详细信息都在文档中。

安装

  1. 为您的操作系统安装Tesseract并将其添加到PATH

安装指南可在此处找到。

  1. 使用pip魔法。

OCRed使用现代Python打包,可以使用pip进行安装。

python -m pip install ocred

使用示例

# OCRing a book
import ocred

ocr = ocred.OCR(
    False,  # is_scanned -> to preprocess the image
    "path/to/an/image",  # path
)
ocr.ocr_meaningful_text(save_output=True)
# OCRing a signboard
import ocred

ocr = ocred.OCR(
    True,  # is_scanned -> sign boards don't need to be preprocessed
    "path/to/an/image",  # path
)
extracted_text = ocr.ocr_sparse_text()
print(extracted_text)
# OCRing an invoice
import ocred

ocr = ocred.OCR(
    True,  # is_scanned -> invoices don't need to be preprocessed
    "path/to/an/image",  # path
)
extracted_text = ocr.ocr_sparse_text()
print(extracted_text)

extraxted_info = ocr.process_extracted_text_from_invoice()
print(extraxted_info)
# manually preprocessing an image
import cv2
from scipy import ndimage
from ocred import Preprocessor

preprocessed = Preprocessor("path/to/img.jpg")

# scan the image and copy the scanned image
preprocessed.scan()
orig = preprocessed.img.copy()

# remove noise
preprocessed.remove_noise()

# thicken the ink to draw Hough lines better
preprocessed.thicken_font()

# calculate the median angle of all the Hough lines
_, median_angle = preprocessed.rotate()

# rotate the original scanned image
rotated = ndimage.rotate(orig, median_angle)

# remove noise again
preprocessed = Preprocessor(rotated)
preprocessed.remove_noise()

cv2.imwrite("preprocessed.png", preprocessed.img)

测试

测试文件位于tests目录中。任何新增功能都必须添加新的测试。

要运行测试 -

pytest

一些示例

roof-500x500 OCR

जयपुर JAIPUR 321 आगरा AGRA 554 श्री गगांनगर 242 SRIGANGANAGAR JODHPUR 261 जोधपुर

Page OCR

Preface  This book deals with computer architecture as well as computer organization and design. Computer architecture is concerned with the structure and behavior of the various functional modules of the computer and how they interact to provide the processing needs of the user. Computer organization is concerned with the way the hardware components are connected together to form a computer system. Computer design is concerned with the development of the hardware for the computer taking into consideration a given set of specifications. The book provides the basic knowledge necessary to understand the hardware operation of digital computers and covers the three subjects associated with computer hardware. Chapters 1 through 4 present the various digital components used in the organization and design of digital computers. Chapters 5 through 7 show the detailed steps that a designer must go through in order  to design an elementary basic computer. Chapters 8 through 10 deal with the organization and architecture of the central processing unit. Chapters 11 and 12 present the organization and architecture of input-output and memory. Chapter 13 introduces the concept of multiprocessing. The plan of the book is to present the simpler material first and introduce the more advanced subjects later, Thus, the first seven chapters cover material needed for the basic understanding of computer organization, design, and programming of a simple digital computer. The last six chapters present the organization and architecture of the separate functional units of the digital computer with an emphasis ‘on more advanced topics.  ‘The material in the third edition is organized  in the same manner as in the second edition and many of the features remain the same. The third edition, however, offers several improvements over the second edition. All chapters  ‘two (6 and 10) have been completely revised to bring the material up to date and to clarify the presentation. Two new chapters were added: chapter 9 on pipeline and vector processing, and chapter 13 on multiprocessors. Two sections deal with the reduced instruction set computer (RISC). Chapter 5 has been revised completely to simplify and clarify the design of the basic computer. New problems have been formulated for eleven of the thirteen chapters.  ‘The physical organization of a particular computer including its registers

CosmosOne preprocessed OCR

organisms of our globe, including hydrogen, sodiurn, magnesiuia, and iron. May it not be thai, at least, the brighter stars are like our Sun, the upholding and energizing centres of systems of worlds, adapted to be the abode of living beings?  — William Hugeins, 1865  All my life I have wondered about the possibility of life elsewhere. What would it be like? Of what would it be made? All living things on our planet are constructed of organic molecules ~ complex microscopic architectures in which the carbon atom plays a central role. There was once a time before life, when the Earth was barren and utterly desolate. Our world is now overflowing with life. How did it come about? How, in the absence of life, were carbon-based organic molecules made? How did the first living things arise? How did life evolve to produce beings as elaborate and complex as we, able to explore the mystery of Our Own origins? And on ihe countless other planets that many circle other suns, is there life also? Is extraterrestrial life, if it exists, based on the same organic molecules as life on Earth? Do the beings of other worlds look much like life on Earth? Or are they stunningly different — other adaptations to other environments? What else is possible? The nature of life on Earth and the search for life elsewhere are two sides of the sarne question — the search for who we are.  In the great dark between the stars there are clouds of gas and dust and organic matter. Dozens of different kinds of organic molecules have been found there by radio telescopes. The abundance of these molecules suggests that the stuff of life is everywhere. Perhaps the origin and evolution of life is, given enough time, a cosmic inevitability. On some of the billions of planets in the Milky Way Galaxy, life may never arise. On others, it May arise and die out, or never evolve beyond its simplest forms. And on some small fraction of worlds there may 35

贡献

如果您想为OCRed做出贡献(感谢您!),请查看我们的贡献指南

贡献者✨

感谢这些出色的人们(表情符号键


Saransh

💻 🐛 🖋 📖 🎨 💡 🤔 🚇 🚧 📦 👀 ⚠️ 🧑‍🏫

Priyanshi Goel

🐛

本项目遵循all-contributors规范。欢迎各种形式的贡献!

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

ocred-0.4.0.tar.gz (4.6 MB 查看散列值

上传时间 源代码

构建分发

ocred-0.4.0-py3-none-any.whl (13.0 kB 查看散列值

上传时间 Python 3

支持者:

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面