diff --git a/arduino/smartcar/secrets.hpp b/arduino/smartcar/secrets.hpp index 59de031..16c87f8 100644 --- a/arduino/smartcar/secrets.hpp +++ b/arduino/smartcar/secrets.hpp @@ -1,5 +1,5 @@ #pragma once -const char host[] = "aerostun.dev"; +const char host[] = "localhost"; const int port = 1883; const char clientId[] = "clientId_Hes24TQfz"; const char username[] = "group09"; diff --git a/arduino/smartcar/smartcar.ino b/arduino/smartcar/smartcar.ino index 5bf0cb6..8ec072f 100644 --- a/arduino/smartcar/smartcar.ino +++ b/arduino/smartcar/smartcar.ino @@ -99,7 +99,7 @@ void setup() // Start the camera and connect to MQTT broker #ifdef __SMCE__ - Camera.begin(QVGA, RGB888, 15); + Camera.begin(VGA, RGB888, 30); frameBuffer.resize(Camera.width() * Camera.height() * Camera.bytesPerPixel()); mqtt.setKeepAlive(30); mqtt.begin(host, port, WiFi); diff --git a/frontendApp/assets/js/communication.js b/frontendApp/assets/js/communication.js index 7889437..771082e 100644 --- a/frontendApp/assets/js/communication.js +++ b/frontendApp/assets/js/communication.js @@ -96,24 +96,27 @@ function onConnect () { console.log("Camera") canvas = document.getElementById('cameraCanvas'); ctx = canvas.getContext('2d'); + + const width = 640; + const height = 480; + + const arrayBuffer = new ArrayBuffer(width * height * 4); + const pixels = new Uint8ClampedArray(arrayBuffer); + var n = 0; + + for (var i = 0; i < message.length; i += 3) + { + n += 4; + pixels[n] = message[i]; + pixels[n + 1] = message[i + 1]; + pixels[n + 2] = message[i + 2]; + pixels[n + 3] = 255; - const width = 320; - const height = 240; - - const imageData = ctx.getImageData(0, 0, width, height); - const data = message; - for (var x = 0; x < width; x++) { - for (var y = 0; y < height; y++) { - var i = (x + y * width) * 3; - var r = message[i + 0]; - var g = message[i + 1]; - var b = message[i + 2]; - - ctx.fillStyle = 'rgb(' + r + ',' + g + ',' + b + ')'; - ctx.fillRect(x, y, 1, 1); - } - } - + } + + const imageData = new ImageData(pixels, width, height); + ctx.putImageData(imageData, 0, 0); + } else { const msg = `${message.toString()}\nOn topic: ${topic}` diff --git a/frontendApp/manual.html b/frontendApp/manual.html index 945b0d5..fa1571d 100644 --- a/frontendApp/manual.html +++ b/frontendApp/manual.html @@ -40,8 +40,7 @@

Live Stream

- - +