diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..7fec51502cbc3200b3d0ffc6bbba1fe85e197f3d --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/.ipynb_checkpoints/openCV_scanner-checkpoint.ipynb b/.ipynb_checkpoints/openCV_scanner-checkpoint.ipynb index aa6048d7a9c3c5a47ab94da4532646a732f5d6da..313abaf19e2933cc1ffc3d469befa6dd80f71245 100644 --- a/.ipynb_checkpoints/openCV_scanner-checkpoint.ipynb +++ b/.ipynb_checkpoints/openCV_scanner-checkpoint.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 267, + "execution_count": 301, "metadata": { "scrolled": true }, @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 268, + "execution_count": 302, "metadata": {}, "outputs": [], "source": [ @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 269, + "execution_count": 303, "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 270, + "execution_count": 304, "metadata": {}, "outputs": [], "source": [ @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 271, + "execution_count": 305, "metadata": {}, "outputs": [], "source": [ @@ -136,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 272, + "execution_count": 306, "metadata": {}, "outputs": [], "source": [ @@ -171,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 273, + "execution_count": 307, "metadata": {}, "outputs": [], "source": [ @@ -185,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 274, + "execution_count": 308, "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 275, + "execution_count": 309, "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ " #print(\"max_index = \",max_index)\n", " image_fixed = image.copy()\n", " if max_index < 0:\n", - " print(\"max_index < 0 \" +i)\n", + " print(\"max_index < 0, return points \")\n", " #print(points)\n", " return points\n", "\n", @@ -308,12 +308,12 @@ }, { "cell_type": "code", - "execution_count": 276, + "execution_count": 310, "metadata": {}, "outputs": [], "source": [ "def b1event():\n", - " print(sizes)\n", + " global step\n", " if sizes == 4:\n", " cv2.namedWindow('input')\n", " cv2.setMouseCallback(\"input\", mouse_callback, 0);\n", @@ -334,12 +334,12 @@ " cv2.imshow('input', image_result)\n", " cv2.imshow('result', image_final)\n", " cv2.imwrite('./modified/' +i, image_final)\n", - " print(i + \" save final image!\")\n", + " print(i + \" i got 4 edges!!\")\n", " \n", " else:\n", " cv2.imshow('input', image)\n", " cv2.imwrite('./modified/' +i, image)\n", - " print(i + \" not yet..!\")\n", + " print(i + \" i don't got 4 edges!\")\n", " cv2.waitKey(0)\n", " cv2.destroyAllWindows()\n", " win.destroy()" @@ -347,7 +347,7 @@ }, { "cell_type": "code", - "execution_count": 277, + "execution_count": 311, "metadata": {}, "outputs": [], "source": [ @@ -356,11 +356,11 @@ " image_final = transform(image, points)\n", " cv2.imshow('result', image_final)\n", " cv2.imwrite('./modified/' +i, image_final)\n", - " print(i + \" save thresh!\")\n", + " print(i + \" i got 4 edges!!/no button\")\n", " else:\n", " cv2.imshow('input', image)\n", " cv2.imwrite('./modified/' +i, image)\n", - " print(i + \" not yet..!\")\n", + " print(i + \" i don't got 4 edges!/no button\")\n", " cv2.waitKey(0)\n", " cv2.destroyAllWindows()\n", " win.destroy()" @@ -368,27 +368,26 @@ }, { "cell_type": "code", - "execution_count": 278, + "execution_count": 312, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "max_index < 0 document.jpg\n", + "max_index < 0, return points \n", "size 0\n", - "0\n", - "document.jpg not yet..!\n", - "max_index < 0 receipt2.jpg\n", - "size 0\n", - "0\n", - "receipt2.jpg not yet..!\n", + "document.jpg i don't got 4 edges!\n", + "len of max_contour 5\n", + "size 4\n", + "[19. 70.] [121. 24.] [199. 157.] [106. 213.]\n", + "89.0 145.0 356.0 319.0\n", + "receipt2.jpg i got 4 edges!!\n", "len of max_contour 8\n", "size 4\n", - "4\n", - "[13. 48.] [149. 27.] [170. 218.] [ 36. 238.]\n", - "61.0 176.0 388.0 274.0\n", - "tilted receipt.jpg save final image!\n" + "[18. 45.] [138. 32.] [158. 211.] [ 39. 225.]\n", + "63.0 170.0 369.0 264.0\n", + "tilted receipt.jpg i got 4 edges!!\n" ] } ], @@ -484,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": 266, + "execution_count": 286, "metadata": {}, "outputs": [ { @@ -494,7 +493,7 @@ "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-266-d25ce1a2f34d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#이미지 저장\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mfpdf\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mFPDF\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPIL\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mImage\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m<ipython-input-286-0a916bbbf96e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#이미지 저장\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;31m##################아직 안합침################################\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mfpdf\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mFPDF\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPIL\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mImage\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'fpdf'" ] } diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..956cbd9b30aa743e3fea875a6b9aaffd427aae97 --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/modified/receipt2.jpg b/modified/receipt2.jpg index fae3687cc7f737191e7f9251389ce46a77b869e4..86a073a944046fbcba804e12c7125e8d05ebd02a 100644 Binary files a/modified/receipt2.jpg and b/modified/receipt2.jpg differ diff --git a/modified/tilted receipt.jpg b/modified/tilted receipt.jpg index b736745a4852da42d9148b5174298aec54292ab1..2e8bc76c5dbd58373f61493124133ffbe3240f77 100644 Binary files a/modified/tilted receipt.jpg and b/modified/tilted receipt.jpg differ diff --git a/openCV_scanner.ipynb b/openCV_scanner.ipynb index aa6048d7a9c3c5a47ab94da4532646a732f5d6da..313abaf19e2933cc1ffc3d469befa6dd80f71245 100644 --- a/openCV_scanner.ipynb +++ b/openCV_scanner.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 267, + "execution_count": 301, "metadata": { "scrolled": true }, @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 268, + "execution_count": 302, "metadata": {}, "outputs": [], "source": [ @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 269, + "execution_count": 303, "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 270, + "execution_count": 304, "metadata": {}, "outputs": [], "source": [ @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 271, + "execution_count": 305, "metadata": {}, "outputs": [], "source": [ @@ -136,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 272, + "execution_count": 306, "metadata": {}, "outputs": [], "source": [ @@ -171,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 273, + "execution_count": 307, "metadata": {}, "outputs": [], "source": [ @@ -185,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 274, + "execution_count": 308, "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 275, + "execution_count": 309, "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ " #print(\"max_index = \",max_index)\n", " image_fixed = image.copy()\n", " if max_index < 0:\n", - " print(\"max_index < 0 \" +i)\n", + " print(\"max_index < 0, return points \")\n", " #print(points)\n", " return points\n", "\n", @@ -308,12 +308,12 @@ }, { "cell_type": "code", - "execution_count": 276, + "execution_count": 310, "metadata": {}, "outputs": [], "source": [ "def b1event():\n", - " print(sizes)\n", + " global step\n", " if sizes == 4:\n", " cv2.namedWindow('input')\n", " cv2.setMouseCallback(\"input\", mouse_callback, 0);\n", @@ -334,12 +334,12 @@ " cv2.imshow('input', image_result)\n", " cv2.imshow('result', image_final)\n", " cv2.imwrite('./modified/' +i, image_final)\n", - " print(i + \" save final image!\")\n", + " print(i + \" i got 4 edges!!\")\n", " \n", " else:\n", " cv2.imshow('input', image)\n", " cv2.imwrite('./modified/' +i, image)\n", - " print(i + \" not yet..!\")\n", + " print(i + \" i don't got 4 edges!\")\n", " cv2.waitKey(0)\n", " cv2.destroyAllWindows()\n", " win.destroy()" @@ -347,7 +347,7 @@ }, { "cell_type": "code", - "execution_count": 277, + "execution_count": 311, "metadata": {}, "outputs": [], "source": [ @@ -356,11 +356,11 @@ " image_final = transform(image, points)\n", " cv2.imshow('result', image_final)\n", " cv2.imwrite('./modified/' +i, image_final)\n", - " print(i + \" save thresh!\")\n", + " print(i + \" i got 4 edges!!/no button\")\n", " else:\n", " cv2.imshow('input', image)\n", " cv2.imwrite('./modified/' +i, image)\n", - " print(i + \" not yet..!\")\n", + " print(i + \" i don't got 4 edges!/no button\")\n", " cv2.waitKey(0)\n", " cv2.destroyAllWindows()\n", " win.destroy()" @@ -368,27 +368,26 @@ }, { "cell_type": "code", - "execution_count": 278, + "execution_count": 312, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "max_index < 0 document.jpg\n", + "max_index < 0, return points \n", "size 0\n", - "0\n", - "document.jpg not yet..!\n", - "max_index < 0 receipt2.jpg\n", - "size 0\n", - "0\n", - "receipt2.jpg not yet..!\n", + "document.jpg i don't got 4 edges!\n", + "len of max_contour 5\n", + "size 4\n", + "[19. 70.] [121. 24.] [199. 157.] [106. 213.]\n", + "89.0 145.0 356.0 319.0\n", + "receipt2.jpg i got 4 edges!!\n", "len of max_contour 8\n", "size 4\n", - "4\n", - "[13. 48.] [149. 27.] [170. 218.] [ 36. 238.]\n", - "61.0 176.0 388.0 274.0\n", - "tilted receipt.jpg save final image!\n" + "[18. 45.] [138. 32.] [158. 211.] [ 39. 225.]\n", + "63.0 170.0 369.0 264.0\n", + "tilted receipt.jpg i got 4 edges!!\n" ] } ], @@ -484,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": 266, + "execution_count": 286, "metadata": {}, "outputs": [ { @@ -494,7 +493,7 @@ "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-266-d25ce1a2f34d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#이미지 저장\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mfpdf\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mFPDF\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPIL\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mImage\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m<ipython-input-286-0a916bbbf96e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#이미지 저장\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;31m##################아직 안합침################################\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mfpdf\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mFPDF\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPIL\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mImage\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'fpdf'" ] } diff --git a/images/receipt.jpg b/receipt.jpg similarity index 100% rename from images/receipt.jpg rename to receipt.jpg