Sunday, May 27, 2012

Content supply for Apple's venture into mapping

This suspense is killing me. Hope it will last. - Oscar Wilde

Apple put up a big fight against the Big Blue to establish itself in the market of personal computers. Now it has to put up a similar brave face to the big blue, red, yellow and green.


Apple acquires C3, now needs oblique and ground based photography to populate the world. While keeping bandwidth usage low and discretional. Apple will be requiring lots of data to populate its more detailed world and there will be rush of data acquisition coming up to create a multiple view representation of the static world.

The most interesting aspect of 3D reconstruction I find is the temporal decorrelation. We can never know all aspects of an object from multiple perspectives simultaneously without violating relativity. A fun aspect of this is the modelling of clock-towers. The reconstructed view always has slightly different times in the clock faces.

Causality is much more absolute than simultaneity, in our frame of reference we might be experiencing events such as the launch of Apple mapping platform whose cause is hidden in some future outcome. Meanwhile the suspense of seeing the big launch from the big fruit in a post-Jobs era is killing me.

Sunday, May 20, 2012

Portable Energy - from fire sticks to lithium

Last night there was a knock on my door at 3am, the flatmate wanted a flame to light his cigarette. We seem to have forgotten how to make fire without help. I have been reading Triumph of the nomads by Geoffrey Blainey. It has some interesting cultural facts regarding knowledge of energy generation.
Aboriginal fire sticks , the methods of fire making.
  1. Pulling stick over bark, fire plough or fire saw
  2. The bow-drill
  3. The percussion method with pyrites
From fire as source of energy and light we have moved on to more chemical mean, emphasizing on coal, potassium, phosphorus and sulphur. Energy currencies like adenosine tri-phosphate which our own cells prefer to use. I collected a lot of matchboxes while I was young and yesterday the TV was filled with imges of David Beckham and James Bond carrying the Olympic torch across the British Isle. We simply cannot afford to forget how fire is made or let all the fire in our immediate vicinity go out.

Then things switched over to fire steel - ferrocerium and butane, petroleum derivatives. It is still our highest energy density power source being used in most mobile power hungry equipment. Next came the more metallic solid state power sources, burning without visible flames, quietly without explosions unless overheated in certain laptops.


Battery technology has gone through several generations - lemon battery, copper-zinc, zinc-carbon, NiCad, NiMH, Fuel cells, Vanadium Pentoxide,  Silver oxide, Lithium and CSIRO made some headway into ultra-batteries by coupling super-capacitors to conventional chemical reaction systems. All involve chemistry and pushing ions up and down electrical staircases to store up energy around the nucleus. With our highly connected life-styles we are plagued by nomophobia, recharge mania. Sometimes I remember the sky is the ultimate device and carry around solar cells to transfer energy from the sky device.

We are constantly pushing electrons downhill in an effort to climb out of this gravity well of a planet we call home. Our techniques to harvest energy so far are not good enough to give us a ticket out without destroying a fair amount of our civilisation in the process. We will have to come up with something rather drastic to get out of this bind, pseudoscience or not.

Sunday, May 6, 2012

Producing Denser SiftGPU points - at the expense of time and RAM

One of the old adages I learnt doing CS was that you can not optimise everything - there is always a trade-off between speed and RAM (and sometimes accuracy). If you solve a problem faster then there will be a bigger problem that cannot be solved by your faster method. GPU computing seems to suffer from this scalability problem a fair bit mainly due to limited GPU Memory. In some cases there can also be issues with numerical stability. There is a fine line between Amdahl's law and Gustafson's law.

The latter is actually more fun since large problems have a patently real world feel. While playing around with large collection of aerial and terrestrial photography we found that SiftGPU seemed to be producing similar amount of key points no matter how big an image we threw at it and asked it operate at lower octaves to take advantage of the higher resolution. A bit of code inspection later I found the usual collection of magic numbers designed to prevent memory overflows ( if you have 60+GB RAM and some Teslas the magic numbers are too small). For posteriry here are the hard limits you can unsafely raise if your hardware can take a thrashing.

//hardware parameter,   automatically retrieved
int GlobalParam::        _texMaxDim = 12800;    //Maximum working size for SiftGPU, 3200 for packed
int    GlobalParam::        _texMaxDimGL = 16384;        //GPU texture limit
int GlobalParam::       _texMinDim = 16; //
int    GlobalParam::        _MemCapGPU = 0;
int GlobalParam::        _FitMemoryCap = 0;
int    GlobalParam::        _IsNvidia = 0;                //GPU vendor


The large aerial frames were defaulting to octave 3 silently, running them at octave 0 produced 500k SIFT features per frame (yes that is ridiculously huge, but these cameras are ridiculously good). With greater number of features you can perform sparse bundle adjustment using more restrictive angle range constraints and more accuracy.

Bundle adjusment has also had a recent boost from the release of Google Ceres library. This has been suitably adapted to allow faster solution of general multi-camera problems. Asteroids seem to be on everyone's mind.

    "... for it is now clearly shown that the orbit of a heavenly body may be determined quite nearly from good observations embracing only a few days; and this without any hypothetical assumption."
    - Carl Friedrich Gauss

Saturday, April 28, 2012

International Space Apps Challenge - backing NASA

Last week I had the chance to participate in the inaugural NASA Space apps challenge, modelled after the random hacks of kindness which we see taking place whenever there are large natural disasters(earthquake in Hawaii) or to address malignant global social issues such as inequality and poverty. It is amazing to see the drive people at such events have to work on something that does not directly impact their everyday life.

Space exploration is one such outside context problem. It seems frivolous on first sight till we study a bit of history. Our current global economy is based on the last 500 years of exploration (and should I say colonial exploitation). The rules of economics are framed such that they require constant expansion of resources - raw materials, energy and ideas. Being in a closed system on the planet poses inherent limits to the amount of expansion we can achieve, in a similar way industrial revolution was bound by the border of colonial powers in Europe - they were forced to explore new worlds. Since the Earth is nearly fully discovered now and everyone agrees on very limited amount of exploitation being the norm, to achieve the growth our mindsets demand we need to expand beyond Earth - ergo space exploration and asteroid mining. By participating the the space apps challenge, we are taking a very small step towards pushing the material and energy exploitation off planet and relieving the pressure put on our bio-sphere and humans in highly populated countries by blind greed.



Philosophy and sociology aside, we worked on a very broad problem for the challenge - developing a Semantic Data Descriptor for NASA data holdings. NASA has a lot of past, present and planned missions addressing the need for better observations of our planet, our neighbours in the solar system and things far far away in both space and time (unravelling the mystery of how the universe came to be as it is today). These missions collect something broadly termed as data, mostly observations. NASA being a fairly siloed organisation, has teams focusing on particular missions and developing their own description regarding the data they collect aimed at subject matter experts. Science in its own way can develop its own priesthood, bent on excluding the "laymen". The aim here was to develop a schema to make sense of NASA data in everyday vocabulary, we basically described all data as being an observation of a target by a sensor, measuring a field or a particle at a point in space-time. Writing that up in RDF required some help from Altova SematicWorks and the presentation some form Prezi. In the end we made it to the global rounds, hopefully our efforts will help the average human being establish their stake on space data if not space itself.

Wednesday, April 25, 2012

Building faster Bundler with CPU/GPU parallelism

The initial Bundler release caused quite a stir allowing simple bundle adjustment from random collection of photos. It leverages the sparse bundle adjustment - SBA created by Lourakis. However being totally single threaded it does not scale quite well to large images. Sift point finding can be accelerated using SiftGPU - Changchang seem to have moved to greater things at Google since his PhD and academic research days.

I have built bundler for Windows 64 bit + CUDA as the MCBA documentation suggests. A few flags are not supported as shown below.
    CHECK_PARAM_SUPPORT(explicit_camera_centers == false);
    CHECK_PARAM_SUPPORT(optimize_for_fisheye);
    CHECK_PARAM_SUPPORT(use_constraints);
    CHECK_PARAM_SUPPORT(use_point_constraints);
    CHECK_PARAM_SUPPORT(fix_points);



I am calling it PBA_Bundler, please give it a try and let me know if it makes bundle adjustments faster for you. The GPU has higher error rates on floating-point calculations and can lead to large bundles drifting off reality. Even computers can have optical illusions. CPU parallel version has less error rate and yields more stable bundles. I am currently working on adding pthreads based parallelism to match filtering stages of Bundler (computing Epipolar Geometry and establishing bundle bounds) and removing the constraint in multi-core bundler which prevents the use of camera constraints.

Sunday, April 15, 2012

Things we do for money - beg, borrow and steal

When I was a child we used to catch the train every morning from Bali station to Howrah, you have to travel long ways at times to go to a good school in India. At the station there usually was a strange man sitting beside a very large pile of hay, gobbling it up. Hay is relatively cheap, but I am sure it is very hard to digest without 4 stomachs and a coterie of symbiotic bacteria. Yet day after day this man sat and ate hay, people were suitably amazed and gave him money to buy more hay. The same applies to performers of any kind, once our stomachs are full of suitably nutritious food (not hay), our minds seek fulfillment as well. We want to be amazed by something extraordinary, stay in touch with people we care about, gloat about the misfortunes of those we hate or envy. The brain feeds on these emotions and burns up the glucose we have consumed.

Fiat currencies have the great blessing of being pure invention, the state says let it be so and money exists - fiat lux. Since the Nixon Shock, currencies are disconnected from materials but attached to emotions and ideas. The society is a very large Markov network, with beliefs about value propagating through every conversation. True value or even truth itself is merely the best presented propaganda. The chinese are no stranger to the vagaries of economy having established the first known instance of paper money, and messed it up through hyperinflation and lack of sovereign discipline.

Content producers directly communicate with our minds through our senses and artists hold the strings to our happiness in their hands. We dance like grand marionettes to the messages being relayed through bands, movies, TV, radio, facebook, churches and Harry Potter novels. We spend money, a product of human ingenuity, on other products of human ingenuity. Last night I attended a small get together, Fee an artist and a friend is garnering support to travel around Australia generating content regarding digital culture. She is being shy about begging for money, but we had to point out to her that she is only begging for it from people who begged, borrowed or stole it in the first place. It is not even begging, it is only borrowing so that she can produce content which will engage people and keep them happy for years to come. We can have better stuff than "Hay" content.

If we, citizens, do not support our artists, then we sacrifice our imagination on the altar of crude reality and we end up believing in nothing and having worthless dreams.  - Yann Martel

Saturday, April 7, 2012

Spontaneous Symmetry breaking and Alan Turing

An embryo in its spherical blastula stage has spherical symmetry, or if there are any deviations from perfect symmetry they cannot be regarded as of any particular importance ... But a system which has spherical symmetry, and whose state is changing because of chemical reactions and diffusion, will remain spherically symmetrical for ever ... it certainly cannot result in an organism such as a horse, which is not spherically symmetrical.
- The Chemical basis for Morphogenesis, Alan Turing.
Resin deposit and butterflies
Spontaneous symmetry breaking is also quite common in Physics. The origins of a lof of forces and particles can be accounted for by asymmetric systems being more stable as whole than a completely symmetric system.

This has a very simple statistical explanation, a perfectly symmetrical state is a very rare occurence compared to the total possibility space of random occurences. Hence the system rapidly deviates from this state. Symmetry is not impossible, but highly improbable. This however does not prevent the consituent elements in the larger system from being highly symmetric, in fact the symmetry is desirable to allow mobility of the constituent to a lower energy more stable state if one becomes available.
Asymmetry is also the basis of the modern economic system globally. There is distinct patchiness in the the distribution of resources on the earth's surface and the reaction-diffusion mechanisms operate by transport of currency or materials (raw or processed) from one part of the earth to another. As the speed of the transport increases the patterning of wealth distribution oscillates. Online transactions have made currency transport nearly instantenous, materials transport still depends on cargo ships and aircraft, but is much much faster today compared to what it was 100 years ago. The wealth spots on the surface of earth are changing faster than the trade winds are blowing, yet they can set up stationary waves where in-spite of the movements the distribution does not shift.

We are all eating off the plate the earth has handed us. In a system with constant energy input, such as the earth receiving energy from the sun and its core via mass-energy conversion, thermodynamic truths such as the total entropy of the system not decreasing do not hold. As we become more proficient with the laws of the universe, we will build more and more symmetric systems/organisms without making a dent on the net asymmetry.