receipt_indexer/code/autocropper/notebooks/oldnotebooks/manualcropandrotate.ipynb
Ethan Wellenreiter 423b511dd9 Cleanup commit
Moving around the testing notebooks. Autocropping is about done
with exception to any new versions or converting the stuff to C
code.

Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
2023-10-18 22:48:24 -04:00

95 lines
2.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np\n",
"\n",
"import torch\n",
"import torchvision.transforms.functional as tvf\n",
"import torchvision.transforms.v2 as v2\n",
"import torchvision.transforms as t\n",
"import myfunctions as mf\n",
"\n",
"from skimage import io\n",
"from matplotlib import pyplot as plt\n",
"import time\n",
"\n",
"import myfunctions as mf"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"# read image as grayscale\n",
"img = cv2.imread('./test_images/IMG_7594.jpg')"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cropped = mf.morphologyCrop(img)\n",
"# rotated = deskew(cropped)\n",
"# cropped2 = morphologyCrop(rotated)\n",
"# cropped2 = selectiveSearchCrop(rotated)\n",
"# cropped3 = cannyEdgeCrop(cropped2)\n",
"cv2.imwrite(\"./testing_space/final.jpg\", cropped)\n",
"# final = rotate(cropped2, 180) # need to implement the code to determine if a doc is upside down"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"### Deskew seems to work \n",
"# Note licencing for the deskew package and "
]
}
],
"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.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}