Custom Search

Thursday, September 24, 2009

Multi Touch Table

So! Everyone is moving towards multi touch with Windows 7 having support for multi touch and gestures. I've decided to build one as well.

Hardware setup
Generic setup: Cupboard, Projector (Epson EMP-400W), Projector mounting, Camera (Point Grey Firefly MV, Philips SPC900NC, PS3eye), Camera lens (M12 mount, HEO NIR Camera lens L58-844/L58-845)

FTIR setup: IR 850nm LEDs, LED Mounting, Resistors (47 ohms + 9 LEDs (1.24V) = 12V adapter) Clear Acrylic, Silicon Rubber , Tracing paper, Rosco Grey Rear projection screen, PET protective film.

LLP Setup: 10mW IR 850nm Laser line lens (3V adapter), Laser mounting, Rosco Grey rear projection screen, Acrylic/Glass.

DI Setup: IR 850nm LED lamp, Rosco Grey Rear projection Screen, Acrylic


Software Setup

CCV, Java, Quicktime, Camera drivers, Flash 9 CS3

Thursday, August 20, 2009

Need to optimize flash 9

I've been using flash 8 and 9 for some simple Multi touch drawing board application and realised that it is running too slow and requires a very fast computer to run it. Therefore, the need to optimize the code. I quick search on the internet led me to the following tips:

1) Declare local variables instead of global variables. (i had the impression that global variables just take up ram but will run faster during runtime. But i guess i'm wrong)
function doSomething() { var mx = 100 var my = 100 var ar = new Array()...}

2) Using OnEnterFrame, it is not recomended to attach too many event handlers all over the movie clip because this can lead to spaghetti code and also it can significantly degrade performance.
Most of the times using one single onEnterFrame can be a good solution: just one main loop that takes care of the various operations to carry on.

3) 25-35fps. The higher the fps the slower it will run the code.

4) Visibility. One of the best solutions to this problem is to have an empty frame in your movieclips where you can gotoAndStop(), freeing up some work to the flash player.
_visible = false; doesn't work.

5) for in loop instead of the usual for or while syntax.
for (var i in arr) {  if (arr[i] > 50)  {   // do some processing here  } } 
is faster than 
for (var i=0; i<10000;> 50)  {   // do some processing here  } } 
//------------------------------------------------------------------------
var i=-1 while (++i <>
is faster than 
for (var i=0; i<1000;>
//-----------------------------------------
6) _global vars is faster than Timeline vars. 
7) Multiple var declaration is faster than single
8) Var name lookup
t = getTimer() var floor = Math.floor var ceil  = Math.ceil for (var i=0; i < num =" floor(MAX)">
is better than 
for (var i=0; i < num =" Math.floor(MAX)">
9) Short var names is better than long variable names
10) Declaring var in loops (to the contrary) is faster than declaring before a loop.
11) using single if statements is faster than complex conditional expressions in a single if statement.
12) Nested loops, while loop is faster than for loops (eg for 2D data) 
13) TellTarget vs dot syntax. 
tellTarget(mc){
_x =10;
_y = 10
} 
is faster than mc._x = 10; mc._y = 10;
14) Loop listening for pressed keys
if(Key.isDown(Key.LEFT)) 
use 
keyDown = Key.isDown
if(keyDown){}
instead. 
15) use int() instead of Math.Floor()
16) Often performance is about perception.
If you attempt to perform too much work in a single frame, 
Flash doesn't have time to render the Stage, 
and the user perceives a slowdown. 
If you break up the amount of work being performed into smaller chunks, 
Flash can refresh the Stage at the prescribed frame rate, 
and there is no perceived slowdown.
16) loads more at this forum: 
http://board.flashkit.com/
http://flasm.sourceforge.net/
The Flashkit Board Optimization thread
Bit-101 Forum Optimizations Tips
OddHammer Tips

Monday, August 17, 2009

The paradigm shift

There is no more hope, its just a recurring nightmare like one of those where you keep running away from someone or something.

Monday, August 3, 2009

Generation Boom to Generation X

A generation gap between the Generation X and Y and their Baby Boomer parents is common around the world. Every country, every state, every village, has its own culture, set of rules and beliefs. In particular, why are people from the Generation X so miserable in Singapore? Everyone has something to complain about with it comes to family, marriage, bgr for the Generation X. Where most if not all should have started their own families, why is there a large number of divorced and single or unhappily married Gen X people out there?
New technology, political differences, workplace behavior, age of consent, age of responsibility, education system etc are blamed for the different and confusing generation gap from just one generation away. The boomers and the gen X. The Gen X is way past the age of MTV, WWE, Rock n Roll, and Retro. But the expectations of our other halves are worlds apart from those of our parents. Blame it on our education? our teachers? our British english with American TV? A pretty messed up society I would say. The age of Housewives and breadwinner's pride, to a neverending fight for equality in certain things in life, but in truth, the man has to suffer more, serve the woman, give in to her, open the door, who invented the gentleman? but it only exists in the era of slavery and monarchy. With the current democracy, the women's charter is obsolete unless there is an equal men's charter with women earning as much as men. Multi-tasking between a women's server, house-husband, a career-minded man, fillial son without compromising his own interests seems like mission impossible.
However, many still make it with the help of their understanding parents giving way, proper management of bosses, spouse and kids. But if any one of these factors were to be missing, the man's entire life would crash. Something will have to be given up, be it career, marriage, or family. but why is it that the women do not have this problem? They are traditionally not expected to stay with the family after marriage. So they have it easy. What happened to the rest of the traditions where the women have to serve the men? take care of the house and the family? In a company, different people fill different roles and never is there an accountant doing an engineer's job or a CEO taking minutes of a meeting. But even the CEO himself, is supposed to "take minutes" and open the car door for his gf and pay for the meals and movie (hold the popcorns too).
Watching the movie wildhogs, the man finally becomes the man when he silences his noisy wife who scolds him everyday and asks for her to "feel" him. Does it have to come to an ultimatum before the woman knows there's only this much a man can take and suffer before giving in? Or is it just these small group of unhappy people, single, divorced people, have this problem?

Tuesday, July 28, 2009

The irony of life

I found this quote very interesting and true, “The private assortment of images: fears, loves, regrets… for it’s the cruel irony of life that we are destined to hold the dark with the light, the good with the evil, success with disappointment… this is what separates us, what makes us human. And in the end, we must fight to hold on to.”
What happens when we stop fighting? will we lose everything? do we become a robot or an alien? or do we just end it all?
Why do we try to be a hero and save people who appear to need help but get ourselves hurt because these people exploit us. If we do not want to help them, they will not be able to exploit us, there will be no hate when we find out the truth nor will there be any unhappiness. But the questions comes when there are people who really need our help. What happens then?
Should we just let nature takes its course? The way God made us? the survival of the fittest? or do we lend a helping hand? and save these godforsaken people and the survival of the fittest becomes the survival of the people dependent on the fittest?
The burden hardest to bear becomes the question for the strong when the weak drains the strong, drag them down and slows their ascent. When is it time to let go? Will there be a sign? or do we fight for them and die trying?
It takes courage to let go, and to believe its time to move on. For one will never know, if it is the right choice since we will never know the future, and when we know the effect of our choices, there is only regret.

Tuesday, June 23, 2009

Is there a norm? Is there an ideal case?

Are we trying to be someone we are not? Are we all actors and actresses? Those who are not afraid to be themselves and do what they like and want are often condemned by the society. Why can't we eat bread in a fancy restuarant the way we eat cheese burgers? Am I the only one who is tired of all these rules? Or is everyone feeling the same way I do? I grow tired, I take a break, and I get up and fight again. What happens when people grow tired and just stop fighting?

Monday, June 22, 2009

Unable to register on selected network. Choose another network, or disconnect your data connection and try again

or Unable to read setting from network. Try viewing settings later, or dissconnect data connection and try again

I was in Johor Bahru and was surprised that my HTC Touch diamond was not able to connect to their local network. Despite changing to manual network settings, soft resetting my phone etc, I still couldn't get it to work.
After searching my phone settings for a long time, I finally found out that it is due to the HSPDA connection.
I had to turn off the HSPDA option under "settings" -> "Advanced Network"

Don't you just hate it when the error messages mislead you to other directions which doesn't solve the problem?