From a42d3c3c5dada567d9d7fb1d675f6d9a5e6b181c Mon Sep 17 00:00:00 2001 From: Norbert Date: Mon, 15 Jun 2020 00:32:25 +0200 Subject: [PATCH] add form, make something --- .vscode/settings.json | 3 + .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 160 bytes .../__pycache__/settings.cpython-38.pyc | Bin 0 -> 2357 bytes .../__pycache__/urls.cpython-38.pyc | Bin 0 -> 996 bytes .../__pycache__/wsgi.cpython-38.pyc | Bin 0 -> 577 bytes bibrecognition/bibrecognition/settings.py | 1 + bibrecognition/db.sqlite3 | Bin 151552 -> 155648 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 157 bytes .../__pycache__/admin.cpython-37.pyc | Bin 194 -> 194 bytes .../__pycache__/admin.cpython-38.pyc | Bin 0 -> 364 bytes .../__pycache__/apps.cpython-38.pyc | Bin 0 -> 387 bytes .../__pycache__/forms.cpython-38.pyc | Bin 0 -> 510 bytes .../__pycache__/models.cpython-38.pyc | Bin 0 -> 1113 bytes .../__pycache__/urls.cpython-38.pyc | Bin 0 -> 326 bytes .../__pycache__/views.cpython-38.pyc | Bin 0 -> 744 bytes bibrecognition/imguploader/admin.py | 7 + bibrecognition/imguploader/forms.py | 7 + bibrecognition/imguploader/functions.py | 189 ++++++++++++++++++ .../migrations/0002_auto_20200210_1945.py | 23 +++ .../migrations/0003_competitions_status.py | 18 ++ .../__pycache__/0001_initial.cpython-38.pyc | Bin 0 -> 1098 bytes .../0002_auto_20200210_1945.cpython-38.pyc | Bin 0 -> 711 bytes .../0003_competitions_status.cpython-38.pyc | Bin 0 -> 634 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 168 bytes bibrecognition/imguploader/models.py | 3 + .../imguploader/templates/index.html | 15 ++ .../imguploader/templates/upload.html | 15 ++ bibrecognition/imguploader/urls.py | 3 +- bibrecognition/imguploader/views.py | 19 +- main.py | 2 +- 30 files changed, 302 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 bibrecognition/bibrecognition/__pycache__/__init__.cpython-38.pyc create mode 100644 bibrecognition/bibrecognition/__pycache__/settings.cpython-38.pyc create mode 100644 bibrecognition/bibrecognition/__pycache__/urls.cpython-38.pyc create mode 100644 bibrecognition/bibrecognition/__pycache__/wsgi.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/__init__.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/admin.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/apps.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/forms.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/models.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/urls.cpython-38.pyc create mode 100644 bibrecognition/imguploader/__pycache__/views.cpython-38.pyc create mode 100644 bibrecognition/imguploader/forms.py create mode 100644 bibrecognition/imguploader/functions.py create mode 100644 bibrecognition/imguploader/migrations/0002_auto_20200210_1945.py create mode 100644 bibrecognition/imguploader/migrations/0003_competitions_status.py create mode 100644 bibrecognition/imguploader/migrations/__pycache__/0001_initial.cpython-38.pyc create mode 100644 bibrecognition/imguploader/migrations/__pycache__/0002_auto_20200210_1945.cpython-38.pyc create mode 100644 bibrecognition/imguploader/migrations/__pycache__/0003_competitions_status.cpython-38.pyc create mode 100644 bibrecognition/imguploader/migrations/__pycache__/__init__.cpython-38.pyc create mode 100644 bibrecognition/imguploader/templates/index.html create mode 100644 bibrecognition/imguploader/templates/upload.html diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..fc80f6a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "C:\\Users\\Norbert\\AppData\\Local\\Programs\\Python\\Python38\\python.exe" +} \ No newline at end of file diff --git a/bibrecognition/bibrecognition/__pycache__/__init__.cpython-38.pyc b/bibrecognition/bibrecognition/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4825c05309995333e1be07573f2ed183bdc7bcb3 GIT binary patch literal 160 zcmWIL<>g`kg1NKh<3RLd5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!Hkt5uAXr&CaB xa(-S+Qf5+o5s;Ohmsyet;p5@P$7cf7#mDOvRNmsS$<0qG%}KQb8UGoG834o=C@%m2 literal 0 HcmV?d00001 diff --git a/bibrecognition/bibrecognition/__pycache__/settings.cpython-38.pyc b/bibrecognition/bibrecognition/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c71a95162fb6072a52c6e756d28e7de285023629 GIT binary patch literal 2357 zcmb7FZFAE`5SA5TJ0^xe!b^b`0VO1Dkpt;aU|L$m7QusGGL}qQ4HJ#5J1ZCThVGO! z`Yn7YANw2n4?6t?`r4V!^bd4~4pX|4okVq*Hnm3UyS?3K_nzB5^{dqi2fv@@f7|?d zhU0!sC;49)Cf~qIe*u9wokIo0I|aRf3)}n;Q#mQ%6R!*DqZiSXUP6LiwmE$ooj^rY zLS;0KD(IwL(ko~NRnaMQ8qK0J=qzYXqB(sA&D$Ij&^dG-T|gJn2ev>8=+Y~}F6dQs zSwDrYpbxWXr*RQ|^qNOkU-6`%&ms|B14|KI&*Y6veoP9spr1iE^|NR}pMzZH;XMcM zd2~y^fOwT#S~OP*99L;KSe4B6Q7mKae06UW#q(z0|HydML!>xWn*9z=1?3>@&;7J<0L z!Jk1IxU$7qKp)m>$hW98im{)8<-0ZP)c~-@{D4@rwx4%x1kbjxIE)-ebO>dlKRn!* z=^+S&Nht1^PK4?Ii522uF3|5#30x<>YZxy#=_1)&*zs?A3wr~$OcuNs%MTX6df>8q zn-6YWa~5}2411dmEpu}a+`g~H^P~MpmhZ8U45W;^cy3Y~v90*>gfex(9%Fj}rtyV| zMT#kfqdL0a!h&go$E8UR2K-wo>omSjTssOJ-$Xc+%pjmr^H5Ruy&`(Q2pd@|fPK`H02j&wP%rK3UM$X(x)>e=6an9^`4)j>QXcsFPI z#Y8S9(3{UghB+`xtgIq)j+2|%Co}Kd9ub`Ly7!(b^t#;_YW(0S4TP_T#gJ40$@O{k5RseU%Alkb@UJ!3&`en{iRNsyy9 z62gPXjz2kuWr$xw|FHPev26;L)pAPfdyrGQB&Aik{#5BSbfMAg zsYzL0UpKN*sk^QFj5wMkmTz<73?NeSVh89D5r1JK}*MEcSp46no$P>#n- zd{R_8Yt4?52pzetge7SA_{l{6Sq%jyrMrHJ47gGV%EC!~ibI*DghULh#3hcI_QnwatdDa%1o-B-0G-IiA+e4iBz)lLQ*}j)%Qd+6 zp>b+U7n71RGf3GdTH2u!vG)RWMIT2D&mfM%MqVWd}%Vd&*mSyj@rOe(5U?oOV$)MncYy=nyG!OS(npVNrY{mc*%4_*5ov}np~9o+7n}4R@IGeuVFls zTTNK(LZMY#a%ZhCuPH{o+fV?u*;Wj_3pG*hL)y(d_dBCe>&|i~DW*D2hn;8;sh(!@ zBNvKLH<|cTQ64^DZLapdNp!i*L40b)BW$86znDCFI^u+4t@mRZI14M5N66# zS4zT^zzapbkbB+;Cv&p`|3;_?LZ;yl^l$lh{9ECjFe{W&-OOJwuJRmcg(LD0VGd%9 Gp5ouK0wO;E literal 0 HcmV?d00001 diff --git a/bibrecognition/bibrecognition/__pycache__/urls.cpython-38.pyc b/bibrecognition/bibrecognition/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cad8a737bcfbe5dda45b14ce10421d4dfcf466e4 GIT binary patch literal 996 zcmb7D%Wl*#6m>G02Wboa1n*`dm4t`HVpJ;Hsuh(Gi$XV}iqsQ(G9JZtWIL30+ppo5 zvSr0Dus~dUGSUbM1eOxn*73RL9Q$7F?ZpVjVDjqIQ4gVSZm~TgSiFJHxF1C`L<1UD zfe2?|;O4!mC!$#-`m=t3Sf55LqWy>9A%yvWg{#48_z;%iY($42P%*A*j%VZ+!o#xR!F)@GVzR23$rDuz%`)8k)scyAdD zY&nFZV0Jkfj}JOuOC{I=mPD}EV>cfs@o7bjc{&GUbc^**DwJI^?S!OW@kY*D;QAjm z4xbW}JCaHAo1zO@R1M{_gb;i^XRUzC+~jlNgTWvLuE$~7B*BX=%IP|;^>w5!@Quh0 zd*DO)XSMT6l^F!MsWf&Qo_Cxi@ppK^C<)p=p@PdKY=<4Lja>9Cy5HxbZ0br8%CtXr zKk(S>ee$Rs<~cl`JfA)8^ny*R;VHw5M(xg)2@Q>ewCkKUGTgE@a@N|Nt?T}Z^o|3$ z-;d+7>GjFQ$tCoJyoTn;x4Ofv|FU$%X?@p@4uzsk#f}0XG_IwiC%eIZZ#UTe`3q3n BHmm>u literal 0 HcmV?d00001 diff --git a/bibrecognition/bibrecognition/__pycache__/wsgi.cpython-38.pyc b/bibrecognition/bibrecognition/__pycache__/wsgi.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..04781db40f2861963455a0b7b66adeb5d27316f8 GIT binary patch literal 577 zcmaJ}-?LLurrI)sXH6dJCmAA+B*~9f%VOCPbE3_6C)LEN?d+C5iJPkAN=}G51J2Aod{_WM}&xnwR8mvbX!Fyb850fM# zA|pw4G>ULRXLm5icQp{ zg3RVdd1VbND?5kGCvn{O48D}sfn$CKY}F^U784CjI3`$O<&}ol8Wy10LR4y5GNJ&< z#$!>IT4kc1Iv(S^4@g$n3Yap;TPzC<8U0K-HdPvSnFEMt-j{AaO{L9TBIm;7_OGVQ z7ActYO|qBH?6tS4gi_m^0*p_uU9Qsj5nUmJP86Q!;CX$<*JOkjN5=<)-U%Oe&(8XT z-jIJfIXeH?y?yzw35f&mmC0SF69k7a^{Vskzmr I+w>{@145~{C;$Ke literal 0 HcmV?d00001 diff --git a/bibrecognition/bibrecognition/settings.py b/bibrecognition/bibrecognition/settings.py index 2450ade..7e68fa1 100644 --- a/bibrecognition/bibrecognition/settings.py +++ b/bibrecognition/bibrecognition/settings.py @@ -119,3 +119,4 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' + diff --git a/bibrecognition/db.sqlite3 b/bibrecognition/db.sqlite3 index cf7bce3fa1b1e7e9195c79bad952f02287aa87bf..53d4a2221f69276a17a3fdef961cfb57e09584ce 100644 GIT binary patch delta 1902 zcmbtVT})e59KVNKpto2LWW>(k+=Vd)*(mqikG8i2vjU^(pe+!f+!|BvN1>PA+gnQc z>aqZn=!1!hHQvMrCG$a(JxLQWn#>Q}`yPx&XVm!Qp7cduHWN=_EQ`}DX30Gt`QLMX z|8su-|NnP3cBqZdsn=VY&JYCAfmdy|O0~>RbrULnA9J~4C*WAy$5gH6dxMJrX^#juD;A(0mjA=qxjR3UgFh@6a<@r#^~t0*m3 z9nDTSK)~DZYxpT#hHt}H;0zq7w9*~W1wSC#oGp!HA7y`Gf#Xj#L$b&Dz^PODj8(MC z%RQZdD!II2dP*dy9DTOZOIrT6M2q>8+`aZqb0a6Y4$+VY4QTUK)8YjPs8Bu!5-@_=xEow_E(6n5NDE?mq=Y|&86F@0p< z;_Sh?ArYzU)Y>$g$*AmH)hUuDCixgUWk$o&YCJ3n61$$v#!A`Mcw#7<9F*3ggN7cR zxPX%3@vOv7mg0#B6Ui}sN8x4zG(tf^tcIImeVoW&=>-S;Eo9Z4fcT7}_*V36ZmzVZ z=dGfsi8+p4F%yJy||KX4AW;vQgLEabSk=M^Ng5Ql?xG-zr9s&2@ z50$2wYcSGIM!}=fvE~#Rr5?rk?uMhW4!}tQPU2)AhU=T1z)fs+g{T%cqNtENuVl4Z zHno_MS;5zi0=U|lc4bsGmWC`N7KvEx+9Ib84*OYMiUyXWk#zrfZb6NjrEz{GlIOyf zFO%_4B(&KAr`}JJswNyJiQgL#0tlg;RZ!A}VjySXi7s;I=S*2QyjWL`M1TJu)#&PQ1_7V&FG5b=3lS%)E03gFsXWSRtOl(-!>mJs2GZ6cK{GXYsxxaX5Sn1SZI`-hj`KaOejfcsXcGnNO=l zx)XIhf2mE@w6xY1q%U2*`~vmSP2ixNHE^GRzrcO$U=Q{^ONPJ^^24%IbAk-rbNnw= zg$^#Tz0-8{_r~3ghDOkKXc(=ECU0BDiFhf*F+s-R#^r;i4z-B7Vt9*aVJe?7f{`-s9?suIZ1jE zivSyc83X@I{ww^u`OElc@po?)EJ)&?T&AzV$T4}oz9o>nsjtQ;w8?LbbD0k^_c3i| zj%3`+RK}>r;Li7rcOS1DPc{PsbKpcrQI^ISOZM$$sfZKr!BF{(2vO)pAfyw0S_wVCn3fB#7bxLIX@7D@xX c{eged1eWD27Z?>bvuyYy4-FV#SpAU)0KqJ5cK`qY diff --git a/bibrecognition/imguploader/__pycache__/__init__.cpython-38.pyc b/bibrecognition/imguploader/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1f47c360d31ac3a84948343ce5df8bd690c74214 GIT binary patch literal 157 zcmWIL<>g`kf+AV7I1v39L?8o3AjbiSi&=m~3PUi1CZpdWtL<@_{iMM-1O3doczR;)S{U9_)MUp_;|g7%3B;Zx%nxjIjMFa Jvp)kd0|4(ACS?Es literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/__pycache__/admin.cpython-37.pyc b/bibrecognition/imguploader/__pycache__/admin.cpython-37.pyc index 8beaf67a9c3185945797dbc11381a97f92ad8bf4..0c2a86207b6fd46e3dcc41f62f14e5dd8f343e8e 100644 GIT binary patch delta 19 ZcmX@ac!-hPiIahGLOhCCumB-YB@{)i5$|I8;W0?YJ)6tg{MCj}ivEw$?R^v~s&Mi1bXSEhI2^zPYs zgK!Yx27G;6WaW|E)_rRhPp0=)H8#Q5W2%jW&RLGeiXds&=1zGSGYhS99_$CP;r~&- z&#sQE<@NF&Fj3X0W@C}sK9&!DYL#wxLuYCUwu(J3hLS5T40KNdG_|K=7JNj~+@XwIb3>4~mx%T+&V&BFXN$F$d53GQQGYJ^2cr zoK1vgV1B;+X1^KcX*L@Jo4ve#K63u{U}zzOHG6Z#fq<}r8WTjg2MS1h0*M?yL=sT= z2=UnucR`G9bYsk|R>!h9_?Mv}gEf0|&LM{c3HUcAf&x|$?qXXPt*LZIx$PyANqKtO z#i5I&R9T%%>Bdsln%c_OQz>8Dtomm{pTEFHJf#c2tGh+I*=`>4gI4Lj+)K+4TvZJm)jRr5I=Hs*J(~ zLbfn1pCsQykvjaIUz|(_ve1rsh`Qwe5)InNe(j$&W1pEZYsohCtv@2Pf!Y87 literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/__pycache__/models.cpython-38.pyc b/bibrecognition/imguploader/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..308d83f68974e2856d34d53c34beccd46752e9f1 GIT binary patch literal 1113 zcmaiz&2G~`5P*06ZzrLp5^&)Kaw!txgb-?*wx~j_5EYkI#mdcW9S8rUYa7vC;o1l3 zEA15tDLeuvX4V06XvJC?&5S4W^UeChXp}HKdlx@G{&X1oPR9E2(AdFWbBF>M@Pd_G zaL(Q^aKQb>z*T(ie07D39uIu<_$!Zxo&ZAhge#8^(J33pOU%W_+yrF}s%WNUuAjd} zpQBeX!GQ@!xpNOVI5%AQYkFXHmrCC_B7^`7gl0IY%Y|z5Hm|E@37F=Vo1{#?$U;?F zJ6qD!!UvsRw6~59&@v&Yi?l1+lW}AsDXX+pQkq0c?6NCJA4+-IrA7ZnBQ9p*$t=}} zxhg=!Q>-bQqRUn)#hIXK)3$4Fncl#7D}L=9ygb`G+Iz32b#->0pG%EeR@rXJUN`eH z>lQ_wg3@O_uI=A3}m~2gZLltJ@lZ#&soefvQ!Snh~LZxtiumM`&G#d6{Oad3L?ADAK8#)dkM5 zJzr#F$He_ivaNNDu}fOC_EDUSN1Aq{2PB3hEa&8~)+*1cx2hlBgp=LV$?pDv2rc#; z^az8EXQ3xYRNAh^__ht>cDnetf?nIC^bb)`4-GXP@lE~!AM3pz<_iq{A4~*BC@omj z6Yvn8Z(T6F5p zIiKRc=?bo{%qCqK@|}zW6T>{MvU(fNd)odneVFz}^`$BBuB;|{)qfqY`JdE7cgx=j Fegn7)_qYH6 literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/__pycache__/urls.cpython-38.pyc b/bibrecognition/imguploader/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b0b8a69a6007ca0a0047cb22d7b124bbf49c019c GIT binary patch literal 326 zcmYk0OKQU~5QZhovYpz=DZ23{2Ph$gKo{MV($bAFElx)`3YKIfyN@drdXO%9A#DqV zT%n875#D5Ae(7WWdEC$EX9VN@{O92d-|qmYksxd^-3kQ=(2gitQA!{J)LElfB!1;Rtf+B literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/__pycache__/views.cpython-38.pyc b/bibrecognition/imguploader/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1430f1774075f9f86ec60e76e1e0bb449f6b65cb GIT binary patch literal 744 zcmY*X&2AGh5cYU~viYkJ>PzI3NSqKtfC{Zz356!>UC76JcRgeRa z%}ZWId4zT(;xew1JPCM$c$%kZr=sqkHr|=&Oxd7&kD1sV_|(W+NHYN6J9Tb3 zk#?zTEAIh+BiKG)Xs1uKsn9vxkC;fIj4WJ1k^c_aG0IC6+e78p2I(rcjj$*muR98> zeHkuXRT}CFv$l-<)JW^@m}w*O`}y&c+0oh2L>9W9U8>6qtfH@K<t$N}0MCED^E*uanYmYK(R zC$|ikO9kJ;l+~$&ExQ5N!v1jZ8&D8>OvXMwe=~i%?vHF!6w=yJW6IIGyW<%;_wffB zXy(&Ox`h@dMFxh(<&%@M*T++zDSNS+mrD59&R5d3C;&GDXK1J~(vg9-v~-fdj~R#ydO(^AM5opq)Pu*Yo;H5A8x5S2WIs^uGHSUf?bmdP$!USG%Ja fXwWc2n!WmgNg$Cut+Z%L`HWV<64Zn6#aZ$PMwF`Z literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/admin.py b/bibrecognition/imguploader/admin.py index 8c38f3f..5937740 100644 --- a/bibrecognition/imguploader/admin.py +++ b/bibrecognition/imguploader/admin.py @@ -1,3 +1,10 @@ from django.contrib import admin # Register your models here. +from .models import Competitions +from .models import Photo +from .models import PhotoMeta + +admin.site.register(Competitions) +admin.site.register(Photo) +admin.site.register(PhotoMeta) \ No newline at end of file diff --git a/bibrecognition/imguploader/forms.py b/bibrecognition/imguploader/forms.py new file mode 100644 index 0000000..79f447b --- /dev/null +++ b/bibrecognition/imguploader/forms.py @@ -0,0 +1,7 @@ +# forms.py +from django import forms +from .models import * + +class PhotoForm(forms.Form): + zawody = forms.CharField(max_length=50) + file_field = forms.FileField(widget=forms.ClearableFileInput()) diff --git a/bibrecognition/imguploader/functions.py b/bibrecognition/imguploader/functions.py new file mode 100644 index 0000000..20264b0 --- /dev/null +++ b/bibrecognition/imguploader/functions.py @@ -0,0 +1,189 @@ +try: + from PIL import Image +except ImportError: + import Image +from cv2 import cv2 +import pytesseract +import argparse +import numpy as np +from imutils.object_detection import non_max_suppression + +pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' +faceCascade = cv2.CascadeClassifier( + 'haarcascade/haarcascade_frontalface_default.xml') + + +def decode_predictions(scores, geometry): + # grab the number of rows and columns from the scores volume, then + # initialize our set of bounding box rectangles and corresponding + # confidence scores + (numRows, numCols) = scores.shape[2:4] + rects = [] + confidences = [] + + # loop over the number of rows + for y in range(0, numRows): + # extract the scores (probabilities), followed by the + # geometrical data used to derive potential bounding box + # coordinates that surround text + scoresData = scores[0, 0, y] + xData0 = geometry[0, 0, y] + xData1 = geometry[0, 1, y] + xData2 = geometry[0, 2, y] + xData3 = geometry[0, 3, y] + anglesData = geometry[0, 4, y] + + # loop over the number of columns + for x in range(0, numCols): + # if our score does not have sufficient probability, + # ignore it + if scoresData[x] < args["min_confidence"]: + continue + + # compute the offset factor as our resulting feature + # maps will be 4x smaller than the input image + (offsetX, offsetY) = (x * 4.0, y * 4.0) + + # extract the rotation angle for the prediction and + # then compute the sin and cosine + angle = anglesData[x] + cos = np.cos(angle) + sin = np.sin(angle) + + # use the geometry volume to derive the width and height + # of the bounding box + h = xData0[x] + xData2[x] + w = xData1[x] + xData3[x] + + # compute both the starting and ending (x, y)-coordinates + # for the text prediction bounding box + endX = int(offsetX + (cos * xData1[x]) + (sin * xData2[x])) + endY = int(offsetY - (sin * xData1[x]) + (cos * xData2[x])) + startX = int(endX - w) + startY = int(endY - h) + + # add the bounding box coordinates and probability score + # to our respective lists + rects.append((startX, startY, endX, endY)) + confidences.append(scoresData[x]) + + # return a tuple of the bounding boxes and associated confidences + return (rects, confidences) + + +# construct the argument parser and parse the arguments +ap = argparse.ArgumentParser() +ap.add_argument("-i", "--image", type=str, + help="path to input image") +ap.add_argument("-east", "--east", type=str, default="./EAST/frozen_east_text_detection.pb", + help="path to input EAST text detector") +ap.add_argument("-c", "--min-confidence", type=float, default=0.5, + help="minimum probability required to inspect a region") +ap.add_argument("-w", "--width", type=int, default=320, + help="nearest multiple of 32 for resized width") +ap.add_argument("-e", "--height", type=int, default=320, + help="nearest multiple of 32 for resized height") +ap.add_argument("-p", "--padding", type=float, default=0.0, + help="amount of padding to add to each border of ROI") +args = vars(ap.parse_args()) + +# load the input image and grab the image dimensions +image = cv2.imread(args["image"]) +orig = image.copy() +(origH, origW) = image.shape[:2] + +# set the new width and height and then determine the ratio in change +# for both the width and height +(newW, newH) = (args["width"], args["height"]) +rW = origW / float(newW) +rH = origH / float(newH) + +# resize the image and grab the new image dimensions +image = cv2.resize(image, (newW, newH)) +(H, W) = image.shape[:2] + +# define the two output layer names for the EAST detector model that +# we are interested -- the first is the output probabilities and the +# second can be used to derive the bounding box coordinates of text +layerNames = [ + "feature_fusion/Conv_7/Sigmoid", + "feature_fusion/concat_3"] + +# load the pre-trained EAST text detector +print("[INFO] loading EAST text detector...") +net = cv2.dnn.readNet(args["east"]) + +# construct a blob from the image and then perform a forward pass of +# the model to obtain the two output layer sets +blob = cv2.dnn.blobFromImage(image, 1.0, (W, H), + (123.68, 116.78, 103.94), swapRB=True, crop=False) +net.setInput(blob) +(scores, geometry) = net.forward(layerNames) + +# decode the predictions, then apply non-maxima suppression to +# suppress weak, overlapping bounding boxes +(rects, confidences) = decode_predictions(scores, geometry) +boxes = non_max_suppression(np.array(rects), probs=confidences) + +# initialize the list of results +results = [] + +# loop over the bounding boxes +for (startX, startY, endX, endY) in boxes: + # scale the bounding box coordinates based on the respective + # ratios + startX = int(startX * rW) + startY = int(startY * rH) + endX = int(endX * rW) + endY = int(endY * rH) + + # in order to obtain a better OCR of the text we can potentially + # apply a bit of padding surrounding the bounding box -- here we + # are computing the deltas in both the x and y directions + dX = int((endX - startX) * args["padding"]) + dY = int((endY - startY) * args["padding"]) + + # apply padding to each side of the bounding box, respectively + startX = max(0, startX - dX) + startY = max(0, startY - dY) + endX = min(origW, endX + (dX * 2)) + endY = min(origH, endY + (dY * 2)) + + # extract the actual padded ROI + roi = orig[startY:endY, startX:endX] + + # in order to apply Tesseract v4 to OCR text we must supply + # (1) a language, (2) an OEM flag of 4, indicating that the we + # wish to use the LSTM neural net model for OCR, and finally + # (3) an OEM value, in this case, 7 which implies that we are + # treating the ROI as a single line of text + config = ("-l eng --oem 1 --psm 7") + text = pytesseract.image_to_string(roi, config=config) + + # add the bounding box coordinates and OCR'd text to the list + # of results + results.append(((startX, startY, endX, endY), text)) + +# sort the results bounding box coordinates from top to bottom +results = sorted(results, key=lambda r: r[0][1]) + +# loop over the results +for ((startX, startY, endX, endY), text) in results: + # display the text OCR'd by Tesseract + print("OCR TEXT") + print("========") + print("{}\n".format(text)) + + # strip out non-ASCII text so we can draw the text on the image + # using OpenCV, then draw the text and a bounding box surrounding + # the text region of the input image + text = "".join([c if ord(c) < 128 else "" for c in text]).strip() + output = orig.copy() + cv2.rectangle(output, (startX, startY), (endX, endY), + (0, 0, 255), 2) + cv2.putText(output, text, (startX, startY - 20), + cv2.FONT_HERSHEY_SIMPLEX, 1.2, (0, 0, 255), 3) + + # show the output image + cv2.imshow("Text Detection", output) + cv2.waitKey(0) diff --git a/bibrecognition/imguploader/migrations/0002_auto_20200210_1945.py b/bibrecognition/imguploader/migrations/0002_auto_20200210_1945.py new file mode 100644 index 0000000..7659b12 --- /dev/null +++ b/bibrecognition/imguploader/migrations/0002_auto_20200210_1945.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.3 on 2020-02-10 18:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('imguploader', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='photo', + name='image', + field=models.ImageField(default='placeholder.jpg', upload_to='images/'), + ), + migrations.AddField( + model_name='photo', + name='name', + field=models.CharField(default='Zdjecie', max_length=100), + ), + ] diff --git a/bibrecognition/imguploader/migrations/0003_competitions_status.py b/bibrecognition/imguploader/migrations/0003_competitions_status.py new file mode 100644 index 0000000..7b4f5d4 --- /dev/null +++ b/bibrecognition/imguploader/migrations/0003_competitions_status.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.3 on 2020-06-14 18:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('imguploader', '0002_auto_20200210_1945'), + ] + + operations = [ + migrations.AddField( + model_name='competitions', + name='status', + field=models.CharField(default='draft', max_length=10), + ), + ] diff --git a/bibrecognition/imguploader/migrations/__pycache__/0001_initial.cpython-38.pyc b/bibrecognition/imguploader/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bc70b0814439d4f8cd8fbe815dde470554df332f GIT binary patch literal 1098 zcmZuw&2G~`5caM&iS0OP3kAXha0p0I;m`v@sBPM!3bg_X7b{}rWVWu2f5O_SXs>Y1 zgYY1{#9n*q1?~tCvvx{d)U|ds-|o)mnQvy_bvllL^N(v*|T}9vc0|1^O6$s+=SYq+f(tnyY4#fr#^i zi9V|j7r_S3{5vkf@CX%{3;W5#Onn1x6t;hm`AA<%o=j@0=3-@fWz@8ICP8|g% zwCA++b#L_Tl()MJ-z7wjXh&|;iaJpjmSJU1k7$kM){QK;ud%FNLwEk;yu09JIHVr9^L)JIs=)D8foG8p5ukd)s}cTz^(%d?JNk2vF^*3=?0T@(&Tk>@4M2Ur`7}(c3Ob_C?_Hrl^%4D;LC6q#)8s zC~`@4(CuNV*1m2!Y3dz&6GhzBIVyX2?90k@b~7o$Abp8iHX-uUAX5~^$|{q=&Q-19 z=HYO2dq+9hR4lsrt05mEXSw`*z4LUmwYT*~OtN$|4#!-g73k0^T!*z>M^}$yw6?bP zm@l#!Oi!hLeJz~1E`UWDWsDI@S4o$2f73tAx_p;N$ zn2L2OvXP--#VTG3?F`zz$c2Pvj%>7-Kp}RyxB)~FZ46g@!oM;ps;t|eN1^uF@R~6l zGKSfDDbQXp_NC|2WHbmwEh-Qd=4u;U6Vd(=!0AxQ9+I9J0)s;bCwtzEW~gfMe*r&9 z^9Umcb(_9JA?jbSug-gi7&kMTnLug57J Ln6TCi9r=%4TcT&U_CYxC zLVHC*>MJ0jGP^0N$C}Z6p3%&F-+nwem@=}n?eEV&Ib**(7+OT&nA|?101SA^DxUF5 zWP-CZ1_I=F1`_#Bev_Gm=mVR_*VN1A!cD6pH@YjD+PYEI0G4*+OG6tII3~9X3dk}J zEEB+Uo=J>$v0s3r-54T>VRR*6d?l%tKthWqZu0K`23mKosPeuo8x3f(hiRHFmF~Mn zEz>3CN2xk`_T*_c+cZ^+U2%Js?R3{$7lYB;?%In%lg5Bs-IpCP&|g)Fb>3afB_Yp2 z)w)6#g&1!OEa99kNmTf+l$$C=eSL|P&y@Po>(cjn1lVE?SZ@lnM$j&oyaIURXBg?> z%hn3Ash&@x_gTiN%L3@ zWl(z+7VV|+4?ZHdhZGViZlXBig1*_`=q6Op=aHMhPS<&}fOVh|jt|AVL-*MOn&Ofd OdqG}$j@I)&l>Y!?)UDG1 literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/migrations/__pycache__/__init__.cpython-38.pyc b/bibrecognition/imguploader/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eef368f4c9ccc5c3af91b70cf3a2283973494cfa GIT binary patch literal 168 zcmWIL<>g`kf+AV7I1v39L?8o3AjbiSi&=m~3PUi1CZpdWtL<@_{iMM-1O3doczR;)S{T&%=Dr}kfP$4`1nkq`uKRgg34PQ SHo5sJr8%i~AZtDYF#`bG5-SM+ literal 0 HcmV?d00001 diff --git a/bibrecognition/imguploader/models.py b/bibrecognition/imguploader/models.py index c4b89a5..57dc232 100644 --- a/bibrecognition/imguploader/models.py +++ b/bibrecognition/imguploader/models.py @@ -4,9 +4,12 @@ from django.db import models class Competitions(models.Model): comp_slug = models.CharField(max_length=100) comp_name = models.CharField(max_length=100) + status = models.CharField(max_length=10, default="draft") class Photo(models.Model): comp_id = models.ForeignKey(Competitions, on_delete=models.CASCADE) + name = models.CharField(max_length=100, default='Zdjecie') + image = models.ImageField(upload_to='images/', default='placeholder.jpg') url = models.CharField(max_length=50) class PhotoMeta(models.Model): diff --git a/bibrecognition/imguploader/templates/index.html b/bibrecognition/imguploader/templates/index.html new file mode 100644 index 0000000..6849961 --- /dev/null +++ b/bibrecognition/imguploader/templates/index.html @@ -0,0 +1,15 @@ + + + + + + RunPhoto + + + {% if user.is_authenticated %} + Zalogowany 😎 + {% else %} + Gość 🏃‍♀️ + {% endif %} + + \ No newline at end of file diff --git a/bibrecognition/imguploader/templates/upload.html b/bibrecognition/imguploader/templates/upload.html new file mode 100644 index 0000000..ad8c1ce --- /dev/null +++ b/bibrecognition/imguploader/templates/upload.html @@ -0,0 +1,15 @@ + + + + + + Upload Photos + + +
+ {% csrf_token %} + {{ form }} + +
+ + \ No newline at end of file diff --git a/bibrecognition/imguploader/urls.py b/bibrecognition/imguploader/urls.py index 192d770..334a710 100644 --- a/bibrecognition/imguploader/urls.py +++ b/bibrecognition/imguploader/urls.py @@ -4,4 +4,5 @@ from . import views urlpatterns = [ path('', views.index, name="index"), -] \ No newline at end of file + path('upload', views.uploadPhotos, name="upload"), +] diff --git a/bibrecognition/imguploader/views.py b/bibrecognition/imguploader/views.py index aafab64..1f1fea1 100644 --- a/bibrecognition/imguploader/views.py +++ b/bibrecognition/imguploader/views.py @@ -1,7 +1,24 @@ from django.shortcuts import render from django.http import HttpResponse +from .forms import PhotoForm +from django.http import HttpResponseRedirect # Create your views here. def index(request): - return HttpResponse("Hello, world. This is imageUploader") + return render(request, 'index.html', {}) + # return HttpResponse("Hello, world. This is imageUploader") + + +def uploadPhotos(request): + if request.method == 'POST': + form = PhotoForm(request.POST, request.FILES) + if form.is_valid(): + + form.save() + # return render(request, print(request.FILES['file_field'])) + return HttpResponseRedirect('/success/url/') + else: + form = PhotoForm() + return render(request, 'upload.html', {'form': form}) + # return HttpResponse("Hello, world. This is imageUploader") diff --git a/main.py b/main.py index bfc76b8..a274ba3 100644 --- a/main.py +++ b/main.py @@ -76,7 +76,7 @@ def decode_predictions(scores, geometry): ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", type=str, help="path to input image") -ap.add_argument("-east", "--east", type=str, +ap.add_argument("-east", "--east", type=str, default="./EAST/frozen_east_text_detection.pb", help="path to input EAST text detector") ap.add_argument("-c", "--min-confidence", type=float, default=0.5, help="minimum probability required to inspect a region")