{ "cells": [ { "cell_type": "markdown", "id": "b9c16c30", "metadata": {}, "source": [ "# Read text, coordinates and confidence" ] }, { "cell_type": "code", "execution_count": 1, "id": "dc2f2529", "metadata": { "execution": { "iopub.execute_input": "2026-11-01T06:47:02.740638Z", "iopub.status.busy": "2026-11-01T06:47:02.740519Z", "iopub.status.idle": "2026-11-01T06:47:18.743536Z", "shell.execute_reply": "2026-11-01T06:47:18.743102Z" }, "scrolled": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Loaded DBNet detector (CPU, threads=8)\n", "Loaded SVTR recognizer (vocab=185 chars, CPU, threads=8)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[occular] LM (pure Python): compact_lm.npz (268 MB), unigrams=2010937, alpha=0.5 beta=1.0 beam=100\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "СУПЕРМАРКЕТ «ВОЛГА-МАРКЕТ»\n", "Confidence: 0.996\n", "Corners: [[248.6, 309.4], [674.5, 309.4], [674.5, 330.3], [248.6, 330.3]]\n", "\n", "ул. Белинского, 32\n", "Confidence: 0.996\n", "Corners: [[314.6, 347.7], [613.6, 347.7], [613.6, 370.3], [314.6, 370.3]]\n", "\n", "00О «Волга-Ритейл»\n", "Confidence: 0.859\n", "Corners: [[319.9, 406.9], [617.2, 408.8], [617.0, 431.3], [319.8, 429.3]]\n", "\n" ] } ], "source": [ "from occular import ocr_detailed\n", "\n", "lines = ocr_detailed(\"receipt.jpg\")\n", "for line in lines[:3]:\n", " print(line[\"text\"])\n", " print(\"Confidence:\", round(line[\"confidence\"], 3))\n", " corners = [[round(x, 1), round(y, 1)] for x, y in line[\"quad\"]]\n", " print(\"Corners:\", corners)\n", " print()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }