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
Hide 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 @@
...
@@ -5,25 +5,26 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Formulaire d'upload de fichiers
</title>
<title>
Formulaire d'upload de fichiers
</title>
<script
src=
"jquery.js"
></script>
<script
src=
"script.js"
></script>
<!-- API TenserFlow -->
<!-- API TenserFlow -->
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"
></script>
</head>
</head>
<body>
<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"
>
<form
id =
"form"
action=
""
method=
""
enctype=
"multipart/form-data"
>
<h2>
Upload Fichier
</h2>
<h2>
Upload Fichier
</h2>
<div
id =
"div-ID"
>
<div
id =
"div-ID"
>
<canvas
id=
"canvas"
></canvas>
<canvas
id=
"canvas"
></canvas>
<img
id=
"img-ID"
src=
""
/>
<img
id=
"img-ID"
src=
""
height=
"150em"
/>
</div>
</div>
<label
for=
"fileUpload"
>
Fichier:
</label>
<label
for=
"fileUpload"
>
Fichier:
</label>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
>
<input
id=
"#btnSubmit"
type=
"submit"
name=
"submit"
value=
"Upload"
>
<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><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>
</form>
<div
id=
"div"
></div>
<div
id=
"div"
>
</div>
</body>
</body>
</html>
</html>
script.js
View file @
35407622
// VARIABLES
// VARIABLES
const
URL_CHECK_ID
=
'upload.php'
;
const
URL_CHECK_ID
=
'upload.php'
;
const
ID
=
$
(
"#img-ID"
);
const
ID
=
"img-ID"
;
const
canva
=
$
(
"#canva"
);
const
canva
=
"canvas"
;
const
idBtnSubmit
=
'btnSubmit'
;
btnSubmit
=
$
(
"#"
+
idBtnSubmit
);
// SCRIPT
// SCRIPT
...
@@ -24,57 +25,61 @@ $(document).ready(function(){
...
@@ -24,57 +25,61 @@ $(document).ready(function(){
contentType
:
false
,
contentType
:
false
,
processData
:
false
processData
:
false
})
})
.
done
(
function
(
response
){
.
done
(
function
(
data
){
//Traitement de la réponse
console
.
log
(
data
);
let
data
=
JSON
.
stringify
(
response
);
$
(
"div#div"
).
empty
();
$
(
"div#div"
).
empty
();
$
(
"div#div"
).
append
(
data
[
'message'
]);
$
(
"div#div"
).
append
(
data
);
//Affichage de la photo
//Affichage de la photo
$
(
"#img-ID"
).
attr
(
'src'
,
data
[
'src'
]);
findFaces
();
})
})
// findFaces();
});
});
});
});
// FONCTIONS
// FONCTIONS
async
function
findFaces
()
{
async
function
findFaces
()
{
const
model
=
await
blazeface
.
load
();
btnSubmit
.
prop
(
'disabled'
,
false
);
const
img
=
ID
;
console
.
log
(
'_findFaces()'
);
const
predictions
=
await
model
.
estimateFaces
(
img
,
false
);
const
model
=
await
blazeface
.
load
();
if
(
predictions
.
length
>
0
)
{
// const img = ID;
console
.
log
(
"faces found"
)
const
img
=
document
.
getElementById
(
ID
);
console
.
log
(
predictions
);
const
predictions
=
await
model
.
estimateFaces
(
img
,
false
);
document
.
getElementById
(
"status"
).
innerText
=
"Face(s) found!"
;
console
.
log
(
'_findFaces()'
);
const
canvas
=
canva
;
if
(
predictions
.
length
>
0
)
{
canvas
.
width
=
img
.
width
;
console
.
log
(
"faces found"
)
canvas
.
height
=
img
.
height
;
console
.
log
(
predictions
);
// const ctx = canvas.getContext("2d");
document
.
getElementById
(
"p-status"
).
innerText
+=
predictions
.
length
+
" face(s) found!"
;
// ctx.fillStyle = "rgba(250,225,6,0.5)";
// const canvas = document.getElementById(canva);
// for (let i = 0; i < predictions.length; i++)
// canvas.width = img.width;
// {
// canvas.height = img.height;
// const start = predictions[i].topLeft;
// const ctx = canvas.getContext("2d");
// const end = predictions[i].bottomRight;
// ctx.fillStyle = "rgba(250,225,6,0.5)";
// const size = [end[0] - start[0], end[1] - start[1]];
// for (let i = 0; i < predictions.length; i++)
// ctx.fillRect(start[0], start[1], size[0], size[1]);
// {
// var landmark;
// const start = predictions[i].topLeft;
// for (let j = 0; j < predictions[i].landmarks.length; j++)
// const end = predictions[i].bottomRight;
// {
// const size = [end[0] - start[0], end[1] - start[1]];
// landmark = predictions[i].landmarks[j];
// ctx.fillRect(start[0], start[1], size[0], size[1]);
// ctx.beginPath();
// var landmark;
// ctx.arc(landmark[0],landmark[1], 1, 0, 2*Math.PI,false);
// for (let j = 0; j < predictions[i].landmarks.length; j++)
// ctx.fill();
// {
// ctx.lineWidth = 1;
// landmark = predictions[i].landmarks[j];
// ctx.strokeStyle = '#ff0000';
// ctx.beginPath();
// ctx.stroke();
// ctx.arc(landmark[0],landmark[1], 1, 0, 2*Math.PI,false);
// }
// ctx.fill();
// }
// ctx.lineWidth = 1;
}
// ctx.strokeStyle = '#ff0000';
else
{
// ctx.stroke();
document
.
getElementById
(
"status"
).
innerText
=
"No Face(s) Found"
;
// }
}
// }
}
else
{
document
.
getElementById
(
"status"
).
innerText
=
"No Face(s) Found"
;
}
btnSubmit
.
prop
(
'disabled'
,
false
);
}
}
upload.php
View file @
35407622
<?php
<?php
define
(
"PATH_TO_ID"
,
"
"
);
define
(
'PATH_TO_ID'
,
"img
"
);
// Vérifier si le formulaire a été soumis
// 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.
// Vérifie si le fichier a été uploadé sans erreur.
//format de la réponse
//format de la réponse
...
@@ -26,14 +27,14 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
...
@@ -26,14 +27,14 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
if
(
in_array
(
$filetype
,
$allowed
))
if
(
in_array
(
$filetype
,
$allowed
))
{
{
// Vérifie si le fichier existe avant de le télécharger.
// 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à.";
//echo $_FILES["photo"]["name"] . " existe déjà.";
$message
=
$_FILES
[
"photo"
][
"name"
]
.
" existe déjà."
;
$message
=
$_FILES
[
"photo"
][
"name"
]
.
" existe déjà."
;
}
}
else
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 "Votre fichier a été téléchargé avec succès.";
// echo("<br></br>");
// echo("<br></br>");
// echo "taille de la photo : ".$_FILES["photo"]["size"]." octets";
// echo "taille de la photo : ".$_FILES["photo"]["size"]." octets";
...
@@ -58,7 +59,10 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
...
@@ -58,7 +59,10 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
// echo "Error: " . $_FILES["photo"]["error"];
// echo "Error: " . $_FILES["photo"]["error"];
$message
=
"Error: "
.
$_FILES
[
"photo"
][
"error"
];
$message
=
"Error: "
.
$_FILES
[
"photo"
][
"error"
];
}
}
header
(
'Content-Type: application/json'
);
$data
=
array
(
echo
json_encode
(
$message
);
"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