Tuesday, 12 March 2013

Playing around with OpenCV and Complex Functions

Last week my college hosted a technical fest. It was pretty cool. There was some really cool tech on display at for the exhibitions, some awesome guest lectures, robotics competitions and a lot of workshops. It was quite a busy and interesting week. I attended this really interesting workshop that introduced us to image processing using Matlab. We managed to get matlab to track a ball in the field of view of my laptop's webcam and use this motion to control windows media player and the movement of wheeled bots. Recently, I've become really interested in the field of Artificial Intelligence so this simple computer vision exercise got me excited. I came back to my room that evening and started exploring my options.

That evening I discovered an excellent Open Source alternative for doing image processing called OpenCV. I decided to abandon Matlab and do image processing in OpenCV instead (Because it's freeeeeeee!). That very evening I got OpenCV compiled and set up on my Ubuntu partition and started learning image processing.

I had a bit of difficulty starting out because I'd never really learnt C++ 'officially'. So I had to use my basic knowledge of C and a lot of googling to understand the basics of setting things up. The biggest hurdle was understanding how classes and objects worked. It took a few hours to smooth those concepts out. As soon as I had a rudimentary grasp of what they meant I could start writing my first image processing program.

So fooled around with flipping and adding noise to images for the last week. Then I got a brilliant idea. I was having a bit of trouble visualizing what I was learning in math class. We were doing conformal maps. So I thought that it might be a good idea to use OpenCV to visualize conformal maps. So I set out trying to apply conformal maps to Lenna,  one of the most famous test images used in image processing.

It took me a couple of days to make the code completely bug free. There were some really annoying bugs. The fact that images were stored in matrices whose indices followed a left handed coordinate system added to the difficulty of implementation. I had to apply multiple transformations in series to get the code to work. But in end everything came together and this was the result!

The result of applying the transformation $w = z^{2}$.
Right now, the only transformation that works perfectly is $w = z^{2}$. Other functions give really weird outputs. I'll figure them out eventually.

And I've decided to open source the code I used for this! It's very messy because it's not the final version of the code and it's full of commented code and random cout statements.  But maybe somebody will find it useful.

The code can be found here: http://pastebin.com/kBBP2ASe

Monday, 11 March 2013

Anthropocene


When you see all of humanity's achievements (and environmental mistakes) summed up like that it really gives you a sense of wonder. We've come so far in terms of technology.

I suddenly understand what Arthur C Clarke meant when he said: "Any sufficiently advanced technology is indistinguishable from magic." The full force and meaning of that statement is mind blowing and frisson inducing. The kind of things we're doing with technology today really is magical. It's a testament to the power of science. We've managed to understand nature so well that we can bend unimaginably tiny clusters of atoms to our will. It really is amazing.

This is the same Youtuber who gave us the wonderful Symphony of Science series. He makes some really awesome stuff.

Saturday, 9 March 2013

Team Fortress 2 on Ubuntu!

Something happened a few months ago that got me really excited. Valve announced that they were releasing Steam for Linux.  At that point I had already installed Ubuntu on my laptop and the only reason I still used windows was that all my awesome games were in my Windows partition. But steam for Linux changed everything. So one of the first games to be ported to Linux was my favorite War Themed Hat Simulator (aka FPS ) Team Fortress 2. There were some initial problems though. It turned out that to actually get steam running on Linux I needed to install some new Nvidia drivers. But these drivers did not have support for laptops that had the Intel Optimus technology which turned off the graphics card when it was not being used to save power. In Ubuntu, the way to get around this is to use a software called Bumblebee which acts as a substitute for Optimus. The new Nvidia drivers didn't work with Bumblebee initially. So I had to wait.

Now I've finally managed to get everything to work together. TF2 finally works on Linux!!! Only my sleeping roommates prevented my from screaming "IT'S ALIVE!!!!" to the rest of the universe.



The game runs beautifully and I think it runs even smoother than it does on windows! It's amazing. The fps stats showed hardly any stutter at all! 

There are still a few problems that need to be resolved before I can run use Ubuntu as my main TF2 playing OS. The temperature is a lot higher in Ubuntu. It skyrockets to 75 degrees and stays there. Also, my hard drive seems to be heating up unnaturally when I play TF2. I think this might have something to do with that message on partition manager about my sectors being misaligned. Maybe that is causing the hard disk to work too hard to transfer the same amount of data. I'm not really sure how exactly to solve that issue. But I think it should be fine after a few more driver updates from Nvidia. 

And I also got this adorable in game item!!