Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement live feed #81

Merged
merged 1 commit into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arduino/smartcar/secrets.hpp
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion arduino/smartcar/smartcar.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
37 changes: 20 additions & 17 deletions frontendApp/assets/js/communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`

Expand Down
3 changes: 1 addition & 2 deletions frontendApp/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ <h3 class="panel-title">Live Stream</h3>
<div id="nasaStream" class="nasa-stream panel-body"><iframe style="display: block; margin: 0 auto;" width="480" height="302" align="middle" src="http://ustream.tv/embed/6540154?forced-quality=high&html5ui=1" scrolling="no" allowfullscreen webkitallowfullscreen frameborder="0" style="border: 0 none transparent;"></iframe>
</div>
<div id="roverStream" class="camera-stream panel-body">
<canvas id="cameraCanvas" width="320" height="240">
</canvas>
<canvas id="cameraCanvas" width="640" height="480"></canvas>
</div>
</div>
</div>
Expand Down