Thursday, January 12, 2012

Kinect viewer with HTML5 canvas

I wanted to create a web-based Kinect viewer that would work on multiple platforms, including Android mobile phones and iPhones. To this end, I created a HTML5 canvas particle viewer for Kinect data using my very limited javascript knowledge and a lot of Mr. doob's knowledge.
Kinect HTML5 particle image

Take a look at the HTML5 Kinect particle image viewer.

Using libfreenect I captured the depth and color data, used Imagemagik and an Automator script to process and stich the images, and threejs to render.

You can extract data from an image by rendering it to a hidden canvas element, and then reading the canvas image data. To avoid errors, the image data should only be read after the full image has been loaded, as per the callback function in loadTexture.

function getImageData( image ) {
var canvas = document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext( '2d' );
context.drawImage( image, 0, 0 );
return context.getImageData( 0, 0, image.width, image.height );
}

function getPixel( imagedata, x, y ) {
var position = ( x + imagedata.width * y ) * 4, data = imagedata.data;
return { r: data[ position ], g: data[ position + 1 ], b: data[ position + 2 ], a: data[ position + 3 ] };
}

var texture, imagedata;
texture = THREE.ImageUtils.loadTexture( "textures/sprites/spark1.png", new THREE.UVMapping(), function ( event ) {
imagedata = getImageData( texture.image );
} );


To run the system locally, avoiding some of Chromes very annoying security settings, you can just use python to run a simple webserver:

python -m SimpleHTTPServer


I recorded a short data sequence and rendered to sprites to create this final 3d home move with the Kinect (too slow for my phone to render). I believe this is the first web-based kinect video ever made, youtube3d anyone?



Animated 3D kinect data with HTML sprites

Next time, I might try WebGL...

Wednesday, January 11, 2012

2011 Wrapup

Looking back, 2011 was certainly a quieter year than 2010. Personal life got busy in the later half of the year, so less was posted. My job also took a less technical turn as I moved away from software development.
By far my most popular posts concerned my analysis of some popular demo scene effects and WebGL:
Otherwise, a survey / summary post on exe compression for multiple platforms was well read, and my Civ 5 casual game mod proved popular too.

I will try to post a bit more about work and the mining industry, not because these are popular posts, but because there is so little information about this field on the web. I hope to post more about robotics and graphics (raytracing), and will try to open source and post about some of my past work.

Monday, December 12, 2011

GPU and Graphics catchup post

It has been a long while since I've done a graphics related post, so here is a bit of a backlog from the last few months of graphics and GPU links:
Finally, I'll leave you with a fantastic 64kb demo by Fairlight and Alcatraz that placed 2nd at Assembly 2011.

Tuesday, November 29, 2011

Remotely Operated Mining

I gave a presentation on the Transmin Rocklogic rock breaker automation system at the Remotely Operated Mining Projects conference. All in all it was a fairly decent conference focused around the theme of remote operations for mining, focusing predominantly on integrated planning, remote operation technology, and the design and construction of remote operation centers.

Talks were given by:
  • Greg Lilleyman, Rio Tinto - an overview of remote operations
  • Matthew Michalewicz, SolveIT - integrated planning for mature organizations, interesting overview of some of the wine industry supply chain issues
  • Patrick Warrand, Wesfarmers Premier Coal - a open overview of issues for 'small' mining operations (Note: Small is of course a relative term compared to the massive operations of BHP and Rio)
  • Jeremy Newman, Schneider Electric - a suppliers point of view to automation
  • Jock Cunningham, CSIRO - an overview of CSIRO activity in mining, and their SLAM technology. (WAMBOT was multi-agent SLAM, CSIRO does automotive SLAM and a novel handheld indoor SLAM 'Zebedee')
  • Brendon, Leica Geosystems - an overview of Autonomous Solutions Inc (they do lots of autonomous systems for military and agriculture), and Locata - a GPS alternative
  • David Beck, Beck Engineering - a case study of Simulation Aided Engineering
  • Adrian Boeing, Transmin - remotely operated rockbreaking
  • David Cavanagh, Integrated Energy - an overview of remote operation center designs for oil and gas, and mining
  • Lucas van Latum, Modular Mining - Goal orientated planning and the Observe-Orientate-Decide-Act loop
  • Reuben Kooperman and Peter Hunt - architecture for Remote Operation Centers (or Integrated Planning Centers) - including two buildings I go past on a regular basis and never fully realised what goes on inside - the City of Stirling building, and the ECU Joondalup library.
  • Mike Lomman, OpX Solutions - planning considering bottlenecks
  • Andrew Jessett, MineWare - realtime dragline and shovel monitoring and support/maintenance orientated ROC's.
  • David Hattrick, Oracle Corporation - Oracles approach to managing mining data and information
  • Richard Taylor, Concept AV - Video walls
I put the Rocklogic animation up on youtube, it's pretty neat. Gives a short overview of the systems features - Remote operation, collision avoidance, automated movements (auto-park, auto-deploy), etc.

Wednesday, November 23, 2011

PDF tools

PDF files are the standard document distribution format. PDF has long left other file formats in the dust. However, there are always a number of operations that people like to make to PDF's ranging from just creating them, to splitting or merging to applying a watermark or foreground stamp.

There are a number of great free tools to do all this work.

  • PDF Creator lets you create PDF files in Windows. Another popular alternative is CutePDF. For Apple Mac, under OSX you can simply print straight to PDF.

  • Splitting/bursting and merging/combining PDFs I feel is best done with a dedicated tool, PDFSAM - Split and Merge. Under OSX, you can actually use the sidebar of preview to move pages around, and drag in PDFs to merge, or pages to remove. If you have a lot of pages to do PDFSAM is a wiser choice, otherwise for smaller tasks Preview is fine.

  • Compression of PDFs under OSX is also straight forward, you just need to open the PDF in preview, and then under Quartz filter choose "Reduce File Size". Under windows, you can use PDFTK, more on this later.

  • Annotation of PDFs, again with OSX, preview gives you a small set of annotation tools. Under windows, you can use PDFTK. (Low cost / free for some-things aternatives are PDF-Xchange viewer and Foxit Reader)

  • Watermarking and Stamps are best done with PDFTK.

  • Encryption can be done with PDFTK, and under OSX, preview has an encrypt option.



  • Of course for those with cash, Adobe's tools are the best choice, but pdftk is a fantastic free alternative, if you don't mind a bit of command line typing.

    An example of putting a foreground stamp onto every PDF with pdftk:
    • Generate a PDF where you would like to apply the stamp to (i.e. the source)
    • Create a stamp PDF. This should have the stamp you wish to apply (e.g. "DRAFT") and be a transparent PDF. Microsoft Word will generate transparent PDFs by default, so you can create your stamp in Word.
    • Apply the stamp to the source PDF using pdftk, for example:
      pdftk in.pdf stamp stamp.pdf output out.pdf
      

    Enjoy!

    Sunday, September 25, 2011

    Robotics competitions and courses

    Sounds like it is competition season again.
    • UAV outback challenge where an unmanned ariel vehicle needs to find a person and drop supplies off to them. Registrations are due on the 27th September!
    • NASA Sample Return Centennial Challenge, a 1.5 million dollar prize competition to have robots autonomously explore a region, collect samples, and bring them back to base. Registration due in January, with the competition set for June. Only 8 months before the deadline when they announced the competition details - what are they thinking?
    • The ICRA solutions in perception challenge (May 2012), this doesn't seem too difficult - Identify and classify a set of objects, where you are given some training data/time. Use any sensor(s) you like.
    • Australian CiSRA ExtremeImaging competition an interesting computer-photography competition, due October this year, finals in November.
    Many more are listed at the robot contests and competitions FAQ. To get you up to speed with robotics, there are some great free courses being run. The stanford Machine Learning course and the Introduction to AI class are both free to register, and start now! The ESA summer of code in space already started last month, but it is worth keeping an eye on for next time.

    Monday, September 12, 2011

    Civilization 5 - Casual/fast game mod for Apple Mac OSX

    I rarely have enough spare time these days to be able to play a game, let alone identify a block of time large enough to dedicate to a game like Civilization 5 - which can take up to 12 hours to play a fast game. So I decided to create a mod for Civ 5 that would significantly speed up gameplay and enable a game to be completed in a few hours.

    Modding the game isn't directly supported under OSX, however it can be done.

    First, edit MainMenu.lua, located in:
    ~/Library/Application Support/Steam/SteamApps/common/sid meier's civilization v/Assets/UI/FrontEnd
    

    Comment the following line: (add a '--' to the start)
    Controls.ModsButton:SetHide( true );
    

    Copy a mod you have downloaded into the:
    ~/Documents/Aspyr/Sid Meier's Civilization 5/MODS
    
    directory.

    You will need to unzip/extract them before they will work.
    If it is a civ5mod file, simply rename it to .7z, and you can use StuffitExpander or any similar tool to extract the folder.

    Start Civ5, and you should see a 'MOD' option on the menu.

    Creating your own mods is easy enough if you know how. Armed with a decent text editor and the console you can create mods under OSX. Begin by reading Dale's explanation of modinfo files. Next, the 2K games Civilization 5 wiki is a good place to visit, in particular the Civ 5 XML reference guide. Finally, the civfanatics modders guide provides an excellent overview of creating a mod.

    You can use the command line 'md5' program to generate the MD5 hashes required for the modinfo file. (And online lower-to-uppercase conversion)

    You can download my simple casual gaming mod for Civilization 5 here. It replaces the standard 'quick' game. At the beginning of the game, you will find most things only take one turn to complete. Things will start to settle down quickly though in classical times.