From 3f061444cc4322208d9f18930b64dcea476ee168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9andre=20Chamberland-Dozois?= Date: Sat, 24 Nov 2018 14:19:33 -0500 Subject: [PATCH] structure finished --- Projet/Bootstrap.py | 59 ++++++++++-------- .../__pycache__/BoudaryTracing.cpython-35.pyc | Bin 0 -> 3598 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 146 bytes Projet/Classifier/DescriptorGenerator.py | 9 +++ .../DescriptorGenerator.cpython-35.pyc | Bin 0 -> 669 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 141 bytes Projet/Clipping/Clipping.py | 1 - .../__pycache__/Clipping.cpython-35.pyc | Bin 1626 -> 1740 bytes Projet/EdgeDetection/EdgeDetection.py | 12 +--- .../__pycache__/EdgeDetection.cpython-35.pyc | Bin 4865 -> 4870 bytes Projet/ImageProcessing/__init__.py | 3 - Projet/Main.py | 3 +- Projet/Pipeline/Pipeline.py | 17 +++++ .../__pycache__/Pipeline.cpython-35.pyc | Bin 0 -> 946 bytes Projet/Shared/Borg.py | 4 ++ Projet/Shared/Parameters.py | 10 +++ .../__init__.py | 0 Projet/Shared/__pycache__/Borg.cpython-35.pyc | Bin 0 -> 445 bytes .../__pycache__/Parameters.cpython-35.pyc | Bin 0 -> 656 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 137 bytes Projet/Training/Trainer.py | 45 +++++++++++++ .../__init__.py} | 0 .../__pycache__/Trainer.cpython-35.pyc | Bin 0 -> 1578 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 139 bytes Projet/Utils/ArgParser.py | 17 ++--- Projet/Utils/ReadWrite.py | 13 ++++ .../__pycache__/ArgParser.cpython-35.pyc | Bin 0 -> 992 bytes .../__pycache__/ReadWrite.cpython-35.pyc | Bin 0 -> 661 bytes .../Utils/__pycache__/__init__.cpython-35.pyc | Bin 0 -> 136 bytes Projet/__pycache__/Bootstrap.cpython-35.pyc | Bin 1170 -> 1611 bytes 30 files changed, 139 insertions(+), 54 deletions(-) create mode 100644 Projet/BoundaryTracing/__pycache__/BoudaryTracing.cpython-35.pyc create mode 100644 Projet/BoundaryTracing/__pycache__/__init__.cpython-35.pyc create mode 100644 Projet/Classifier/DescriptorGenerator.py create mode 100644 Projet/Classifier/__pycache__/DescriptorGenerator.cpython-35.pyc create mode 100644 Projet/Classifier/__pycache__/__init__.cpython-35.pyc delete mode 100644 Projet/ImageProcessing/__init__.py create mode 100644 Projet/Pipeline/Pipeline.py create mode 100644 Projet/Pipeline/__pycache__/Pipeline.cpython-35.pyc create mode 100644 Projet/Shared/Borg.py create mode 100644 Projet/Shared/Parameters.py rename Projet/{FingertipDetection => Shared}/__init__.py (100%) create mode 100644 Projet/Shared/__pycache__/Borg.cpython-35.pyc create mode 100644 Projet/Shared/__pycache__/Parameters.cpython-35.pyc create mode 100644 Projet/Shared/__pycache__/__init__.cpython-35.pyc create mode 100644 Projet/Training/Trainer.py rename Projet/{ImageProcessing/ImageProcessing.py => Training/__init__.py} (100%) create mode 100644 Projet/Training/__pycache__/Trainer.cpython-35.pyc create mode 100644 Projet/Training/__pycache__/__init__.cpython-35.pyc create mode 100644 Projet/Utils/ReadWrite.py create mode 100644 Projet/Utils/__pycache__/ArgParser.cpython-35.pyc create mode 100644 Projet/Utils/__pycache__/ReadWrite.cpython-35.pyc create mode 100644 Projet/Utils/__pycache__/__init__.cpython-35.pyc diff --git a/Projet/Bootstrap.py b/Projet/Bootstrap.py index a686eb6..ae191a0 100644 --- a/Projet/Bootstrap.py +++ b/Projet/Bootstrap.py @@ -3,35 +3,42 @@ import numpy as np from PIL import Image -from EdgeDetection.EdgeDetection import EdgeDetection -from Clipping.Clipping import Clipping +from Utils.ArgParser import ArgParser +from Classifier.DescriptorGenerator import DescriptorGenerator +from Pipeline.Pipeline import Pipeline -class Bootstrap: - def __init__(self): - #self.iimProc = - #self.fingDetec = - self.edgeDetec = EdgeDetection() - self.clip = Clipping() - #self.classifier = - #self.boundTrac = - - def run(self): - #if +from Training.Trainer import Trainer - #else: - #processedImage = - img = Image.open('./asl_alphabet_test/C3_test.jpeg').convert('L') - image = np.asarray(img) +from Shared.Borg import Borg +from Shared.Parameters import Parameters - edges = self.edgeDetec.detect_edges(image) - - clippedEdges = self.clip.clip(edges) +class Bootstrap(Borg): + def __init__(self): + args = ArgParser.parse() + Parameters.set_parameters({ + 'mode' : args.mode, + 'input_image' : args.input_image, + 'training_set' : args.training_set, + 'model_path' :args.model_path + }) - test2 = np.asarray(clippedEdges) - test = Image.fromarray(test2) - plot = plt.imshow(test) - plt.show() - #plot = plt.imshow(clippedEdges) - #plt.show() + def run(self): + p = Parameters().get_parameters() + + if p['mode'] == 'training': + Trainer().train() + + elif p['mode'] == 'classification': + print('hello') + + else: + img = np.asarray(Image.open('./asl_alphabet_test/U_test.jpg').convert('L')) + res = Pipeline().run(img) + test2 = np.asarray(res) + test = Image.fromarray(test2) + plot = plt.imshow(test) + plt.show() + + diff --git a/Projet/BoundaryTracing/__pycache__/BoudaryTracing.cpython-35.pyc b/Projet/BoundaryTracing/__pycache__/BoudaryTracing.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..57796fc4d0390cc317066b073547c23e2a01df7a GIT binary patch literal 3598 zcmbtW-EI>{6h5=-b^MnE5+DxHf&HK9X^CTN9Vu_D$zQVI(mH0Grr!Wel4k@Msg$t#JB&N6uwkqhLF zlQ$tUCQOodM&uHCXUUrq8Iz~s;<;$@VYlylbv=Bc>y4Jb(NOS-fBa@gAE5+GsPM7y z*G&X*ntR~484^Ia2Oe88S&-l!_^PA_juH&p%bE?;EO{BZ5IL>w`bIO#ZMXaZ>iU4| zmOm7E7)`hQR@ka{+z`Gt-CnolhmrN&&1o5?sjvb)2#cR zZZ52JJHv$+E5T=X?tFgh!NQ8}wwvKX=G(cQg5qXx7!_QXjk<1uVK{?|RPoreTg_;> zIa<*xMQ$pdS4yO^NP@Cj zu2pmn2BUJL-f8qZE+ea*V?97w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luDjE(cg%>MWa~3r@pVbgKh4{n=B(CCUCnXQ>_>{&LUGP_ZKL8i z2RyB!DkVGQK=zkc#!F+Qq!uaT)I*@z1FjQ3yi OwIE=?V93g=y!9_^>wfD1 literal 0 HcmV?d00001 diff --git a/Projet/BoundaryTracing/__pycache__/__init__.cpython-35.pyc b/Projet/BoundaryTracing/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2a4b20460f78ef5596d80656917b58d3a6c43030 GIT binary patch literal 146 zcmWgR<>fN@_%WIR2p)q77+?f49Dul(1xTbYFa&Ed`mJOr0tq9CU-tSL`MIh3IjMH6{UnR%Hd@$q^E VmA5!-a`RJ4b5iX<1{VV{0|1R@Bb5LE literal 0 HcmV?d00001 diff --git a/Projet/Classifier/DescriptorGenerator.py b/Projet/Classifier/DescriptorGenerator.py new file mode 100644 index 0000000..3344ad3 --- /dev/null +++ b/Projet/Classifier/DescriptorGenerator.py @@ -0,0 +1,9 @@ +class DescriptorGenerator: + + @staticmethod + def generate_origin_descriptor(): + return 0 + + @staticmethod + def generate_descriptor(data): + return 0 diff --git a/Projet/Classifier/__pycache__/DescriptorGenerator.cpython-35.pyc b/Projet/Classifier/__pycache__/DescriptorGenerator.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d2021d0811f42fe66f72688cf17ae8ccb1ef556 GIT binary patch literal 669 zcmaJ;u};G<5WP4lR8_lB2_$|1WuOL$p#wsog1S|e$`l66icK4o#KlgBvX<{)N8(fX zf~-t@0!*A!nt&8I>CUIK-o5wi-AnbJdeG$y1>v9jkarugB)F-#WJU)u zHzvA`q^330z4SrgSuoQYK1?me3H(P9A!7@V}v5{uaOZN}~wJpR6En~Y~sn8<9V pgl<@QmhOkF;sdNUy>V51Q=9B~#bo3=#aRc*o2P5uGmABt@C6;=n`{68 literal 0 HcmV?d00001 diff --git a/Projet/Classifier/__pycache__/__init__.cpython-35.pyc b/Projet/Classifier/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c36c4c5a1456182576810d1070e995e8b8f0067f GIT binary patch literal 141 zcmWgR<>i{=`5~GC2p)q77+?f49Dul(1xTbYFa&Ed`mJOr0tq9CUsn1V`MIh3IjMWHa Q^HWN5Qtd!y76UN@0I0qpNB{r; literal 0 HcmV?d00001 diff --git a/Projet/Clipping/Clipping.py b/Projet/Clipping/Clipping.py index 2c60bef..65e5078 100644 --- a/Projet/Clipping/Clipping.py +++ b/Projet/Clipping/Clipping.py @@ -10,7 +10,6 @@ def clip(self, edgesImage): self.image = np.asarray(edgesImage) y1 = self.calculY1() y2 = self.calculY2() - print('y1', y1, 'y2', y2) clipping_level = max(y1, y2) for i in range(clipping_level, len(self.image)): zeros = np.zeros(len(self.image[i])).astype('uint8') diff --git a/Projet/Clipping/__pycache__/Clipping.cpython-35.pyc b/Projet/Clipping/__pycache__/Clipping.cpython-35.pyc index 553c87ba8e5f5b5050946676ab3386bbfa802d99..5b21d27698393fe552ffcf813aff039fb2c0ec21 100644 GIT binary patch literal 1740 zcmah}O>Y}j6uoc0Jh7doX=#%3p-PRYcx=BJ zw{{e-g2Z27%L@1lEcpTafG2h=kXLLGn{w_O+fAEPyz#rf^Ui%|-rRHVtSl}TSHJ(~ z>t8*hKk3x4;orebt1vD61jR%RK`o0K7OymH`m|+J%c1W8J9GlT;kez3JHaNZPoBdz z*_{mw&K=D3Ll~L!!Gg~ag9xm1Ql@jM_Ir z3h0w>YBYAuqZVFZ$1YuETu{5nF9K%_KKyV1u)1`+FKI8o+pRctZH+cCZ)tZBC0VUf z(pJ*bg)j}33P;+FI^luTelv`lgZS~r+{1>R!VYbB!l8Cmm>|rKWuo09sk*85!ZaK8 zWTl{;RL1*_qHG<=berjvgB&T&SmQ!-n#>@UPi3q{q%LCp7gBHF@84SWNw*`bu?&-z zlGUAVJgPq2N#Cp0-ru-e-BI1P%&Idz=FZLDNIOit0FLw$42eskjO(&k64%7LVp$w5 z&bHm;$fn>Z3_coaG1u}BIM9-_WpWCs*2aQ{zfoqL0iYnN<-~?EKeEijA2wka};70N4 z6Mk{UW@5A9nw~tzs5okgA$n!gswmOFC&Jnc&ep6?PpLwbP&52AEa#iyOI^~KgTjf%@q*?TN8B}2T2FZPe?W~?&j0`b literal 1626 zcma)5OKTKC5U!qgHXCCUlPEsGfG`JL6Aa`a5{aSI&qWPSI!NR!A$mGx`Mhy0UV+&L4bOO z_6_Zul$z89V)CVX7PX6%TGX{Dwe>QhJ?t{**0TcjY)T#4a(~CVHl60Upq@ir{BQ`4 zvgvxONbCK#hrTG`u6DH+ZpzH7gmGmjelkDu7BaIIwliCWb;QkB)-$8t%YWx90>RD*b6=QSuvQ7E(9L~3oIGs9SR8tQHv|G+qR=Kn&d2^0_txwS^?tpYUFMP1tGk5+8!jeGkz*2PW7|a#U<-o%&{qVXjKO8d1-uji?{TwMP7KX`-PlP3^a%1hD%8d}4OdWaxuY0%nnu*wn85qf9@h z+v9<50ko-0+a{^^Lm{vPjWJ{!uuk7<9UcdaxJ`(!qm9sqvpts^H1f2NU#aWzr?eJz zo1$@Dn#J{?|F%VHk!xe9*y2E~v64E;>}s`g?43Ho`1W54s%fmu%d^`^SMAQs6mEF30rT4MI2SjJx&R`}NVF+F3Kz2u* zg!FUhycvkT)FT7c!$c AIRF3v diff --git a/Projet/EdgeDetection/EdgeDetection.py b/Projet/EdgeDetection/EdgeDetection.py index 7bdddf4..285e55c 100644 --- a/Projet/EdgeDetection/EdgeDetection.py +++ b/Projet/EdgeDetection/EdgeDetection.py @@ -10,8 +10,8 @@ class EdgeDetection: def __init__(self): - self.threshold_1 = 80 - self.threshold_2 = 80 + self.threshold_1 = 10 + self.threshold_2 = 5 def calc_offset(self, angle): @@ -140,10 +140,4 @@ def detect_edges(self, image): updated_mask = self.hysterisis(mask, image_maxima) - return self.apply_mask(updated_mask, image_maxima) - - - - - - + return self.apply_mask(updated_mask, image_maxima) \ No newline at end of file diff --git a/Projet/EdgeDetection/__pycache__/EdgeDetection.cpython-35.pyc b/Projet/EdgeDetection/__pycache__/EdgeDetection.cpython-35.pyc index d04dbce66b90b434de1096efabfa465087394ba5..826adb3c707cf695fc29a60b6b2b47660b16c6db 100644 GIT binary patch delta 407 zcmZovYg6MCCm&?gV&vZZ zhOwHFk!x}WvkW&kP`n6C@NDj94q-GcVh5@G^Z);UP4-(%c?Gvvt5S>di*GUKq~;az z1LbZp6=dFGElSKwPc7mD@-^9uxF$=ms-qa?#cIyT$UeD=%@b(P88#0TNqP1?OpM}_ z?{G?R2!RaX0vhm#(-}pL7gskUF9%Szh!doQ6{zG9w-SmHejZIGpy`%;7AV3se3~H7 zE#p^17M^^af3*}S5Q?lpgfoah^84gD0tbMaVg)r&G))l9VB-ZT6`%Z1P)7iv0TN=9 Tt%NKY`6rhMg=0$H7E%KMvN=<> delta 380 zcmZouYgFSD#~8I3xi)`ftY&27 zoSe%n!_CFOz)%DxxHnH>4q;?^$vXKJi?jqEQ2Z8CLFO&iqQt!P)FNIWUz5FvbFwU} zI*KNLR&z#1$;s_(o>y`w zfRwNTl|1KGLQx{Zqsas`-Hy)!MYxeq6XcE6{A$R;lkf1amf{4NXAL5pK?IU7CodE@ t0MwKusDYwss$d2i4@jxlWM&~90fYuf*i5z;vSj3&TqzWeDfK`|4FER9M%e%W diff --git a/Projet/ImageProcessing/__init__.py b/Projet/ImageProcessing/__init__.py deleted file mode 100644 index d28dc06..0000000 --- a/Projet/ImageProcessing/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -class ImageProcessing: - def __init__(self, image): - self.image = image diff --git a/Projet/Main.py b/Projet/Main.py index 345fe2c..ce974c8 100644 --- a/Projet/Main.py +++ b/Projet/Main.py @@ -1,4 +1,3 @@ from Bootstrap import Bootstrap -boot = Bootstrap() -boot.run() +Bootstrap().run() \ No newline at end of file diff --git a/Projet/Pipeline/Pipeline.py b/Projet/Pipeline/Pipeline.py new file mode 100644 index 0000000..b6c3a11 --- /dev/null +++ b/Projet/Pipeline/Pipeline.py @@ -0,0 +1,17 @@ +from EdgeDetection.EdgeDetection import EdgeDetection +from Clipping.Clipping import Clipping +from BoundaryTracing.BoudaryTracing import BoundaryTracing + +from Shared.Borg import Borg + +class Pipeline(Borg): + def __init__(self): + self.edgeDetec = EdgeDetection() + self.clip = Clipping() + self.boundTrac = BoundaryTracing() + + def run(self, input): + edges_image = self.edgeDetec.detect_edges(input) + clipped_image = self.clip.clip(edges_image) + + return clipped_image \ No newline at end of file diff --git a/Projet/Pipeline/__pycache__/Pipeline.cpython-35.pyc b/Projet/Pipeline/__pycache__/Pipeline.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ebd59caad5794dfedf1b12ec368638f0a4063d6f GIT binary patch literal 946 zcmZ8fJ&)8d5FIB@Hv0v4SI{6)lY$L&TOf4Yf#_B%?Nz3*LTvW3$`?+y*wa!iKZA~n zzm%4Wp8ygPGY&cJ;@FcnwrBj_*pH^u(bsRk-v40$Kj5fw#Fsc~fkt6xkOAZj1OrCC z1DON43&QPu7cvgH2g2)o4w(=60K@>;JLQ4$;R}ZOpa*ckumIEmR$=fH^Fzqm>07nd zZ*-%RCM^q`2(GiVs?uVO_~BK#EmUlFHzrQHDSlO&bwa^?a}ZqOsGp+IKunRSaELq7 z#nX|i!p<$`fUH)b-v-OH(pg&Q1dCuB{VCfu4x6n3H~{PcB!kB3u?r3FF$x6C#ulM( zD6}2wUXO9f=LyO&9HAI~AT=ZfrSV#4AHRbc;mYrMbX(>+%5+>PqoZY+?V_7y{cJve z{^E7CH04G&QBU_C%&J`*NSPLCBV~YjY99@-34V9y{q|YEBO!j&h|Gyh6u808V9(&d z;Il)LHxBhZs>T@?_HHNBH3JM66J@VVlG@tP;UPCe{Iy>w&#p@#Mb;Iz#{Hz1n+k$E(}e hXoYKLZM>e!5k1S+mLhoBNqa?4v8J+~G5nk}=P&FH(ZK)! literal 0 HcmV?d00001 diff --git a/Projet/Shared/Borg.py b/Projet/Shared/Borg.py new file mode 100644 index 0000000..fcf366d --- /dev/null +++ b/Projet/Shared/Borg.py @@ -0,0 +1,4 @@ +class Borg: + _shared_state = {} + def __init__(self): + self.__dict__ = self._shared_state \ No newline at end of file diff --git a/Projet/Shared/Parameters.py b/Projet/Shared/Parameters.py new file mode 100644 index 0000000..067c2b9 --- /dev/null +++ b/Projet/Shared/Parameters.py @@ -0,0 +1,10 @@ +class Parameters: + parameters = {} + + @staticmethod + def set_parameters(new_parameters): + Parameters.parameters.update(new_parameters) + + @staticmethod + def get_parameters(): + return Parameters.parameters \ No newline at end of file diff --git a/Projet/FingertipDetection/__init__.py b/Projet/Shared/__init__.py similarity index 100% rename from Projet/FingertipDetection/__init__.py rename to Projet/Shared/__init__.py diff --git a/Projet/Shared/__pycache__/Borg.cpython-35.pyc b/Projet/Shared/__pycache__/Borg.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a30744ae2bd54c51352f27607f21f24768a302fc GIT binary patch literal 445 zcmYjMJx{|h5IrYpsj5a|Dmz;SFfesMsKCG$MG8|GPEl-Vs(gT*4n=J66ZjMSrL6o4 zn7DI9)sx=4v+v&Xc^-z-`RC7r27qtEE_|w%1bakurvQ|I56ABwWK?*NMt(ufU3gS2 z3HF$X3^M_w%RDHFeKsHwd1L`7pVUDg+_dJY5H!xgnLTa^_K@feVC@*4QyPgl^7;_% zDmPl8?eb3d6GT-O9bzQ>9NZIi%STNL#Msf$;x20f-i|1}03n;&WL@rN`u#-+n2^ z4Tj#wQ~=Bf%qYA#K7zYO5gA6FvQQH)D-IK^mVy^DB58jipV;o^4U~`I??F7t=Q7SD zUkD}RB+u6IU80W%gVVF?I8pgb7V&7pl@#$#+sSfm`dSt>Ld&MDOrXz4HDnXjcs8rn znQCKEnsPp<^Pw!66In|w?3w;UV{-?4|7~ufhEdye7+c`$GG;=?=DAp9w(c_axZ+uP z^|l_k7nIMx^xNpu6NObS}#Emu?aV F;Rml&jPU>f literal 0 HcmV?d00001 diff --git a/Projet/Shared/__pycache__/__init__.cpython-35.pyc b/Projet/Shared/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..078a8c250ed98827a7aa93a6c87397dd03396894 GIT binary patch literal 137 zcmWgR<>iu}@-vzN2p)q77+?f49Dul(1xTbYFa&Ed`mJOr0tq9CUuOCl`MIh3IjMWHa^HWN5 MQtd$I6$3E?0RD_0Z2$lO literal 0 HcmV?d00001 diff --git a/Projet/Training/Trainer.py b/Projet/Training/Trainer.py new file mode 100644 index 0000000..e80d471 --- /dev/null +++ b/Projet/Training/Trainer.py @@ -0,0 +1,45 @@ +from PIL import Image +from os import listdir +import numpy as np + +from Utils.ReadWrite import ReadWrite +from Classifier.DescriptorGenerator import DescriptorGenerator +from Pipeline.Pipeline import Pipeline + +from Shared.Borg import Borg +from Shared.Parameters import Parameters + +class Trainer(Borg): + def __init__(self): + p = Parameters.get_parameters() + self.path_data = p['training_set'] + self.path_model = p['model_path'] + + def train(self): + actu_letter = None + + training_data_files = listdir(self.path_data) + print(training_data_files) + + centroid_actu_descriptor = DescriptorGenerator.generate_origin_descriptor() + + count = 0 + + for i in range(0, len(training_data_files)): + if training_data_files[i].split('_') == actu_letter: + count = count + 1 + + img = np.asarray(Image.open(self.path_data + training_data_files[i]).convert('L')) + data = Pipeline().run(img) + + centroid_actu_descriptor = centroid_actu_descriptor + DescriptorGenerator.generate_descriptor(data) + + else: + centroid_actu_descriptor = centroid_actu_descriptor / count + ReadWrite.write(self.path_model, actu_letter + ' ' + centroid_actu_descriptor) + + actu_letter = training_data_files[i].split('_') + centroid_actu_descriptor = DescriptorGenerator.generate_origin_descriptor() + count = 0 + + diff --git a/Projet/ImageProcessing/ImageProcessing.py b/Projet/Training/__init__.py similarity index 100% rename from Projet/ImageProcessing/ImageProcessing.py rename to Projet/Training/__init__.py diff --git a/Projet/Training/__pycache__/Trainer.cpython-35.pyc b/Projet/Training/__pycache__/Trainer.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fbf87011e68c3f8fb4d0ca299e8c1664075e9eac GIT binary patch literal 1578 zcmZux&5j#I5U%d|v&ZALy_VK20hA+-z=jh!AQVWXRitQTk)TL}&}ii8^^WQJNlzQt z$UZI4zyomOJ&<^ZKEQ!f9)X;w>alkt$Y`dfs=Dj%tLi@K_rt$_{pVZb0sIYbJTCGN z@N0fSlHtoh0u&5l28?75l0)G@?6k52(uLTwdtHz|6amCRyXJxHK+%P`+sZ!35Q-ke zy;crDMo{!2?zeIW_XmA%4w0 zBpP7N;2L1ZV2jQeoNfUUZUx>7=oiqPb8aF{{_=8_G(wxOs4^jwI@Om`S9Q>vIa&#g zibD~mON&XC>ePgmwI)+;+(yU?!|LBajnMG*XYamz#`UXFNgcuXNL_pAW){X(SmS-&|rC3 zK0<+|6B-P595iCUiD%k@wQDg#Byi1zpZ)}mh~Pf@36(TI50tT-GOx%bO`I-KIGnLg8SDIwGkP7cRpwwJIv|`w!YN_uyuek8o)Ln z&1C1mi!;((av!l{e&U4e4jg8rvu1m7AizQt#u=c<_zRWiz|EoLUe+ zcqr4R$uDv|P;a@aY3rUT T@C6N7Gek0ELl$wOL!$g&Thw!- literal 0 HcmV?d00001 diff --git a/Projet/Training/__pycache__/__init__.cpython-35.pyc b/Projet/Training/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fd1cc21d87cb5ba4a8aa1f6c0a30d8e54900d0a3 GIT binary patch literal 139 zcmWgR<>eCZ{SnOo1dl-k3@`#24nSPY0whux7=kq!{Z=v*frJsnFAM#Q{M=OioYcg; zl%iDqfc%_F{g8lST?-2XLr499qWrAX68(^(#LT?RymbBecpzO8AFo$Xd5gm)H$SB` NC)EyQVlfai002Q?AVdHF literal 0 HcmV?d00001 diff --git a/Projet/Utils/ArgParser.py b/Projet/Utils/ArgParser.py index 08c54d8..5d7a2d0 100644 --- a/Projet/Utils/ArgParser.py +++ b/Projet/Utils/ArgParser.py @@ -1,5 +1,4 @@ import argparse -from Shared.Parameters import Parameters class ArgParser: @@ -8,16 +7,8 @@ def parse(): parser = argparse.ArgumentParser( description='Relay between Oronos rocket & clients (PC/tablets).') - parser.add_argument('-b', '--baudrate', type=int, - help='Baudrate of the serial port') - parser.add_argument('-c', '--connector_type', - help='Data source', choices=['serial', 'simulation'], default='simulation') - parser.add_argument('-f', '--connector_file', - help='Connector type. COM serial port or CSV file') - parser.add_argument('-s', '--server', type=int, default=3000, - help='Activates a server listening on a certain port') - parser.add_argument('-r', '--rocket', default='11_valkyrieM2.xml', - help='XML configuration file') - parser.add_argument('-m', '--map', default='spaceport_america', - help='Name of the map in Config/Other/Maps.xml') + parser.add_argument('-m', '--mode', help='Mode of execution', choices=['training', 'classification', 'article'], default='article') + parser.add_argument('-i', '--input_image', help='Image to process', default='./asl_alphabet_test/A_test.jpg') + parser.add_argument('-s', '--training_set', help='Data set', default='./TrainingSet/') + parser.add_argument('-mp', '--model_path', help='Model path', default='./TrainedModel/model.txt') return parser.parse_args() \ No newline at end of file diff --git a/Projet/Utils/ReadWrite.py b/Projet/Utils/ReadWrite.py new file mode 100644 index 0000000..be3adb9 --- /dev/null +++ b/Projet/Utils/ReadWrite.py @@ -0,0 +1,13 @@ +class ReadWrite: + @staticmethod + def read(path): + file = open(path, 'r') + return file.readlines() + + @staticmethod + def write(path, data): + file = open(path, 'a+') + file.write(data) + file.close() + + \ No newline at end of file diff --git a/Projet/Utils/__pycache__/ArgParser.cpython-35.pyc b/Projet/Utils/__pycache__/ArgParser.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6bce299813b7a3693ac8d454a4d1c599826dc6ff GIT binary patch literal 992 zcmYjQOK;Oa5FR^8^JtQ`JW3A;Ss~^o$`S#=Q`(Hl5Z&W6xqogZdwGgu}$j%j=5dE?JPm$(N)LShGRIL^N{`#&t_Z z9HzZ5CnF{m$}1v|V%xM1XsPccG{BilO7U~>z5skCi>rzgQ3LoI@FwsU@HX%cOeop9 zRpx%pTe^0E_nd3rVH+jiKkD~!GcPzO7QW}Tx-WLoO9 z$g9V1QLu~P1obDxJa{9EyikEGk`JhZ`#~a7%(V)3M+cE+Cjzw^3@bm(sN$#Pk!vluA$2gjttylS!Q>0!@?SDVqsR z%xTpN!!$2vI!-e-!D{oBeFeG*N-7JLs_qOUrbNs{Ib~FMtWoJ`-@S%s<%CF7)epnV zw6Q{6wO%mI0;~0h(ebjNBh*n<3$wE7F1itM$@H}9*ltAN^qr+Ua%YTe(_*O4H4Q_H z$w_I4!Srb?W*L2|#cY@^<2)wR*-Xbd*}WQgX3g#7Pmp~YmVZy8X^~+hkmX!rG%CbJ zbUaew-rmDU`_V`iXH?}ooeC9Ek_G>;yf6(%)38HldBAUbZU2FH+uha1im$EkaL_QV zIL=vyacnwqOnuCR)w^;0amK_F=_*bCCdp7w3obW_*HyV9Hmr?KBh+art8_iLANbN9 Y1E;U}+v21RGOeeJq|fY$SwzKhsjIAEmjL81yOV#li?xM$=6+ zR~2$=sAxz{Nut{1_kSg}aysvO=IZb@`~Vw)gy#SN literal 0 HcmV?d00001 diff --git a/Projet/Utils/__pycache__/__init__.cpython-35.pyc b/Projet/Utils/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4e7b35b9fb1c9041dfbe1030e58eaef51eda8b61 GIT binary patch literal 136 zcmWgR<>g`z`4G(j1dl-k3@`#24nSPY0whux7=kq!{Z=v*frJsnFH`-D{M=OioYcg; zl%iDqfc%_F{g8lST?-2XLr499qWrAX68+GU%$#EV`1s7c%#!$cy@JYH95%W6DWy57 Lb|B-5ftUdRt;!z7 literal 0 HcmV?d00001 diff --git a/Projet/__pycache__/Bootstrap.cpython-35.pyc b/Projet/__pycache__/Bootstrap.cpython-35.pyc index e625a9f71511b75253e562ea1e9a38d40f6c1c63..20d11f36953518af433cf88eab91af3827d22924 100644 GIT binary patch literal 1611 zcmZuxJ8vU55FYMRPfN1TzFc!ax@-~YlIn^eINt?09AFp%>}!}}!INldH{3@^DuE5T za)4C%6{*sv%1_xYNR^+ERGHyQwgcSm&TwWp9L|0-4WM)(Ffjd^#IfW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