Add code for video connecting and capturing, as well as some swarm issues.
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
//var msgpack = require("msgpack-lite");
|
||||
|
||||
// Assuming paho mqtt library is included.
|
||||
host = "172.16.13.128";
|
||||
host = "172.16.13.130";
|
||||
client = new Paho.MQTT.Client(host, port=1884, "2343");
|
||||
|
||||
client.onMessageArrived = onMessage;
|
||||
client.onConnectionLost = onConnectionLost;
|
||||
client.connect({onSuccess: onConnect});
|
||||
|
||||
function connectToSwarmn(){
|
||||
// Only connect when person is ready.
|
||||
client.connect({onSuccess: onConnect});
|
||||
}
|
||||
|
||||
function onConnect(){
|
||||
alert("Client Connected");
|
||||
@@ -26,10 +30,58 @@ function onConnectionLost(responseObject){
|
||||
}
|
||||
|
||||
function onMessage(message){
|
||||
alert("message received");
|
||||
// Working.
|
||||
messageb = message.payloadBytes;
|
||||
|
||||
if(message.payloadBytes = 1){
|
||||
// Sent checking ready command.
|
||||
|
||||
var messageD = msgpack.decode(message.payloadBytes)
|
||||
console.log(messageD)
|
||||
if(messageD["type"] == "reqvote"){
|
||||
console.log("Received vote message");
|
||||
submit_vote();
|
||||
}
|
||||
}
|
||||
|
||||
function send_connect(){
|
||||
var buffer = msgpack.encode({"type":"connect", "sender":client.clientId, "data":{}});
|
||||
message = new Paho.MQTT.Message(buffer);
|
||||
message.destinationName = "Demo";
|
||||
|
||||
client.publish(message);
|
||||
}
|
||||
|
||||
function submit_vote(){
|
||||
// Capture the image.
|
||||
// Perform recognition on the image.
|
||||
// Send vote back to commander.
|
||||
}
|
||||
|
||||
function capture_image(){
|
||||
|
||||
}
|
||||
|
||||
(function(){
|
||||
var height=320;
|
||||
var width=0;
|
||||
var streaming=false;
|
||||
|
||||
var video = null;
|
||||
var canvas = null;
|
||||
var photo = null;
|
||||
var startbutton = null;
|
||||
|
||||
function startUp(){
|
||||
video = document.getElementById('video');
|
||||
canvas = document.getElementById('canvas');
|
||||
photo = document.getElementById('photo');
|
||||
startbutton = document.getElementById('startbutton');
|
||||
|
||||
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
|
||||
.then(function(stream) {
|
||||
video.srcObject = stream;
|
||||
video.play();
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log("An error occurred! " + err);
|
||||
});
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user