-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
163 lines (146 loc) · 6.36 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env python3
# Copyright © 2020 Hethsron Jedaël BOUEYA and Yassine BENOMAR
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""!
@file main.py
@brief Facial Recognition Algorithm Using CNN Algorithm
@details Declaration of starting point of this program
@author BOUEYA Hethsron Jedaël <[email protected]>
BENOMAR Yassine <[email protected]>
@version 0.0.1
@date October 23th, 2020
@note For this program, we recommand to use the existing virtual
environment that allows you to avoid installing Python
packages globally which could break system tools or other projects
@pre Before you can start installing or using packages in the
existing virtual environment, you'll need to activate it.
Activating this virtual environment will put the virtual
environment-specifi python and pip executables into your
shell's PATH.
- On macOS and Linux, run :
source env/bin/activate
- On Windows, run :
.\env\Scripts\activate
@post If you want to switch projects or otherwise leave this virtual
environment, simply run :
deactivate
@bug No known bug to date
@warning Misuse could cause program crash
@attention
@remark
@copyright GPLv3+ : GNU GPL version 3 or later
Licencied Material - Property of Stimul’Activ®
© 2020 ENSISA (UHA) - All rights reserved.
"""
import os, sys, glob
from art import tprint
from deepmwoo.core.capture import shooting
from deepmwoo.core.train import training
from deepmwoo.core.access import argv
from deepmwoo.core.recognize import recognition
from getopt import getopt, GetoptError
class mwoo(object):
"""!
@class mwoo
@brief Define useful static methods to run `DeepMwoo`.
"""
@staticmethod
def __version__():
"""!
@fn __version__
@brief Display information about `DeepMwoo` release.
"""
tprint('DeepMwoo', font = 'bulbhead')
print('Version 0.0.1')
print('License GPLv3+ : GNU GPL version 3 or later')
print('Licencied Material - Property of Stimul’Activ®')
print('© 2020 ENSISA (UHA) - All rights reserved.')
@staticmethod
def __usage__():
"""!
@fn __usage__
@brief Display most of command line options that you can use
with `DeepMwoo`.
"""
if sys.platform in ('win32', 'win64'):
pass
else:
os.system('clear')
os.system('groff -Tascii -man deepmwoo.man')
@staticmethod
def main():
"""!
@fn main
@brief Parse and interpret options.
"""
try:
opts, args = getopt(sys.argv[1:], 'chi:trv', [ 'capture', 'help', 'image=', 'train', 'recognize', 'version' ])
except GetoptError as err:
print(err)
# Unsucessful termination occurs when parsing command-line options
sys.exit(2)
for o, a in opts:
if o in ('-c', '--capture'):
# Check if there is no argument
if not args:
# Make a shooting of 30 pictures
shooting.make(video_source = 0)
else:
# Built-in assert statement to find errors
assert False, 'The command does not run if the argument is provided'
elif o in ('-h', '--help'):
# Check if there is no argument
if not args:
# Display usage of the application
mwoo.__usage__()
else:
# Built-in assert statement to find errors
assert False, 'The command does not run if the argument is provided'
elif o in ('-i', '--image'):
# Check if given argument is a valid readable image
if argv.is_image(given_argv = a):
# Built-in tracking
#recognition.fromImage(id = 1, image_source = a)
print('OK')
pass
else:
# Built-in assert statement to find errors
assert False, 'Invalid argument'
elif o in ('-t', '--train'):
# Check if there is no argument
if not args:
training.make()
else:
# Built-in assert statement to find errors
assert False, 'The command does not run if the argument is provided'
elif o in ('-r', '--recognize'):
# Check if given argument is a valid integer
if not args:
recognition.fromStream(video_source = 0)
else:
# Built-in assert statement to find errors
assert False, 'The command does not run if the argument is provided'
elif o in ('-v', '--version'):
# Check if there is no argument
if not args:
mwoo.__version__()
else:
# Built-in assert statement to find errors
assert False, 'The command does not run if the argument is provided'
else:
# Built-in assert statement to find errors
assert False, 'Unhandled option'
# No problems occured (successful termination)
sys.exit(0)
if __name__ == '__main__':
mwoo.main()