Thursday, February 28, 2013

Where am I .... all the time

Okay lets start by clearly stating the futility of position, every defintion of position requires a reference frame. It would be pretty messy to define where I am relative to the centre of our galaxy at all times, the super-massive blackhole makes measuring time there pretty messy as well. I could define my position better in ECEF or ENU or in most cases Platte Carre. I set out to build a project which could define where I am at all times for the posterity and essentially keep a track of my spime. My spime is the only thing I have absolute natural rights to, everything else can be taken away and be subject to argument with sufficient legal juggling. Come to think of it even the personal spime is not inviolate, meh reading to much Hannu Rajaniemi. Android My Tracks is pretty good, but a phone sometimes feels like too many eggs in one basket, I don't want to leave it lying around in the car dash gathering sunlight.

The project is mainly based on a Seeeduino stalker board with a convenient Bee socket. I plugged the UBlox Neo-6M based GPS Bee there. Data logs go to a 2GB SD card and Lipo power is backed by a 1w solar cell. The GPS constantly spits out NMEA strings which get logged to the SD card as long as power and space is available. A log with 2 days worth of data took up 45Mb, so I can hold about 3 months of data. Unfortunately the 2000mAh battery died after 2 days of continous use, with some solar recharge while in use. Since the battery death, in order to prevent melt down in harsh sunlight and continuous use, I have added a USB charger option as a stop gap. This should hold the fort till I plug in the quartz/heat powered charger for use while hiking and the mini windmill for use while wind surfing. Eventually the SD card will blow off into star dust after I have had my fun and extracted and time and location of said fun, but hey SD cards are more expensive per-ounce than gold.

Monday, February 18, 2013

Baby food and Poker machines - Snapping stuff in MongKok

The biggest story making headlines while I killed time between city walks in HongKong was one featuring "Baby Formula", including an event just a few steps from me at the MongKok East station. Someone taking lights over was cornered and searched for baby food by citizens and angry mothers.
Australia is one of the wealthiest nations in the world in per-capita terms and most of our wealth is locked up in the Australian dream - house. In contrast it is quite difficult for young people to own a house in HongKong, so the consumption tends to be high in other areas. People eat out more often, since the living areas are small and can be a hassle cooking.
 People invest more in personal appearance, buying jewellery, clothes and watches. Admittedly I am very poor at brand recognition, but the greek links to Doxa made me remember that particular brand. Personal investment is also apparent in all the rush for cosmetics and offers for private tuition. Image and wealth you can carry about on you is everything here. Just like the pokie joints pretending to be video game parlours.

There is a tension between pro and anti-Falun gung groups. The posters for both factions are displayed side-by-side near the star ferry terminal, right next to the anti-communist party booth. The Harbour city mall with its clientele of mostly mainland buyers is nearby. The rebelliousness may be filtering back along with the baby food.

Sunday, February 10, 2013

Living and dying in the Sunderbans

This is a well established wikipedia fact the the Sunderbans are the world's largest single block of Mangrove forests. It is difficult to grasp the scale and density of it unless you are drifting around in the countless rivers cris-crossing it for an entire day. A couple of days ago, I did just that. Nothing as dangerous as what the locals do - strolling into the deep forest with a pass bought for AUD50 or so and spending days at end collecting fish and honey. Occasionally falling prey to tigers or crocodiles. At least they get to see the elusive tiger briefly. They keep doing it since profit margins are huge, some AUD4000 per month, better than sitting exams and waiting for a government job.

Public river transport
On the same day we saw human footprints heading into the jungle and after drifting around a bit more tiger footprints crossing the river. Crocodiles were everywhere, sunning themselves. We even saw a juvenile croc, looked rather harmless. One of the anecdotes we picked up was about a tiger losing his back legs to a croc while crossing the rivers.
The khal and kumir 
Those who don't earn their living from the forest have taken to clearing it and planting rice. The conservation efforts are ongoing to protect the forest and reduce land clearing. The big cyclone in 2009 - Aila, caused stormsurges and deposited salt on most of the rice fields. This has sent people back to the forests, until the salt tolerant rice comes along. The other noticeable thing was the profusion of solar panels, since most of this area is off the grid. Often there were separate panels supplying separate rooms and one clearly identified for the TV, attached to a satellite dish.
The musicians
The television is a rarity only afforded by the rich. The local live music and theatre scene seems to be pretty active. You can often spot musicians on the ferry heading to a gig on a pushbike with a dhol strapped to their back. Tourism is catching up to provide some more support and even more exposure for the area. It provides an alternative to "jungling", our cook lost her husband to a tiger. However local tourism can be quite destructive, since the locals tend to dump rubbish everywhere and get drunk and drown themselves in the river. Not much different from stories I read about Australians in Laos.

Sunset boat ride
It is a beautiful place, but in the danger of disappearing under the pressure of people. The great economic importance the forests have in their non-destructive use is keeping them from destruction. Things may go slightly awry if urbanisation finally catches up, being off the grid is actually good for this place.

Two weddings and Tiger Footprints

It is that time of the year when I visit my family in India and throw in a drive by tour of another place in Asia. This trip is almost round the world in its scope - Adelaide, Singapore, HongKong, Kunming, Kolkata, Dubai .... back. There are always memorable things at each spot. Singapore airport is just too familiar, but on 2 flights I sat next to Capgemini employees flying in and out of China (from Australia and to India). Something huge is brewing.

Hong Kong skyline
The highlight of HongKong was the busy life-style, crazy shopping and the hybrid cultural wedding. The lights make for great photography and testing out of my new 4/3 camera. Some serious lens shopping coming up. The wedding was a fun, great venue, good scale and +Rowan Fry looked understandly over the moon. The best part was the entrance in traditional chinese gear, he would have made a rather respectable official in imperial china. I wish them a happy life together.

Last week I attended another wedding in Bengal. The contrast was stark, the rush, the colours, the food. The only thing that was constant was the hot wire cut foam decorations, the flowers and the suit I wore to the other wedding. The wedding invitations extend to whoever bothers to come, I hardly knew anybody, not even bride and the groom. Felt a bit like a wedding crasher, till we went to see the bride's dad, he was laid up with all the stress from getting the feast organised for some 600 people.
Devil is in the detail
The last few days we toured the Sunderbans with a Backpackers group aimed at foreigners, much more relaxed than trying to do it packed like sardines in local style. There seems to be zero-respect locally for the Sunderbans, since the majority have not been lucky enough to see the tigers, all believe no tigers exist. They should perform 3D photogrammetry on tiger footprints, lay out some tiger sized dolls and change the holiday season to coincide with tiger mating season. Only then will people believe tigers do exist. Saw plenty of crocs though and some crazy tourists to keep us company. I was both local and foreign, had fun teaching Bengali - managed to teach a Canadian to count to ten. Should start some word association based Bengali learning kit.

Tiger paw prints

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.