mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 02:20:17 +01:00
Début test interface borne
This commit is contained in:
52
code/client/borne/assets/js/main.js
Normal file
52
code/client/borne/assets/js/main.js
Normal 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);
|
||||
}
|
||||
13
code/client/borne/index.html
Normal file
13
code/client/borne/index.html
Normal 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>
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user