Tuesday, December 18, 2012

On map Augmented Reality with Vuforia + Unity

I have been doing some more development with Android, using a different (and easier) renderer this time than the still nascent OpenSceneGraph port, with a bit of Augmented Reality thrown in via Vuforia.Which basically functions as an OpenCV port with image orientation recognition thrown in optimized for Qualcomm's Snapdragon SoC. The feature detection and texture packing is annoyingly performed at the Qualcomm site, I guess they want to keep track of images over which features are detected and prevent inappropriate use by script kiddies. From the looks of FastCV, the features are either MSER or Harris corners.
I already have Android dev kits going so the fun bit was in importing our nice models into Unity and sending the package over to the device. Textured models seem to import best into Unity via Blender, after a bit of copying around of textures and forcing association with the right materials.
Setting up the scene in Unity is fairly straight forward, the Vuforia SDK delegated to Unity for rendering and simply attaches a handler to the Camera. The visible object is automatically centred in the scene so the camera to target geometry is irrelevant in this case. However lighting is not, so a bit of tweaking in lights is necessary for a nice model render. Switch all the materials to diffuse/mobile to load the appropriate shaders in GLES2. Add an LODGroup node if the model is getting too big, though I was able to render some 100,000 triangle models.
When all is set the tracking can begin. I lined up the model to our orthoimagery, the screenshot does not do it justice. It is really cool watching a 3D object stick out of your screen. Everybody at work is very used to viewing things in stereo, but multi-perspective 3D still has a wow-factor.

Tuesday, December 4, 2012

Building OpenSceneGraph with Android NDK

I have been rapidly picking up Android development for the last 2 days with Native coding in C++ thrown in. Cross compiling for embedded systems is nothing new for me having played with Beagleboards in various incarnations, the Hawkboard and Pandaboard. Neither is JNI, I did a fair bit of JNI work while at CSIRO trying to make NetCDF faster.

So to build OpenSceneGraph for Android (I am using my Nexus S running 4.2), do the obvious:
  • Get OSG source
  • Get ADK
  • Get NDK
  • Get ADT if you are Eclipse fan like me
  • Get Sequoyah, CDT and whatever else Eclipse wants to build native code.
Build OSG for Android with whatever hack you can imagine. I ended up getting CMake to generate with NMake build files, but built directly using ndk_build afterwards since the MSYS shell could not access DOS commands ndk-build seems to call. Install automation did not work either so I copied OSG headers over by hand into the build directory. It took a while to build, the NDK compilers are rather slow, in the future I will run with -j 12 to take advantage of all my cores.

The next bit was rather easy since the OSG Android sample is already configured for Eclipse. I had to fix up settings with MSYS for bash. Most tutorials refer to cygwin for Linuxy utilities, but I loathe cygwin and I already a have a bunch of MSYS installs floating around through OSGeo4W and Git-bash. The include files and compiler checks are rather strict in Eclipse and any errors in the IDE will prevent uploading the build, be naughty and just delete the errors due to ADT bugs. This is just a proof of concept after all. I had to change a few little things like false to JNI_FALSE to keep the compiler happy. After some toing and froing with gnustl_static, the whole thing built and ran fine.



I wanted to have jpeg textures embedded in the .ive and .osgb files displayed as well as load models with PagedLOD's over http. So I needed to link the little trivial application to curl and jpeg in their Android native incarnations. The hard work has been done already and you can get thirdparty bundles. The first attempt with 8192x8192 textures expectly blew up on the little platform, but atleast libjpeg seemed to be working, I squished textures down to something sane. Libcurl works to download a file hosted on our webserver just fine, but you can't wait for an eternity on this plaform, unless the basefile is a few kb and links to the rest via LOD's the GL context will be lost before the download finishes. Overall it was a fun experiment and I am glad i managed to load a Jesus statue to celebrate this festive season - though it represents death rather than birth.

Thursday, November 8, 2012

Blender as a Python module, happy coding from Eclipse

This post is going to be a reminder to self in-case I ever need to do this again, or I am cloned and the clone is wondering how the original spent his time.

Get Blender source
Set options as pointed by IdeasMan to build as Python module
Compile with Visual Studio
Set BLENDER_SYSTEM_SCRIPTS as an environment variable, small undocumented caveat where reading the source actually helps.


Import Bpy and Python 3.2 in Eclipse and use Blender algorithms in headless mode.

Tuesday, October 30, 2012

Trivial CMAKE for OpenSceneGraph

It is often fun to get open source projects working with Visual Studio since a lot of build systems leave out a few Microsoft specific vagaries. With CMAKE life in the last few years has become much easier, though sometimes it requires a bit of digging to locate the right incantations to pull in the right dependencies for a trivial project.

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(AeroViewer)

SET(TARGET_SRC aeroviewer.cpp )

find_package(OpenSceneGraph REQUIRED osgDB osgUtil osgGA osgViewer osgText)

ADD_EXECUTABLE(aeroviewer ${TARGET_SRC})

INCLUDE_DIRECTORIES(${OPENSCENEGRAPH_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(aeroviewer ${OPENSCENEGRAPH_LIBRARIES})  


The aim of this quick dash is to add a screen overlay with the company logo to the default osgViewer. This requires adding a geometry node to the scene with some static geometry in camera space. Which ends up being equivalent to a HUD in osg parlance. After a bit of tweaking and rotations in texture space I got this, not too bad for a cold-start in OSG land. This bit of sample code is better for HUD's than the tutorial, the required projection and modelview matrices are encapsulated by the CameraNode.

Saturday, October 20, 2012

Why is gold valuable anyway ? - Midas and Supernovas

Growing up as a child in India in a family of goldsmiths it is hard to ignore the role gold plays in perception of wealth and daily conversation. My uncle would often refer to "stuff" or "maal", meaning gold. On my last visit the regular obsession was checking the current gold price from the wholesalers via SMS. According to a recent article - Man's addiction to gold - India holds pretty large stockpiles of the metal in the proverbial family jewels. It changes hand at marriages as gifts and dowry.

Midas as an allegory of a supernova Gold has no intrinsic bio-chemical value which supports life as the cautionary tale of King Midas points our. Its inherent inertness however gives it great value in the burgeoning electronics industry and it is very rare to start with anyway due to the cosmic element forming processes making it harder and harder to produce heavier elements. The vagaries of nucleosynthesis are so universal that they have even made it to being a Hollywood plot device in "Cowboys and Aliens" where aliens set up a gold mine.

The ultimate statement on how we value things comes down to supply and demand - gold is in short supply due to its nuclear weight and on high demand due to its permanence once acquired. We now just need to find suitable biochemistries or bioelectronics to make it part of a living body. Gold abundance is a measure of the midas touch of supernovas.

Wednesday, October 17, 2012

Making Furniture from Banana

I had a solid grounding in natural fibers and polymer chemistry thanks to my father. My mum still has a picture of him happily holding a sisal leaf. We took this picture in the plantations just outside Mombasa. Well the agave family is pretty notorious, apart from sisal it also gives us pineapples and tequila.
So I tend to talk about the wonders of polymer chemistry often. I kept rambling at the Augustiner Biergarten in Munich about natural fibers, hair and aramids, to slightly disbelieving stares. Ended up learning a bit about making violins out of Kevlar.

The whole chain of thought started on the plane from Adelaide to Kualalumpur. I sat next to Ed organising the overseas operations in Egypt for Papyrus inc and making veneer out of banana stems. He treated me to a nice time in KL on condition that I show the same consideration to any travelling PhD student I meet in the future, when I am a director or something. Otherwise it was a great conference featuring a visit to the EADS solar panel and rocket engine manufacturing facility - which used to serve as the tank manufacturing facility at its inception. As well as plenty of nice technical sessions and a strange conversation regarding compressed sensing and the difference between SAR and optical.

I finally did the IGARSS Conference review survey today, so getting the blog out is timely. May be I will present about point clouds at the next conference and take a break from the SAR stuff. Check this video for what I have been doing recently.


Saturday, August 18, 2012

The sunset cermony at Arche de Triomphe

There are many battles listed on the Arche de Triomphe, they were all fought, but not all of them ended in victory. We walked through Paris starting at Place de La Madeleine filled with red blooms and people sitting on the steps. Thinking this is Paris where building a church is considered a public service, useful in keeping people sane and full of hope. We walked a beeline to the obelisk and lined ourselves up with the Arche de Triomphe along Avenue des Champs-√Člys√©es.

We slowly waded into the ocean of tourists, passed a man cutting out silouhettes in 2 minutes using just scissors, got pigeon poop on my bag, saw the citroen demo car with solar panels on the roof and had a burger at Q being served by a very tall girl. We got lost crossing the roundabout to get to the arch and went round in a cricle before we figured out the right underground tunnel to take. As usual there was a huge queue to climb the Arche, I am not really into queues so we went and sat under the arch. All these random events led us to sit next to a very small old lady (we later found out that she was 92), carrying a large flag.

I started doing my usual sketching thing, the old lady was a subject you just can't pass by. Some tourists noticed us and introduced us to the old lady. She spoke excellent English and had served with the Free French Forces under Charles de Gaulle during WWII, in intelligence. We came around to discussing the olympics and to our surprise she started reciting the venues of all the olympics since the 40's. I did some quick sketches of her and dutifully handed them over, she asked us to stay for the sunset ceremony alongside all the dignitaries in suits.

It was a rather odd half an hour as we struggled to be inconspicuous among all the military attire and the ambassadors. The tourists were all herded out and looked on from the outside. All the national anthems of allied countries were played - France, UK, Australia and some I did not recognize. Wreaths were laid on the memorial to the fallen soldiers. The logo on my t-shirt was mistaken for a regimental emblem and I was asked which one I belonged to. It was a rather strange end to our random walk through Paris. Thanks for letting us stay Paulette.

Tuesday, July 17, 2012

Redrawing Diagrams - Fun with Inkscape

Hand drawn curves
Good diagrams in publications are hard to come by and sometimes already published ones get re-used exactly due to the lack of the know-how on reproducing them. One classic example is the Entropy-Alpha space diagram produced by Cloud-Pottier. Though the diagram is simple enough and the space limit curves can be computed from the equations, it is sufficiently complex given no full recipe to warrant copying as-is. Copying with attribution is standard practice in science, but gives no insight into how the diagram was originally produced without contact with the authors or forensic analysis of the lines. The tell-tale randomness of the curves in this particular one makes me of the opinion that it was hand drawn, I will have to as Shane Cloude when I meet him over a beer in Munich.
Entropy/Alpha diagram



So I decided to try out my Inkscape skills and redraw the diagram from scratch using some theory and some free-hand approximations. Without definitive parametric equations for the bounding curves it is rather like trying to work out how the pyramids at Giza were built.

Friday, July 13, 2012

Lots of images to lots of OBJ to lots of images

Working with Structure from Motion and Dense matching can be a lot of fun. If the project get sufficiently big though, the reconstructed models is broken up into multiple Wavefrom Object files and can be difficult visualise and render. I like doing most of my rendering in Blender, and the handy Python API for loading OBJ files makes the job of getting all the files in easy.

To grab a bunch of obj files from a folder into Blender simply script this in the console:

import glob
objects = glob.glob("Filepath\*.obj")
for obj in objects:
    try:
        bpy.ops.import_scene.obj(filepath=obj, axis_forward='X', axis_up='Z')
    except:
        print("Failed "+obj)

Just like that you create a scene with 100's of object tiles. Make sure they are viewed in outline mode, so that the display is zippy while setting up lights, cameras and animation action. Start off the render and go get a beverage.


Friday, July 6, 2012

Rage against the machine - Pattern Matching

One of the major strengths (and sometimes weakness) of the human brain is its ability to perform pattern matching - the classic is where people play more attention while playing games and digitising and gamifying the airport security leads to less false positives. We perform heuristics in everything we see and hear, often coming to conclusions based on partial information, based on extrapolation performed using past experience. This is why upper-case letters in English are so much easier to read since we have built up heuristics to infer the letter from the top-half, people who write in all capitals seem to be almost shouting as our visual heuristics take the cue.

Ambiguous painting
Machines are getting better at the heuristics as well as brute force, we have passed them on just the way we pass on preconceptions of right and wrong, beauty and religion to our children. Based on this system of thought and accumulated body of knowledge, machines can perform pattern matching tasks they are programmed for in vastly superior ways than humans. All they demand in return is energy, materials to build them and intelligent human beings to make some long intellectual marches in programming them.
Cat videos are the dominant species
In someways the rote jobs of pure pattern matching has made us mental Neanderthals with short neural loops focused on ambush hunting only the job at hand, rather than thinking long term strategy. The long chase where all the short easy pattern matching jobs have been mechanised is for the more creative, the artists. Yet there is still need for the engineer to keep the machines functioning. There are always predictions of race of against the machines. We still need to communicate our mental models imperfectly via whatever means.
Genies are just machines with Genius

May be with exposure to lots of cat videos and artwork, the machine will eventually learn to play with cats while painting, and we will keep building bigger machines since we can't be born biologically with bigger skulls or weild GeV's with our finger tips.

Friday, June 22, 2012

Searching point clouds - Hashes vs Trees

About a year ago I was sitting in the lawn outside of the Google buildings in Mountain View, discussing the project I was working on at the time. I had the fun job of displaying very large (60GB +) NetCDF data sets in NASA WorldWind. We were approaching it from the classic game developer perspective and considering building an octree or hyper-octree (this data had temporal slices) index over the dataset to quickly locate subsections we wanted to display at the proper detail. As an aside we began to consider what the limits of the disk to screen transmission are. A 1920x1200 screen with RGB data will have about 6.6 MB of data uncompressed, with compression this will come down a bit. At 60 FPS this requires about 3 Gbit/s disk bandwidth, compare this to what is available via SATA 3. SATA 2 will definitely be too slow adding the times required to search the index, perform seeks and read the pre-computed chunk. It might look better with highly redundant data and good compression.

The idea here comes down to searching using 2 different methods - Hash Search vs Binary Search. Octree based rendering is essentially a binary search in 3 dimensions. The other way to render would be to hash the camera position and orientations or view frustrums, create indexes and blocks of the point cloud being rendered to load chunks as the camera is moved around and data block required is located on the disk using the index + hash. The gamers keep harping on about polygon counts without looking at how the facade of the very large word-count of the internet can be quickly acessed via hashing the query, similarly the first surface of a large object count scene can be quickly accessed via hashing the camera.

All this brings me to the point of the conversation. In the last few days a bit of a drama played out in the hard-core gamer community regarding a leak from Euclideon, who make engines not websites. Hash based searching will work quite well for static data and unlike trees will not require rebalancing for dynamic data. Finding a nice unique hash for frustrums can get quite tricky and storing and compressing the results in a nice data format will also be a challenge. Building a game engine from scratch without all the blocks the graphics world has put in place is a Radical Rewrite. May be it will work, then again we live in a universe where there are 4 dimensions and no one asks how to compute the volume of a hyper-sphere. Knowing e=mc^2 does not let you build an atom bomb or a nuclear reactor, even figure out how to avoid Fukushima. Engineering simply is not the same as Mathematics.

Saturday, June 16, 2012

Power of appearances - Peacocks and Pandas

Somebody once told me the only survival adaptations pandas have evolved is their cuteness. They eat hard to digest, scarce low nutrient food, move and breed slowly and are distinct and highly visible to predators. They have only survived because people find them cute.

Studying the appearance and optic manipulation performed to achieve the colours opens up a huge arena in the study of wave propagation. Peacocks achieve their iridiscent plumage through structural colouration. The quality of the colouration reveals a lot regarding the refinement of the genetic processes which create it.
Beauty is said to be in the eye of the beholder, it more like beauty is in the sensor and the heuristics attached to the sensor. With proper training you will find X-rays of ribcages and hyaenas beautiful (of course after you have spent a few years studying the subject for say a PhD). Beauty is often associated with a halo effect and positive attributes are lumped onto those who pass our physical beauty filter.

Rampant use of cosmetics has messed up our facial feature filters somewhat, soon we will be judging people by their bone structure (this happens a bit already among athletes), heat distribution or UV images. All the better for cyborg like optical implants or AR Goggles. I will keep performing full wave EM simulations in head and keep seeing things in Gigahertz range. With the anthropic principle in effect and metallic content of the known universe increasing due to fusion and the cosmic background being in this range, it might come in handy one day.

Saturday, June 9, 2012

Go back to PvE - fighting each other vs conquering the universe

In Hobart I used to hang out often at the Dr.Coffee. One Sunday I was sitting around drinking coffee and sketching, I met somebody preparing a lesson for a church gathering. We started talking about what each of us did and eventually I started describing, 3D modelling and game design. How a game has to have balance, PvE (player versus environment) and PvP (player versus player), how often at low levels the player is made struggle against the environment and some choose to keep doing it or on a game like Guild Wars with low level cap they choose to play PvP after having attained a certain level. Keeping on playing against the mind less monsters in the environment is considered grinding or farming, and generally looked down upon, unless you are a gold farmer who exchanges game gold for real world gold.

At the end of this conversation the believer in God left me a few words - "While you design and play games do not forget who designed you and which game you are living in.". This theme has been a common refrain since the advent of gaming. The overlap between virtual worlds and the real world is growing and is captured in a lot of cyber punk such as REAMDE. Currencies are changing hands by being sacrificed to gods in game world only to be converted to fiat in real world. Religions pose a similar dogma in real world, proposing to convert our material wealth, faith or in certain cases lives to real wealth for our players in some world beyond this one. The central premise being this is sort of a game world and we should indulge in PvP against players of the opposing team(religion, colour, nation, whatever label seems appropriate) to earn points, which will be converted to rewards in the world in which this simulation is running. The grand illusion of material world ideas have been around for a while, not as long as the 14billion year long illusion, but if you believe in such weirdness, time itself is an illusion anyway.

We seem to have reached a level cap for the time being in our evolutionary progression and become so heavily embroiled in PvP i.e. taking it out on each other that we have no time to engage in conquering our environment and making our society stronger. Widening our play ground, instead of squabbling over the invididual grains of sand in the sand pit. There is a favourite refrain among elite PvP players - "Go back to PvE". The politicians, financial magnets and all those playing to beat other humans in the game of life are PvP players looking down on those attempting to conquer the environment, be it in exploring new frontiers in medicine, space or fabrication.

If this does happen to be a game, why not figure out the mechanics first and become masters of the environment before going around shouting from roof tops about religion and judgement day, and why we should serve the games master i.e. a deity if we want to finish with a good score. We should just get along and keep playing the game of life, all eschatology aside. Our indulgence in gaming world seems to have helped in expanding the boundaries of real world through the likes of Elon Musk, we just need more people to stop playing against each other.

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.

Sunday, April 1, 2012

Locating scattering centers with FDTD

We are so stuck up with visible light and ray tracing where the path of a photon is a straight line that our minds reel at the thought of full-wave simulations and wave based solutions to Maxwell's equations. After all Maxwell believed in the luminiferous aether is required for the waves to propagate.

I have written before on how useful FDTD based methods are for getting an intuitive understanding of electromagnetic propagation, especially through optically complex objects such as forests. For the last few months as part of my PhD work I have been developing simple scheme based representations of vegetation structures in 2-dimensions to solve the wave propagation problem using FDTD. During my research I came across a trilogy popular science books, Branches, Shapes and Flow, describing how simple physical processes lead to the formation of all the complex natural shapes we see.

In a stationery wave field set-up in an FDTD simulation scattering centers appear as point sources similar to the radiation source. To locate these scattering centers accurately without visualising the time-slices, one can apply the Huygens-Fresnel principle. Simply use some image processing tricks  e.g. Generalised Hough, grab some time slices and locate centres of the circular field intensity patterns. To complete the analysis chain up the HDF output from MEEP to OpenCV Hough and you have instant location of scattering centers for fairly complicated scattering problems. The plant material is composed of microwave water, i.e. water with conductivity, permeability and permittivity it shows at microwave frequencies. If water had higher conductivity, we could have used MoM to model forests.

This analysis generates interesting questions about life and what we consider organic shapes vs inorganic(read crystalline) shapes. Under detailed analysis at the right wavelength (DNA capitulated to X-ray crystallography), organic shapes turn out to be formed out of crystalline shapes at multiple scales. What we consider inorganic is just the same material as organic, except it has not gone through sufficient iterations in the fractal generation process. The human mind is predisposed to seeing patterns amid chaos - The Grand Design, and an engineer loves to take the hood off and work out the forces at play which create the finished product. Only then can we assess the strengths and flaws of what we have at hand, and guide the forces to create new products following our own grand design. A lot of cosmetic products use crystalline structures to overlay the naturally evolved organic structures, this fools our heuristics of age determination. Beauty is heuristics anyway, harm will only come if the manipulation of heuristics pauses the continuity of the species.