Début test interface borne

This commit is contained in:
2023-01-04 22:07:32 +01:00
parent 66d1aaf027
commit b31ee7c0b9
39 changed files with 3354 additions and 3260 deletions

View File

@@ -0,0 +1,52 @@
let canvas = document.getElementById('camera');
let video = document.getElementById('video');
const width = 320; // We will scale the photo width to this
let height = 0; // This will be computed based on the input stream
let streaming = false;
function startup() {
video = document.getElementById("video");
canvas = document.getElementById("canvas");
navigator.mediaDevices
.getUserMedia({ video: true, audio: false })
.then((stream) => {
video.srcObject = stream;
video.play();
})
.catch((err) => {
console.error(`An error occurred: ${err}`);
});
video.addEventListener(
"canplay",
(ev) => {
if (!streaming) {
height = video.videoHeight / (video.videoWidth / width);
// Firefox currently has a bug where the height can't be read from
// the video, so we will make assumptions if this happens.
if (isNaN(height)) {
height = width / (4 / 3);
}
video.setAttribute("width", width);
video.setAttribute("height", height);
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
streaming = true;
drawVideoOnCanvas();
}
},
false
);
}
window.addEventListener("load", startup, false);
const drawVideoOnCanvas = () => {
canvas.getContext("2d").drawImage(video, 0, 0, width, height);
requestAnimationFrame(drawVideoOnCanvas);
}

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Téléreview</title>
</head>
<body>
<canvas id="camera"></canvas>
<video id="video"></video>
</body>
</html>

View File

@@ -0,0 +1,29 @@
import requests
#Exemple ajout d'un commentaire depuis la borne (site ou geste)
avis = {
"note": 8,
"source": "borne",
#Optionel
"auteur_age": 20,
"notes_autre": '{"proprete":8,"calme":10}',
"auteur_sexe": 'f',
"commentaire": "Commentaire"
}
# res = requests.post("http://localhost:8080/add_review", data=avis)
# print(res.text)
#Exemple ajout d'un commentaire trouvé sur les réseaux sociaux
avis = {
"auteur_nom": "michel",
"source": "instagram",
"note": 8,
"date": "2022-12-24",
#Optionel
"commentaire": "J'ai beaucoup aimé !",
"lien": "https://instagram.com/si_insta_avait_des_liens_vers_des_commentaires_faudrait_le_mettre_ici",
"auteur_lien": "https://instagram.com/michel",
}
res = requests.post("http://localhost:8080/add_social_review", data=avis)
print(res.text)