Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Projet ISIS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MARQUE Pierre
Projet ISIS
Commits
35407622
Commit
35407622
authored
Mar 12, 2022
by
Okthane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comptage de visages
parent
876d653f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
58 deletions
+68
-58
index.php
index.php
+9
-8
script.js
script.js
+49
-44
upload.php
upload.php
+10
-6
No files found.
index.php
View file @
35407622
...
...
@@ -5,25 +5,26 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Formulaire d'upload de fichiers
</title>
<script
src=
"jquery.js"
></script>
<script
src=
"script.js"
></script>
<!-- API TenserFlow -->
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"
></script>
</head>
<body>
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"
></script>
<script
src=
"https://code.jquery.com/jquery-3.6.0.min.js"
></script>
<script
src=
"script.js"
></script>
<form
id =
"form"
action=
""
method=
""
enctype=
"multipart/form-data"
>
<h2>
Upload Fichier
</h2>
<div
id =
"div-ID"
>
<canvas
id=
"canvas"
></canvas>
<img
id=
"img-ID"
src=
""
/>
<canvas
id=
"canvas"
></canvas>
<img
id=
"img-ID"
src=
""
height=
"150em"
/>
</div>
<label
for=
"fileUpload"
>
Fichier:
</label>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
>
<input
id=
"#btnSubmit"
type=
"submit"
name=
"submit"
value=
"Upload"
>
<p><strong>
Note:
</strong>
Seuls les formats .jpg et .png sont autorisés jusqu'à une taille maximale de 5 Mo.
</p>
<
!-- <p id="p-status"><strong>Statut :</strong></p> -->
<
p
id=
"p-status"
><strong>
Statut :
</strong></p>
</form>
<div
id=
"div"
></div>
<div
id=
"div"
>
</div>
</body>
</html>
script.js
View file @
35407622
// VARIABLES
const
URL_CHECK_ID
=
'upload.php'
;
const
ID
=
$
(
"#img-ID"
);
const
canva
=
$
(
"#canva"
);
const
ID
=
"img-ID"
;
const
canva
=
"canvas"
;
const
idBtnSubmit
=
'btnSubmit'
;
btnSubmit
=
$
(
"#"
+
idBtnSubmit
);
// SCRIPT
...
...
@@ -24,33 +25,36 @@ $(document).ready(function(){
contentType
:
false
,
processData
:
false
})
.
done
(
function
(
response
){
//Traitement de la réponse
let
data
=
JSON
.
stringify
(
response
);
.
done
(
function
(
data
){
console
.
log
(
data
);
$
(
"div#div"
).
empty
();
$
(
"div#div"
).
append
(
data
);
$
(
"div#div"
).
append
(
data
[
'message'
]
);
//Affichage de la photo
$
(
"#img-ID"
).
attr
(
'src'
,
data
[
'src'
]);
findFaces
();
})
// findFaces();
});
});
// FONCTIONS
async
function
findFaces
()
{
btnSubmit
.
prop
(
'disabled'
,
false
);
console
.
log
(
'_findFaces()'
);
const
model
=
await
blazeface
.
load
();
const
img
=
ID
;
// const img = ID;
const
img
=
document
.
getElementById
(
ID
);
const
predictions
=
await
model
.
estimateFaces
(
img
,
false
);
console
.
log
(
'_findFaces()'
);
if
(
predictions
.
length
>
0
)
{
console
.
log
(
"faces found"
)
console
.
log
(
predictions
);
document
.
getElementById
(
"status"
).
innerText
=
"F
ace(s) found!"
;
const
canvas
=
canva
;
canvas
.
width
=
img
.
width
;
canvas
.
height
=
img
.
height
;
document
.
getElementById
(
"p-status"
).
innerText
+=
predictions
.
length
+
" f
ace(s) found!"
;
// const canvas = document.getElementById(canva)
;
//
canvas.width = img.width;
//
canvas.height = img.height;
// const ctx = canvas.getContext("2d");
// ctx.fillStyle = "rgba(250,225,6,0.5)";
// for (let i = 0; i < predictions.length; i++)
...
...
@@ -75,6 +79,7 @@ async function findFaces() {
else
{
document
.
getElementById
(
"status"
).
innerText
=
"No Face(s) Found"
;
}
btnSubmit
.
prop
(
'disabled'
,
false
);
}
upload.php
View file @
35407622
<?php
define
(
"PATH_TO_ID"
,
"
"
);
define
(
'PATH_TO_ID'
,
"img
"
);
// Vérifier si le formulaire a été soumis
if
(
$_SERVER
[
"REQUEST_METHOD"
]
==
"POST"
){
if
(
$_SERVER
[
"REQUEST_METHOD"
]
==
"POST"
)
{
// Vérifie si le fichier a été uploadé sans erreur.
//format de la réponse
...
...
@@ -26,14 +27,14 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
if
(
in_array
(
$filetype
,
$allowed
))
{
// Vérifie si le fichier existe avant de le télécharger.
if
(
file_exists
(
PATH_TO_ID
.
$_FILES
[
"photo"
][
"name"
]))
if
(
file_exists
(
PATH_TO_ID
.
"/"
.
$_FILES
[
"photo"
][
"name"
]))
{
//echo $_FILES["photo"]["name"] . " existe déjà.";
$message
=
$_FILES
[
"photo"
][
"name"
]
.
" existe déjà."
;
}
else
{
move_uploaded_file
(
$_FILES
[
"photo"
][
"tmp_name"
],
$_FILES
[
"photo"
][
"name"
]);
move_uploaded_file
(
$_FILES
[
"photo"
][
"tmp_name"
],
PATH_TO_ID
.
"/"
.
$_FILES
[
"photo"
][
"name"
]);
// echo "Votre fichier a été téléchargé avec succès.";
// echo("<br></br>");
// echo "taille de la photo : ".$_FILES["photo"]["size"]." octets";
...
...
@@ -58,7 +59,10 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
// echo "Error: " . $_FILES["photo"]["error"];
$message
=
"Error: "
.
$_FILES
[
"photo"
][
"error"
];
}
header
(
'Content-Type: application/json'
);
echo
json_encode
(
$message
);
$data
=
array
(
"message"
=>
$message
,
"src"
=>
PATH_TO_ID
.
"/"
.
$_FILES
[
"photo"
][
"name"
]
);
echo
json_encode
(
$data
);
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment