{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1: define papermill parameters" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "file_path = \"./example.jpg\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2: read file" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import cv2\n", "\n", "img = cv2.imread(file_path)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3: extract text" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "tags": [ "output" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CONSTRUCTION TYPE: VB\n", "\n", "OCCUPANCY TYPE: R-3\n", "\n", "APN: 00302030\n", "\n", "ZONING DISTRICT: R-1\n", "\n", "CONSTRUCTION LOCATION:\n", "\n", "775 Hamilton Ave Palo Alto Ca 94301\n", "\n", "PROJECT OWNER:\n", "\n", "Michael Asher (650) 520-8509 mike.asher@gmail.com\n", "\n", "775 Hamilton Ave Palo Alto Ca 94301\n", "\n", "FIRE SPRINKLERS:\n", "\n", "N/A (EXISTING PRIMARY HOME IS NOT EQUIPPED WITH\n", "\n", "FIRE SPRINKLERS)\n", "\n", "PHOTOVOLTAIC SYSTEM:\n", "\n", "TO BE FILED AS A DEFERRED SUBMITTAL - SEE CF1R\n", "\n", "GROSS FLOOR AREA:\n", "\n", "PROPOSED: 951.62 SQFT\n", "\n", "AV. BLDG. HEIG!\n", "\n", "PROPOSED: 12-4\" FT\n", "\n", "F.AR. CALCS: (800S.F. OF EXEMPT AREA FOR ADU)\n", "\n", "ALLOWABLE F.A.R. 3,450 SOFT\n", "\n", "LOT: 9,352 SQFT\n", "\n", "PRIMARY DWELLING FOOTPRINT: 2.388 SQFT\n", "\n", "PROPOSED ADU FOOTPRINT: 750 SQFT\n", "\n", "PROPOSED JADU FOOTPRINT: 350 SQFT\n", "\n", "RATIO: 29%\n", "\n", "PROJECT SCOPE:\n", "\n", "NEW CONSTRUCTION OF ADU & JADU ATTACHED TO\n", "\n", "EXISTING SINGLE-FAMILY PRIMARY DWELLING UNIT.\n" ] } ], "source": [ "import pytesseract\n", "import cv2\n", "\n", "img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n", "text = pytesseract.image_to_string(img_rgb)\n", "\n", "lines = [line.strip() for line in text.split(\"\\n\")]\n", "lines = [line for line in lines if len(line) > 0]\n", "\n", "print(\"\\n\\n\".join(lines))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.10.6" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }