Titanium Image Filter Module

Titanium Image Filter Module, tiimagefilters, is a skeleton Titanium Mobile project that is able to perform image filtering after you taken a photo from your iPhone device.

It contains the native Objective-C code that perform algorithms for image filtering, and then provided the Titanium JS bridge proxy made it able to be invoked from JavaScript.

Check out its source code from Github: https://github.com/tzmartin/tiimagefilters

brain.js on Titanium Mobile

brain.js is a Node JS module library serves neural network. It is normally used for pattern recognition, machine learning, forecasting and business intelligence.

Titanium mobile is a native mobile development platform using JavaScript.

Titanium mobile allows to include modules that conform to CommonJS Specification. Therefore, I just wonder if it is possible Titanium mobile run a neural network by including brain.js which is a Node JS module. And then, I managed to include it and have made some test training inputs and get the test outputs.

The exciting part is the training data sets can be shared among server (Node JS server side), and client (Titanium mobile, with iOS, Android), because they both use same CommonJS module brain.js.

Short Notes about including brain.js on Titanium mobile:

1) you use require to include the brain.js module by must provide full absolute path to the main entry js, for example: require('/path/to/module'), with corresponds to /path/to/module.js. you should change all the require portion among all the library codes to use absolute path instead of relative path.

2) try to separate out the callback function after exports.xxx.
For example, exports.xxx = function() {}; doesn’t work, you should write this as:

var callback = function() {};
exports.xxx = callback;

3) sample code to use brain.js:


var brain = require("/path/to/your/brain");

var trainInputs = [];

trainInputs.push({input: [1,0,1,1,1,1,1,0,1], output: [0.08]});
trainInputs.push({input: [1,1,1,0,1,0,1,1,1], output: [0.09]});
trainInputs.push({input: [1,1,1,0,1,0,1,1,0], output: [0.1 ]});
trainInputs.push({input: [1,0,1,1,1,0,1,0,1], output: [0.11]});
trainInputs.push({input: [1,0,0,1,0,0,1,1,1], output: [0.12]});
trainInputs.push({input: [1,0,1,1,1,1,1,0,1], output: [0.13]});
trainInputs.push({input: [1,0,1,1,1,1,1,0,1], output: [0.14]});
trainInputs.push({input: [1,1,1,1,0,1,1,1,1], output: [0.15]});
trainInputs.push({input: [1,1,1,1,1,1,1,0,0], output: [0.16]});

var net = new brain.NeuralNetwork();
net.train(trainInputs);
var input = [1,0,1,1,1,1,1,0,1];
var output = net.run(input);

As you can see the training data sets trainInputs is a JavaScript Array and it can be easily shared to Node JS server side using JSON-serialized format and in Node JS server side you can do the same code which Titanium mobile used also to manipulate the training data sets.

Node.JS playground 20111211

This weekend I played around with Node.JS, all around JavaScript. Here some notes.

I sign up for Tropo and set up some sample code to play with the telephony related stuff. It is free to test when in developing mode until your apps run into production mode then need to pay.

I simply played say.js, it is a text-to-speech engine in Node.JS, supports Mac OS X and Linux. It used Mac built-in text to speech engine while in Linux it requires Festival to be installed.

Another great library brain.js, it is able to build neural networks on Node.JS and client browser, purely written in JavaScript. Neural network is an Artificial Intelligence technique that mostly used in forecasting and prediction field.

Another library cron.js, it is able to schedule recurring jobs in Node.JS. It used Unix’s Cron liked expression to trigger the job.

Both of them just provide easier to use API that easily integrated into any enterprise application.

Node.JS is a relatively new programming language but its community grows extremely fast. There are many exciting libraries built into Node.JS. It may still not yet suitable for enterprise application but some of the organizations had tried to use it in production, for example, Linked In used Node.JS to build its entire mobile site platform.

socket.io Library for Titanium Mobile

Found a socket.io Library for Titanium Mobile.

https://github.com/nowelium/socket.io-titanium

socket.io Library is originally included in Node.JS, and someone brilliant migrated into Titanium Mobile.

And, currently there is no nowJS implementation for Titanium Mobile. But I investigated nowJS source code it used socket.io, and *maybe* it is possible to migrate into Titanium mobile as well. However, this is not impossible, because Kosso had made it, but just didn’t open source yet.

Showcase on Real time video sharing built on nowJS

I am learning nowJS, a framework to build real time application built on Node.JS, and had made a simple web application that is able to share screen to the other clients in real time. This apps includes client side and server side is 100% completely written in JavaScript.

I had recorded a video and exported into HTML5 Webkit compatible video clip, and included into web page using HTML5 <video> tags. And then, the screens will be copied into HTML5 <canvas>. After that, the magic comes, the screen in HTML5 <canvas> will be real time broadcasted to the other client browsers (tested on Google Chrome, Apple Safari, and Apple Safari Browser runs on iPhone, or webkit browser). I had applied some algorithms to manipulate the video as well. The canvas also allows simple line drawing. At the end, the results of the canvas will broadcast to the other client browsers in real time.

Attached is the showcase video:

 

Fork me on Github: https://github.com/fyhao/Real-time-video-sharing-built-on-nowJS-and-Node.JS