NABARUN SENGUPTA
Published © GPL3+

Runu - Giving Vision to Technology

Project Runu is a way to make technology understand visual input leveraging it in areas like visually impaired, security cameras etc.

IntermediateWork in progress1 hour859
Runu - Giving Vision to Technology

Things used in this project

Hardware components

Tessel 2 (main module)
Tessel 2 (main module)
Tessel2 is the micro-controller used for this project. It acts as a file system and web server for this project
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
This will come with Tessel module
×1
Creative Live cam
Creative Live! Can Sync hd as it is having good compatibility with Tessel2 usb support
×1

Software apps and online services

Microsoft Cognitive API

Story

Read more

Code

Runu - Source code

JavaScript
This capture the node.js script which is mentioned in the description
var fs = require('fs');

var av = require('tessel-av');

var os = require('os');

var http = require('http');

var port = 8082;



var camera = new av.Camera();



//Create a http server and capture the image from tessel

//supported usb camera



http.createServer((request, response) => {

  response.writeHead(200, { 'Content-Type': 'image/jpg' });



  var capture = camera.capture();

  capture.pipe(response);

  capture.on('data',function(data){

        saveimage(data);

        analyzeimage();

  });



}).listen(port, () => console.log(`http://${os.hostname()}.local:${port}`));


//Analyze the image using Microsoft cognitive api

function analyzeimage(){

        fs.readFile(__dirname+'/captured-image.jpg',function(err,data){

        if(err)

                console.log(err);

        else{



                parseURL = require('url');

                parsedURL = parseURL.parse("https://api.projectoxford.ai/vision/v1.0/analyze?visualFeatures=Description");



                console.log(parsedURL.host);



                var options = {

                        host: parsedURL.host,

                        path: "/vision/v1.0/analyze?visualFeatures=Description,Tags",

                        headers: {

                                'Content-Type':'application/octet-stream',

                                'Content-Length':data.length,

                                'Ocp-Apim-Subscription-Key':'<<Microsoft cognitive api key>>'

                        },



                        method:'POST',



                        };



                callback = function(response){

                        var str ='';

                        response.on('data', function(chunk){

                                str+= chunk;

                        });



                        response.on('end', function(){

                                var obj = JSON.parse(str);

                                console.log("I think the caption of this object should be " + obj.description.captions[0].text+". I am "+obj.description.captions[0].confidence+"sure.");

                        });

                }



                var post_req = http.request(options, callback);

                post_req.write(data);

                post_req.end();

        }

    });

}

Credits

NABARUN SENGUPTA

NABARUN SENGUPTA

1 project • 2 followers
I am a Node.js enthusiast currently involved in projects involving Microsoft cognitive and google vision api.

Comments

Add projectSign up / Login