Oslo and the news

I have just come back from a great weekend in Oslo. It’s a interesting place although not really at all like Stockholm which came as a bit of surprise to me. Anthea and I did as much site seeing as we could getting to the Viking ship museum, Folk museum, sculpture park and ski jump in the one and a half days we were there. I’ll post the photos to the travelling section of my website shortly.

Saw this on slashdot today. It appears that MDRobotics (makers of the Canada arm I & II on the International Space Station) have been working on a similar project to me. They have created some software that can reconstruct a 3d model of a scene photographed by a stereo camera system. Their software also uses Lowe’s SIFT features.

A little progress

Well I managed to get the quickcam displaying the full resolution image using opencv. It turns out that it was capturing at 640×480 the whole time, it just wasn’t displaying the whole image. A bit of tweaking to the capture properties and everything started working correctly. Specifically I needed to add these lines:

cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);

I was also having a little bit of trouble getting at the raw image data from C# as you access it like this using C:

pix = ((uchar*)(img->imageData + img->widthStep*y))[x];

I ended up writing a function that looks like this (where imageData is an IntPtr):


/// This method is used to get the value of a single pixel from the
/// underlying C
array.
private unsafe byte GetPixel(int x, int y)
{
// the image data is in one long contiguous array so we need to
// skip y rows of widthstep
values before adding our x value to
// index to the right x point in the right row.

return (byte)(((byte*)this.Image.imageData) + this.Image.widthStep * y)[x];
}

Hey… it works 🙂

Bits and bytes

So it appears that I am pretty crap at this whole blogging thing… I just can’t seem to get into the routine of writing about the stuff I’m doing. It seems that I’d rather be doing, than writing 😉

Last Friday I got a couple of new toys from Amazon and over the weekend I had some time to have a bit of a play. I got a Nokia HDW-3 bluetooth headset which I intended to use with my computer to do some VoIP (voice over ip) stuff. I managed to get the bluetooth headset recognised and connected by Linux, however try as I might I couldn’t get the audio to work with the alsa bluetooth drivers. I will look into this when I get some more time… In the mean time however I tried downloading Skype for Windoze and managed to have a very nice conversation with my parents (in New Zealand) from here in London for the bargin price of only 1.1p a minute. Skype it seems, is a great thing.

Also in my box of Amazon goodies was a new web cam. I got a Logitech Quickcam Pro 4000 for my computer vision project. I managed to get it working under linux in no time at all using the PWC drivers, and had it displaying images using camstream and xawtv. I also managed to get it working with Opencv very quickly. Opencv has just started supporting cameras that use the Phillips chipsets recently as they produce images in the YUV color range. You will need to use the CVS version of opencv for it to work. Unfortunately I didn’t get working perfectly. It seems be only capturing the top left hand corner of the image for some reason. I have yet to debug the prolem though.

The other cool thing I did over the weekend was to write a bash script for a friend of mine that will automatically mount a drive for backup. It checks to see if the desired mount point exists eg /mnt/usb and if not attempts to mount it. If it fails it sends an email requesting that the external device be plugged in and switched on. It then retries once every 10mins for an hour and emails success or failure at each stage of the process. When if finally succeeds it runs the command passed as the only argument to the script. It probably doesn’t sound very difficult, but I hadn’t done any bash scripting for a while and it was a good challenge!

Well, hopefully you hear from me on a slightly more regular basis. I’ll try and put up another update on my vision project soon.

P/Invoke fun

So on the weekend I was trying to work on the next step in my vision project (really must get around to putting up a web page about it) and struck a wee problem with P/Invoke and marshalling using Mono on linux.

Actually it was two wee problems.

I was getting a run time exception saying that Mono couldn’t find the library I was trying to use via DllImport. I thought this was strange because the library was definitely in my ld.so.cache and I was pretty sure I had my C# code correct.

I decided to try a different approach and use an example I knew should work to test if it was in fact my code/c library combination that was causing it to fail, or if it was a problem with my Mono environment. So I tried the ncurses example from Mono: A Developer’s Notebook (excellent book by the way) and what do you know? It didn’t work 😦

Well, after a bunch of emails traded with some very helpful guys on the Mono-List I was getting close to working out the problem. After turning on logging and info using the MONO_INFO and MONO_LOG enviroment settings (see “man mono” for more details) I was able to see that Mono was infact finding the assembly but not loading it for some reason. Another guy suggested it might be something to do with gmodule. Well, I’d had some problems with a few other apps after I had changed to gcc 3.4.3 from gcc 3.3.4 recently so I switched back to gcc 3.3.4 recompiled gmodule and hey! it works…. kinda

So, now the ncurses example was working but I still couldn’t use P/Invoke with my target C library (the opencv library). Another helpful soul had suggested that if I use ldd to examine libopencv.so I would see that there was no reference to libstdc++ which was causing my problem. This was indeed the case, and after hacking a few linker steps in the opencv makefiles I was happily creating CvImage objects and loading highgui windows from my C# app!

Ahhhh… I just love it when I learn something new, and this time round I learnt a whole lot!

A useful .NET library to know about

I recently discovered Mapack for .NET by Lutz Roeder of Reflector fame. If you haven’t heard of Reflector I don’t know what rock you’ve been hiding under…

Anyway Mapack is a great library of math functions you’re likely to need at some stage but aren’t built into the .Net framework. I was looking for a Matrix class for doing matrix math, and also an example of a least squares implementation in C#. Mapack has both of these and a bunch more.

Check it out at http://www.aisto.com/roeder/dotnet/

I should have paid more attention in class!

So it turns out that all that matrix math I learnt at Uni is actually useful. Unfortunately I can’t remember most of it now so I am going through the very painful process of relearning it all.

I am trying to estimate what the image coordinates of an object will be after I perform a translation and rotation of the camera viewpoint. I think I’ve got the real world coordinates of the object relative to the new camera position. Now its just a matter of turning that into an image reference (pixel location).

Once I have this working I should be able to match features between frames. This will then enable me to estimate camera ego motion. Then I’ll be well on my way to my SLAM goal 🙂