Image.ocr#
- Image.ocr(minconf: int = 50, plot: bool = False, return_bbox: bool = False) list[OCRWord][source]#
Optical character recognition
- Parameters:
minconf (int, optional) – minimum confidence value for text to be returned or plotted (percentage), defaults to 50
plot (bool, optional) – overlay detected text on the current plot, assumed to be the image, defaults to False
- Returns:
detected strings and metadata
- Return type:
list of
OCRWord
Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Read('penguins.png') >>> for word in img.ocr(minconf=90): ... print(word) pytesseract is required for OCR functionality. Install it with: pip install pytesseract or pip install machinevision-toolbox-python[ocr] Install the tesseract OCR engine from https://github.com/tesseract-ocr/tesseract?tab=readme-ov-file#installing-tesseract
Each recognized text string is described by an
OCRWordinstance that contains the string, confidence and bounding box within the image.Warning
PyTessearct must be installed.
- References:
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 12.4.1.
- Seealso:
OCRWord