Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
INT-HACK-Groupe7
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PC-AP-INT446-N-2023
Hacking Health
INT-HACK-Groupe7
Commits
46b101b5
Commit
46b101b5
authored
Feb 8, 2023
by
BIRK Renaud
Browse files
Options
Downloads
Patches
Plain Diff
Ajout de l'interface graphique
parent
34ab0bea
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
CHANGELOG
+1
-0
1 addition, 0 deletions
CHANGELOG
poc/__init__.py
+2
-1
2 additions, 1 deletion
poc/__init__.py
poc/_models.py
+1
-1
1 addition, 1 deletion
poc/_models.py
poc/_ui.py
+124
-0
124 additions, 0 deletions
poc/_ui.py
test.py
+28
-23
28 additions, 23 deletions
test.py
with
156 additions
and
25 deletions
CHANGELOG
+
1
−
0
View file @
46b101b5
...
...
@@ -11,4 +11,5 @@ et le projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Ajout de l'OCR.
- Ajout de l'identification.
- Ajout de l'interface graphique.
- Ajout d'un fichier de test.
This diff is collapsed.
Click to expand it.
poc/__init__.py
+
2
−
1
View file @
46b101b5
...
...
@@ -4,9 +4,10 @@ ou prothèse à partir des informations présentes sur son emballage.
"""
__all__
=
[
"
Device
"
,
"
Group
"
,
"
Identification
"
,
"
OCR
"
"
Device
"
,
"
Group
"
,
"
Identification
"
,
"
OCR
"
,
"
UI
"
]
from
._identification
import
Identification
from
._models
import
Device
,
Group
from
._ocr
import
OCR
from
._ui
import
UI
This diff is collapsed.
Click to expand it.
poc/_models.py
+
1
−
1
View file @
46b101b5
...
...
@@ -22,10 +22,10 @@ class Group:
class
Device
:
"""
Classe représentant les informations d
'
identification d
'
un dispositif.
:param uid: L
'
identificateur unique (IUD)
:param manufacturer_name: Le fabricant
:param brand_name: La marque
:param description: Une description
:param uid: L
'
identificateur unique (IUD)
:param ref: La référence
:param useful_groups: La liste de groupes à trier
"""
...
...
...
...
This diff is collapsed.
Click to expand it.
poc/_ui.py
0 → 100644
+
124
−
0
View file @
46b101b5
from
._models
import
*
from
tkinter
import
*
class
UI
:
"""
Classe définissant une interface graphique remplie à l
'
issue de la phase
d
'
identification.
:param device: Un dispositif issu de la phase d
'
identification
:param export_path: Un chemin d
'
exportation
"""
def
__init__
(
self
,
device
:
Device
,
export_path
:
str
=
None
)
->
None
:
self
.
device
=
device
self
.
export_path
=
export_path
def
clear
(
self
)
->
None
:
"""
Nettoie la fenêtre.
"""
for
widget
in
self
.
app
.
winfo_children
():
widget
.
grid_forget
()
def
draw
(
self
)
->
None
:
"""
Dessine les composants sur la fenêtre.
"""
# S'il n'y a plus d'élements à trier, on arrête l'application
if
not
len
(
self
.
device
.
useful_groups
):
self
.
export
()
self
.
app
.
destroy
()
return
word_entry
=
Entry
(
self
.
app
,
justify
=
'
center
'
,
width
=
70
)
word_entry
.
insert
(
0
,
self
.
device
.
useful_groups
.
pop
(
0
).
string
)
word_entry
.
grid
(
row
=
1
,
column
=
1
,
columnspan
=
4
)
uid_button
=
Button
(
self
.
app
,
text
=
"
IUD
"
,
command
=
lambda
:
self
.
updateField
(
uid_entry
=
word_entry
))
uid_button
.
grid
(
row
=
2
,
column
=
1
)
manufacturer_button
=
Button
(
self
.
app
,
text
=
"
Fabricant
"
,
command
=
lambda
:
self
.
updateField
(
manufacturer_name_entry
=
word_entry
))
manufacturer_button
.
grid
(
row
=
2
,
column
=
2
)
brand_button
=
Button
(
self
.
app
,
text
=
"
Marque
"
,
command
=
lambda
:
self
.
updateField
(
brand_name_entry
=
word_entry
))
brand_button
.
grid
(
row
=
2
,
column
=
3
)
ref_button
=
Button
(
self
.
app
,
text
=
"
Reférence
"
,
command
=
lambda
:
self
.
updateField
(
ref_entry
=
word_entry
))
ref_button
.
grid
(
row
=
2
,
column
=
4
)
uid_entry
=
Entry
(
self
.
app
,
justify
=
'
center
'
,
width
=
20
)
uid_entry
.
insert
(
0
,
self
.
device
.
uid
)
uid_entry
.
grid
(
row
=
3
,
column
=
1
)
manufacturer_name_entry
=
Entry
(
self
.
app
,
justify
=
'
center
'
,
width
=
20
)
manufacturer_name_entry
.
insert
(
0
,
self
.
device
.
manufacturer_name
)
manufacturer_name_entry
.
grid
(
row
=
3
,
column
=
2
)
brand_name_entry
=
Entry
(
self
.
app
,
justify
=
'
center
'
,
width
=
20
)
brand_name_entry
.
insert
(
0
,
self
.
device
.
brand_name
)
brand_name_entry
.
grid
(
row
=
3
,
column
=
3
)
ref_entry
=
Entry
(
self
.
app
,
justify
=
'
center
'
,
width
=
20
)
ref_entry
.
insert
(
0
,
self
.
device
.
ref
)
ref_entry
.
grid
(
row
=
3
,
column
=
4
)
description_button
=
Button
(
self
.
app
,
text
=
"
Description
"
,
command
=
lambda
:
self
.
updateField
(
description
=
word_entry
))
description_button
.
grid
(
row
=
4
,
column
=
2
,
columnspan
=
2
)
trash_button
=
Button
(
self
.
app
,
text
=
"
Poubelle
"
,
command
=
self
.
updateField
)
trash_button
.
grid
(
row
=
4
,
column
=
1
)
exit_button
=
Button
(
self
.
app
,
text
=
"
Quitter
"
,
command
=
lambda
:
(
self
.
export
,
self
.
app
.
destroy
))
exit_button
.
grid
(
row
=
4
,
column
=
4
)
def
export
(
self
)
->
None
:
"""
Si le chemin d
'
export du fichier est défini on exporte le fichier au
format de dictionnaire Python.
"""
if
self
.
export_path
:
file
=
open
(
self
.
export_path
,
"
w
"
)
file
.
write
(
str
(
self
.
device
))
file
.
close
()
def
show
(
self
)
->
None
:
"""
Initialise et affiche la fenêtre.
"""
self
.
app
=
Tk
()
self
.
app
.
eval
(
'
tk::PlaceWindow . center
'
)
self
.
app
.
geometry
(
"
620x240
"
)
self
.
app
.
grid
()
self
.
app
.
columnconfigure
(
1
,
minsize
=
150
)
self
.
app
.
columnconfigure
(
2
,
minsize
=
150
)
self
.
app
.
columnconfigure
(
3
,
minsize
=
150
)
self
.
app
.
columnconfigure
(
4
,
minsize
=
150
)
self
.
app
.
rowconfigure
(
1
,
minsize
=
60
)
self
.
app
.
rowconfigure
(
2
,
minsize
=
60
)
self
.
app
.
rowconfigure
(
3
,
minsize
=
60
)
self
.
app
.
rowconfigure
(
4
,
minsize
=
60
)
self
.
draw
()
self
.
app
.
mainloop
()
def
updateField
(
self
,
uid_entry
:
Entry
=
None
,
manufacturer_name_entry
:
Entry
=
None
,
brand_name_entry
:
Entry
=
None
,
ref_entry
:
Entry
=
None
,
description
:
str
=
None
)
->
None
:
"""
Met à jour les champs du dispositif selon les informations remplies
dans les composants de la fenêtre.
:param uid_entry: Champ de texte de l
'
IUD
:param manufacturer_name_entry: Champ de texte du fabricant
:param brand_name_entry: Champ de texte de la marque
:param ref_entry: Champ de texte de la référence
:param description: Description
"""
if
uid_entry
:
self
.
device
.
uid
=
uid_entry
.
get
()
if
manufacturer_name_entry
:
self
.
device
.
manufacturer_name
=
manufacturer_name_entry
.
get
()
if
brand_name_entry
:
self
.
device
.
brand_name
=
brand_name_entry
.
get
()
if
ref_entry
:
self
.
device
.
ref
=
ref_entry
.
get
()
if
description
:
self
.
device
.
description
+=
description
.
get
()
+
"
\n
"
self
.
clear
()
self
.
draw
()
This diff is collapsed.
Click to expand it.
test.py
+
28
−
23
View file @
46b101b5
...
...
@@ -31,31 +31,36 @@ def main():
# 2 bis. Génération des images
ocr
.
save_ocr
(
device
.
useful_groups
,
TEST_IMAGES_DIR
+
"
/biomet.jpg
"
,
OUTPUT_DIR
+
"
/biomet_export_step2.jpg
"
,
FONT_DIR
+
"
/
"
+
FONT_FILENAME
)
# 3. Interface graphique de tri
UI
(
device
,
OUTPUT_DIR
+
"
/biomet_export_step3.txt
"
).
show
()
# Autres exemples
groups2
=
ocr
.
recognize
(
TEST_IMAGES_DIR
+
"
/passeo-18.jpg
"
)
ocr
.
save_ocr
(
groups2
,
TEST_IMAGES_DIR
+
"
/passeo-18.jpg
"
,
OUTPUT_DIR
+
"
/passeo-18_export_step1.jpg
"
,
FONT_DIR
+
"
/
"
+
FONT_FILENAME
)
file2
=
open
(
OUTPUT_DIR
+
"
/passeo-18_export_step1.txt
"
,
"
w
"
)
file2
.
write
(
str
(
groups2
))
file2
.
close
()
identification2
=
Identification
(
groups2
)
device2
=
identification2
.
identify
()
output_file2
=
open
(
OUTPUT_DIR
+
"
/passeo-18_export_step2.txt
"
,
"
w
"
)
output_file2
.
write
(
str
(
device2
))
output_file2
.
close
()
ocr
.
save_ocr
(
device2
.
useful_groups
,
TEST_IMAGES_DIR
+
"
/passeo-18.jpg
"
,
OUTPUT_DIR
+
"
/passeo-18_export_step2.jpg
"
,
FONT_DIR
+
"
/
"
+
FONT_FILENAME
)
groups3
=
ocr
.
recognize
(
TEST_IMAGES_DIR
+
"
/stryker.jpg
"
)
ocr
.
save_ocr
(
groups3
,
TEST_IMAGES_DIR
+
"
/stryker.jpg
"
,
OUTPUT_DIR
+
"
/stryker_export_step1.jpg
"
,
FONT_DIR
+
"
/
"
+
FONT_FILENAME
)
file3
=
open
(
OUTPUT_DIR
+
"
/stryker_export_step1.txt
"
,
"
w
"
)
file3
.
write
(
str
(
groups3
))
file3
.
close
()
identification3
=
Identification
(
groups3
)
device3
=
identification3
.
identify
()
output_file3
=
open
(
OUTPUT_DIR
+
"
/stryker_export_step2.txt
"
,
"
w
"
)
output_file3
.
write
(
str
(
device3
))
output_file3
.
close
()
ocr
.
save_ocr
(
device3
.
useful_groups
,
TEST_IMAGES_DIR
+
"
/stryker.jpg
"
,
OUTPUT_DIR
+
"
/stryker_export_step2.jpg
"
,
FONT_DIR
+
"
/
"
+
FONT_FILENAME
)
# groups2 = ocr.recognize(TEST_IMAGES_DIR + "/passeo-18.jpg")
# ocr.save_ocr(groups2, TEST_IMAGES_DIR + "/passeo-18.jpg", OUTPUT_DIR + "/passeo-18_export_step1.jpg", FONT_DIR + "/" + FONT_FILENAME)
# file2 = open(OUTPUT_DIR + "/passeo-18_export_step1.txt", "w")
# file2.write(str(groups2))
# file2.close()
# identification2 = Identification(groups2)
# device2 = identification2.identify()
# output_file2 = open(OUTPUT_DIR + "/passeo-18_export_step2.txt", "w")
# output_file2.write(str(device2))
# output_file2.close()
# ocr.save_ocr(device2.useful_groups, TEST_IMAGES_DIR + "/passeo-18.jpg", OUTPUT_DIR + "/passeo-18_export_step2.jpg", FONT_DIR + "/" + FONT_FILENAME)
# UI(device2, OUTPUT_DIR + "/passeo-18_export_step3.txt").show()
# groups3 = ocr.recognize(TEST_IMAGES_DIR + "/stryker.jpg")
# ocr.save_ocr(groups3, TEST_IMAGES_DIR + "/stryker.jpg", OUTPUT_DIR + "/stryker_export_step1.jpg", FONT_DIR + "/" + FONT_FILENAME)
# file3 = open(OUTPUT_DIR + "/stryker_export_step1.txt", "w")
# file3.write(str(groups3))
# file3.close()
# identification3 = Identification(groups3)
# device3 = identification3.identify()
# output_file3 = open(OUTPUT_DIR + "/stryker_export_step2.txt", "w")
# output_file3.write(str(device3))
# output_file3.close()
# ocr.save_ocr(device3.useful_groups, TEST_IMAGES_DIR + "/stryker.jpg", OUTPUT_DIR + "/stryker_export_step2.jpg", FONT_DIR + "/" + FONT_FILENAME)
# UI(device3, OUTPUT_DIR + "/stryker_export_step3.txt").show()
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment