Sending strings from Arduino to Openframeworks

Recently worked on a project where I had to receive strings from Arduino to Openframeworks. Its not really that straight forward like processing so thought of sharing the code..


ofSerial mySerial;


setup() {

mySerial.setup(0, 9600); // update port no and baud rate according to your system.



// trim trailing spaces

string ofxTrimStringRight(string str) {

    size_t endpos = str.find_last_not_of(” \t\r\n”);

    return (string::npos != endpos) ? str.substr( 0, endpos+1) : str;



// trim trailing spaces

string ofxTrimStringLeft(string str) {

    size_t startpos = str.find_first_not_of(” \t\r\n”);

    return (string::npos != startpos) ? str.substr(startpos) : str;



string ofxTrimString(string str) {

    return ofxTrimStringLeft(ofxTrimStringRight(str));;


string ofxGetSerialString(ofSerial &serial, char until) {

    static string str;

    stringstream ss;

    char ch;

    int ttl=1000;

    while ((ch=serial.readByte())>0 && ttl–>0 && ch!=until) {

        ss << ch;



    if (ch==until) {

        string tmp=str;


        return ofxTrimString(tmp);

    } else {

        return “”;




update() {

    // Receive String from Arduino

    string str;

    do {

        str = ofxGetSerialString(mySerial,’\n’); //read until end of line

        if (str==””) continue;


        for(int i = 0; i < str.length(); i++) {





    } while (str!=””);


Tagged , , ,

Turing pattern

Recently was fasinated by the aesthetics of turing patterns. Wanted to tinker a little bit with the algorithm and values to see the outcomes. Started exploring and reading codes by Kyle McDonald, Jonathan McCabe and Martin Schneider. Here are some of my explorations.




Tagged ,

Face Tracking / Expression Recognition

From the age of Face Detection, we have come to an age where Face Tracking is feasible without a professional setup. All you need is a decent machine with a Kinect. If you have tried / tinkered with ofxFaceTracker, faceAPI or FaceDetect, I am sure you will love this. FaceShift can now be downloaded from their website. Kyle has developed a ofxaddon ofxfaceshift.

My observations: The tracking is very accurate and was impressed with the way it tracks the blinks and eye ball movements. Frame rate is good and the tracking does not have any gittering.

All this said, it comes with lot of limitations. Most of them comes with kinect. Like the minimum distance where the user has to stand / sit. Lighting conditions etc. and you have to train the software with few poses for good tracking results. So still its far from usage in realtime setups. But as  of now can be used for animation, expression tracking etc.

Tagged , , , , , ,

Gesture based Bubble game in Flash AS3

I started using computer vision libraries in Processing and then shifted to openframeworks. But have not done anything in web for quite sometime. So thought of trying out some cool stuff in flash. I had very low impression on flash when it comes to computer vision stuff. But looks like even though its slow, its very easy to code in as3.

I built my first gestural bubble game. I dont have to explain the game for those who are familiar with opencv example of processing. But for others, ya this game is all about hitting the bubbles using your hands / fingers / head / anything in your hand :-)

You can play for yourself by clicking here.

Note: Obviously you need a webcam to play this game.

Yawn Detector

I was a great fan of Apesnake Manwolf project at Fabrica. Thanks to Che-Wei Wang and David Peñuela for inspiring me. The moment I returned home, I couldn resist myself from trying FaceOSC. Its soo cool to play with our face gestures. I spent nearly an hour trying out all possible weird gestures ;-) Then landed up doing an app which will detect when you YAWN. I was imagining a scenario where this app can run in stealth mode in corporates and keep a count of how many times a particular employer yawns. Actually that can generate a good yawn report for the managers :-) Anyways here I am detecting when the user yawns and I am playing an audio which says “Stop yawning and get back to work!” and also displays a text “Stop Yawning!”.

Note: I myself yawned once genuinely when I was writing this post and this girls voice “Stop yawning and get back to work!” was soooooo irritating… then I smiled and said to myself “This app works.”

Tagged , , ,


Tried playing around with openCV blobs and created a palette. This is my first project in openframeworks. I had this idea for the benetton’s window project while I was in fabrica but did not implement it then. As the logic is simple, thought of trying it in openframworks.

Basically it detects the consumers (users) walking by the window and generates a palette with predefined colors. The idea is to have the color pallete of the collection in the showroom. I still want to make the appearance of each bar little smooth.

Tagged , , ,

Exploring LaserTag

Exploring Theodore Watson and Zachary Lieberman’s LaserTag. Was nice to learn from their opensource code.

This slideshow requires JavaScript.

Design Documentation Video

Got an opportunity to give a presentation on “How to make design documentation videos?” for the New Media Design students of 2010 batch from National Institute of Design, Gandhinagar. After realizing the most common problems encountered by design students when they start making a documentation video, I made a series of video tutorials which might help them and other design students as well.

The video tutorial playlist can be found here.


Prototype of an ongoing project Engrave. More to come very soon..

Thanks to Suvani Suri for helping me to document this and also Manasi for her amazing tripod.

Tagged , , , ,

Play Pong using Mouse, Keyboard, Webcam, Wii, iPhone and Kinect

This is a part of another project where we were interested in comparing different modes of interface for the game of Pong. The game is built in such a way that the user can choose either Mouse / Keyboard / Wii / iPhone / Webcam (color tracking) / Microsoft Kinect to play the game. This video shows the game being played using kinect.

Thanks to Suvani Suri for helping me to document this and also Manasi for her amazing tripod.

Tagged , , , , , , , ,

Get every new post delivered to your Inbox.