Intégration de la reco d'image à l'interface borne

This commit is contained in:
Quentin Roussel
2023-03-22 14:39:56 +01:00
parent 15bc1c7714
commit d896767543
11 changed files with 131 additions and 156 deletions

View File

@@ -84,7 +84,6 @@ class CameraPage {
_frame() {
if (this.streaming && this.enabled && this.width && this.height) {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
// this.ctx.drawImage(this.video, 0, 0, this.width, this.height);
this._drawEffects();
}
if (this.enabled) {
@@ -106,6 +105,11 @@ class CameraPage {
_drawEffects() {
for (let effect of this.activeEffects) {
let { x, y, width, height } = this._scaleEffect(effect.x, effect.y, effect.width, effect.height);
width = width * this.videoWidth * 2;
height = height * this.videoHeight * 2;
x = x * this.videoWidth - width / 2;
y = y * this.videoHeight - height / 2;
console.log(width, height);
if (effect.type == "thumbs_down") {
this._drawThumbsDown(x, y, width, height);
}

View File

@@ -3,14 +3,16 @@ class WebsocketClient {
this.socket = new WebSocket("ws://localhost:5000");
this.socket.addEventListener("open", (event) => {
this.socket.send("connected");
console.log("connected")
});
this.socket.addEventListener("message", (event) => {
this.socket.onmessage = (event) => {
let msg = JSON.parse(event.data);
if (msg.type == "effects") {
onNewEffects(msg.effects);
}else if(msg.type == "state") {
onNewState(msg.state);
}
});
};
}
}

View File

@@ -14,8 +14,11 @@ class StateManager {
this._thankYouPage = new ThankYouPage();
this.wsClient = new WebsocketClient(
(effects) => this._cameraPage.setEffects(effects),
(state) => this.changeState(state)
(effects) => {
this.setState(STATE.video);
this._cameraPage.setEffects(effects)
},
(state) => this.setState(state)
);
this._sleepingPage.enabled = true;