Last active
August 29, 2015 13:56
-
-
Save colegleason/9181646 to your computer and use it in GitHub Desktop.
[wearscript] vision for glass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html style="width:100%; height:100%; overflow:hidden"> | |
| <head> | |
| <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>--> | |
| <script src="https://api.picar.us/wearscriptdev/bower_components/msgpack-javascript/msgpack.js"></script> | |
| </head> | |
| <body style="width:100%; height:100%; overflow:hidden; margin:0"> | |
| <canvas id="canvas" width="640" height="360" | |
| style="display:block"></canvas> | |
| <script> | |
| function publish() { | |
| var data = msgpack.pack(Array.prototype.slice.call(arguments)); | |
| WS.publish(arguments[0], btoa(data.map(function (x) {return String.fromCharCode(x)}).join(''))); | |
| } | |
| function sendImage(imageData) { | |
| WS.log('sending image to server'); | |
| WS.say('sending image to server'); | |
| publish('image', imageData); | |
| } | |
| function server() { | |
| WS.log('Vision'); | |
| WS.say('Welcome to vision!'); | |
| WS.dataLog(false, true, .15); | |
| WS.cameraOn(10); | |
| WS.liveCardCreate(false, .2); | |
| WS.sound('SUCCESS') | |
| } | |
| function main() { | |
| if (WS.scriptVersion(1)) return; | |
| ctx = document.getElementById('canvas').getContext("2d"); | |
| WS.serverConnect('{{WSUrl}}', 'server'); | |
| } | |
| window.onload = main; | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import wearscript | |
| import argparse | |
| def callback(ws, **kwargs): | |
| def image(*data): | |
| print(data) | |
| ws.subscribe('image', image) | |
| while True: | |
| pass | |
| wearscript.parse(callback, argparse.ArgumentParser()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"name": "Vision for Glass"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment