All Projects → Lynnesbian → Ocrbot

Lynnesbian / Ocrbot

Licence: agpl-3.0
An OCR (Optical Character Recognition) bot for Mastodon (and compatible) instances

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Ocrbot

ocr
Simple app to extract text from pictures using Tesseract
Stars: ✭ 98 (+151.28%)
Mutual labels:  ocr, tesseract
Ccextractor
CCExtractor - Official version maintained by the core team
Stars: ✭ 356 (+812.82%)
Mutual labels:  ocr, tesseract
breach-protocol-autosolver
Solve breach protocol minigame in second(s). Windows/Linux/GeForce Now/Google Stadia. Every language.
Stars: ✭ 28 (-28.21%)
Mutual labels:  ocr, tesseract
cordova-plugin-tesseract
Cordova Plugin for OCR process using Tesseract
Stars: ✭ 70 (+79.49%)
Mutual labels:  ocr, tesseract
Easyocr
Java OCR 识别组件(基于Tesseract OCR 引擎)。能自动完成图片清理、识别 CAPTCHA 验证码图片内容的一体化工作。Java Image cleanup, OCR recognition component (based Tesseract OCR engine, automatically cleanup image and identification CAPTCHA verification code picture content).
Stars: ✭ 466 (+1094.87%)
Mutual labels:  ocr, tesseract
staff identity card ocr project
Staff Identity Card OCR Project
Stars: ✭ 15 (-61.54%)
Mutual labels:  ocr, tesseract
Card Ocr
身份证识别OCR
Stars: ✭ 345 (+784.62%)
Mutual labels:  ocr, tesseract
tesseract-ocr
Node.js wrapper for Tesseract OCR CLI.
Stars: ✭ 29 (-25.64%)
Mutual labels:  ocr, tesseract
Ocrmypdf
OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched
Stars: ✭ 5,549 (+14128.21%)
Mutual labels:  ocr, tesseract
React Native Tesseract Ocr
Tesseract OCR wrapper for React Native
Stars: ✭ 384 (+884.62%)
Mutual labels:  ocr, tesseract
Cogstack Pipeline
Distributed, fault tolerant batch processing for Natural Language Applications and Search, using remote partitioning
Stars: ✭ 26 (-33.33%)
Mutual labels:  ocr, tesseract
Tesseract
A PHP wrapper for the Tesseract OCR engine
Stars: ✭ 19 (-51.28%)
Mutual labels:  ocr, tesseract
TesseractStudio.Net
A free Windows graphical interface to the Tesseract 4.0 OCR engine.
Stars: ✭ 38 (-2.56%)
Mutual labels:  ocr, tesseract
Javascript Bcr Library
Offline business card reader
Stars: ✭ 24 (-38.46%)
Mutual labels:  ocr, tesseract
IdCardRecognition
Android id card recognition based on OCR. 安卓基于OCR的身份证识别。
Stars: ✭ 35 (-10.26%)
Mutual labels:  ocr, tesseract
Qanswer
【Deprecated】🥇🥇🥇 冲顶大会等游戏答题助手,提供答题辅助决策 ,帮助顺利吃鸡
Stars: ✭ 326 (+735.9%)
Mutual labels:  ocr, tesseract
textocry
Textocry - Copy text from Images (chrome extension)
Stars: ✭ 29 (-25.64%)
Mutual labels:  ocr, tesseract
LaraOCR
Laravel Optical Character Reader(OCR) package using ocr engines like Tesseract
Stars: ✭ 88 (+125.64%)
Mutual labels:  ocr, tesseract
Tessdata
Trained models with support for legacy and LSTM OCR engine
Stars: ✭ 4,173 (+10600%)
Mutual labels:  ocr, tesseract
Tesseract.js
Pure Javascript OCR for more than 100 Languages 📖🎉🖥
Stars: ✭ 25,246 (+64633.33%)
Mutual labels:  ocr, tesseract

OCRbot

OCRbot is a Mastodon (and compatible, such as Pleroma) bot that uses OCR to automatically generate text descriptions of images. It reads the image and outputs what it thinks is the text contained, using tesseract. It requires Python 3.

Screenshot of OCRbot in action

Working Example

A working version of OCRbot can be found here. I'll always run the latest version, and the instance hosting it has a much higher character limit than Mastodon's default of 500 or Pleroma's default of 5000 (specifically, it has a limit of 65535 chars). If you'd like to run your own version that works differently (for example, maybe you want a version that works with Japanese text instead, or a version that uses a different OCR engine), then you're free to fork and modify!

Installation

Tesseract (Required)

  • Debian/Ubuntu: sudo apt install tesseract-ocr
  • Arch Linux: sudo pacman -Syu tesseract tesseract-data-eng

What about the higher quality data packs?

According to tesseract's GitHub wiki:

Most users will want tessdata_fast and that is what will be shipped as part of Linux distributions. tessdata_best is for people willing to trade a lot of speed for slightly better accuracy.

With the setup I'm using, I really can't afford to use much more processing power just for "slightly better accuracy". Additionally, most Linux distributions only ship the fast set, which makes obtaining the best set an extra step. I haven't tested how much better fast is than best, but given that distributions like Arch and Debian deemed fast good enough to be the only package available, I'm inclinded to suspect that this is a case of diminishing returns, and that it's not worth the extra effort of obtaining these files, as well as the extra CPU usage required to use them.

OCRbot (Required)

git clone https://github.com/Lynnesbian/OCRbot/
cd OCRbot
pip3 install -r requirements.txt

Running OCRbot

Initial Setup

Run login.py, and answer the interactive prompts. To further configure OCRbot, open config.json and edit the settings as you wish. Here is an explanation of the options in the config file:

Setting Meaning Example
site The instance your bot will log in to and post from. https://botsin.space
cw The content warning (aka subject) OCRbot will apply to non-error posts. OCR output
ocr_threads The amount of CPU threads to use for running tesseract. 8
char_limit The maximum length of an OCRbot post. This limit does not apply to errors. I recommend setting it to your instance's character limit. 500
default_language The language you'd like OCRbot to default to. eng
admin The account you'd like OCRbot to tell users to report errors to. If you format it as [email protected] (omitting the leading @ sign), it won't automatically tag you. This ensures your notifications don't get flooded if the bot breaks. [email protected]

Most importantly, make sure you choose the instance your OCRbot account will post from. Then, run login.py and log in with the account you'd like OCRbot to post from. Finally, run service.py and OCRbot will take care of the rest.

Running OCRbot as a Service

You can use something like systemd or SysVinit to manage running service.py for you. I've provided an example systemd script here. It requires some editing (to specify where your OCRbot folder is located, and to specify the user to run it as -- don't run it as root), and then you simply need to

sudo mv systemd-example.service /etc/systemd/system/OCRbot.service
sudo systemctl start OCRbot

You may also sudo systemctl enable OCRbot if you want it to start on boot.

Caveats

OCRbot is not designed to replace captions, merely to supplement them. It works best with plain black text on a plain white background. For example, PDF scans and Wikipedia screenshots will work great, but handwriting and distorted text won't. It will almost always fail (at least partially) for:

  • Anything using handwriting, especially cursive
  • Text that is skewed, rotated, stretched, or otherwise distorted
  • Heavily compressed images
  • Text with layouts more complex than this page
  • WordArt
  • Unusual fonts
  • Videos and GIFs
  • Very large or very small text
  • Text on a complex background
  • Vertical text in a language where text is usually written horizontally, and vice versa

Additionally, OCRbot may sometimes fail to find images due to federation issues. This is a known issue, and OCRbot does its best to work around it, but due to the way federation works, it will never be completely solved.

If you can caption images yourself, I recommend doing so. If, for example, you are posting a screenshot of a tweet, you'll get better results from copy and pasting the text of the tweet as a caption rather than relying on OCRbot. OCRbot's image recognition is far from perfect and never will be.

Support for Other Languages

OCRbot is capable of supporting languages other than English. If you are using Debian, you can install the package tesseract-ocr-all to install all language files, or install individual ones, such as tesseract-ocr-jpn for Japanese. Arch also provides these packages, with slightly different names (e.g. tesseract-data-jpn), although it does not have an "all" package.

Errors

While invoking OCRbot, you may encounter a number of errors. While the text is somewhat self explanatory, this section exists to provide further elaboration on their meaning.

Error message Explanation
Couldn't find any media. OCRbot was unable to find any posts that had images attached, usually because your post or the one you're replying to doesn't have any images. It could also happen if the images have failed to federate properly.
Failed to find post containing image. This may be a federation issue, or you may have tagged OCRbot in a conversation without an image. Please note that OCRbot can only see images in the post you are directly replying to, and can't see images that are provided as URLs rather than attachments. (see above)
Specified post has no images. OCRbot successfully loaded the post, and was unable to find any images. This means that your post or the one you're replying to definitely doesn't have any images.
Couldn't read the specified image(s), sorry! OCRbot works best with plain black text on a plain white background. Here is some information about what it can and can't do: https://github.com/Lynnesbian/OCRbot/blob/master/README.md#caveats OCRbot couldn't read your image. In the same way that you would have trouble reading a blurry photo of text, OCRbot has trouble with things such as cursive handwriting, rotated text, strange fonts, and more. Check the caveats section on this page for more information.
Tesseract returned no text. Either your image contains no text, or tesseract (the program OCRbot relies on) encountered an error and returned nothing.
Failed to read image. Download may have timed out. If any one image takes longer than 30 seconds to download, OCRbot gives up on it. This can occur because a server is down, experiencing slowdown, or most likely, because wasabi is down.
Failed to run tesseract. Specified language was: [language] Tesseract, the program OCRbot relies on to provide captions, crashed.

Donating

Please don't feel obligated to donate at all. Donations can be provided via PayPal or Ko-fi. Don't feel obligated to donate!

License

Copyright (C)2019 Lynnesbian (https://fedi.lynnesbian.space/@lynnesbian)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

The full text of the license is provided under the name "LICENSE" in the root directory of this repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].