On spherical distortion

Spherical distortion, aka barrel distortion: it’s a problem. generally only a problem for wide angle lenses. Now I am using a wide angle lens so now it is a problem for me. I am adding barrel distortion to BBTouch, it is nearly done, but I havent been able to test it for many reasons mostly having to do with the newness and unfinishedness of my bigger and better table.

So I decided to blog about it a bit instead. (and get to the testing tomorrow).

Here is the new (unfinished) BBTouch barrel distortion defrakulator on the main config screen. The game here is to adjust the distortion amount (as well as dragging the ROI rectangle around) until your distorted (the green one) rectangle matches your surface. This is generally the opposite of many un-distorters out there in that they usually warp the whole image.

An important note: BBTouch never does any spherical calculations on the image itself. that is a bit silly (and a bit wasteful of the processor) instead it only adjusts the points that we care about, namely the blob positions. This way BBTouch only has to do a half-dozen calculations per cycle instead of trying to correct the entire image every cycle.

Now, that said, it would be totally cool to be able to see the undistorted camera image, and I may add that later (just during the config process, since it is a huge waste of processor otherwise) but for now, there will just be a bit of the draggy-stretchy.

One thing I did notice during the small amount of testing that I have done is that i will also need to implement a perspective distortion defrakulator as well. (if you look close in the above image, you can see that the barrel rectangle is not quite the same as the surface due to the perspective, which is of course amplified with the wide angle. ) so I guess i will be doing that in the next few days as well.

cheerio!
-b

This entry was posted in BBTouch, code, multitouch. Bookmark the permalink.

6 Responses to On spherical distortion

  1. sandor says:

    Yo Ben,

    looks promissing! But i was sure that you will come to this conclusions once you are building a bigger table – tha’s why i suggested a distro filter with some more features for corrections. It is very common that you don’t have the chance to place your cam exactly in the middle under your projection surface. BTW: the reactivison software is doing also a very nice calibration (it’s done with a printed sheet of paper). Maybe you have the time to look at the code of Martin. I also saw such a filter thingie in action in a commecial trecking application in the last days – that’s why i’m sure that it makes sense ;-)) How do you are planning the screen-calibration btw.?

    Oh, and another thing: i was trying to compile the new BBTouch version – i am getting very strange things. Actualy only a “dummy” window after the stuff is compiled… Hmmmm…. Aliens?

    Greets,

    Sandor

  2. Ben says:

    Hey Sandor,

    Yeah, i have been working on the distortion thing for a few days now. I just got my new IR illuminators so I can use my whole surface so I will be doing some more productive work + testing in the days to come.

    I had actually thought of the whole printed paper idea, but hadn’t gotten as far as the reactivision guys, they are so damn smart.

    anyhow i have been toying with a few ideas as to how to do the calibration (and distortion correction) I havent settled on a good one yet really. I want it to be more automatic than the ones that are out there, but I may have to be happy with something more manual in the meantime.

    In any case i hope to have something (even if it is kinda crappy) by the end of the week (hopefully :-)

    cheers!
    -b

  3. Ben says:

    oh, and i should mention: I will try and checkout a ‘clean’ copy of the bbtouch code and see what is going on vis-a-vis compiling problems.

  4. Ben says:

    Sandor,

    I checked out a version of the most current BBTouch code and it compiled with no problems. One thing you might try is trashing your prefs file (com.bb.bbtouch.plist in library->preferences i think)

    There is still some crazy thing in the way i am saving the prefs that causes some problems (i think it is how I am saving the camera settings as a big binary blob) anyway, i haven’t been able to recreate the problem well enough to fix it properly, but i do know that whenever there is a strange issue, trashing the prefs seems to help.

    Cheers!
    -b

  5. sandor says:

    Hey Ben,

    sorrysorrysorrysorrysorrysorry… I’m so stupid! I don’t have the right words for how stupid i am… Dunno why, but i have been toying all the time with the BBOSCCocoa trunk… And that’s why i was wondering why the hell do i get only a strange window telling me “Nope Nuttin her… etc.”. NOW i have dl-ed r89 and it works fine… Even so fine that i was able to simply put a white paper on my desktop and getting reliable blobs by simply pointing a webcam (the logitech that resides ON my monitor) at the paper. No IR mumbo-jumbo. Just a piece of paper. BBTouch takes my whole hand as a single blob and works like a charme ;-) You should check this out – it’s funny… BTW: take a look at http://www.vertigo-systems.de. I have visited last week the company – very nice and very clever people. On plus they are only 100-200m from my office. Actualy they are doing the same – they are tracking “large sized blobs”. Ofcourse with a very sophisticated software (linux) and with some very impressive client applications – i LOVE those fishes! ;-)))

    Can you estimate when you will have the time to put the experimental distro-filter version online?

    Great work man!

    Cheers,

  6. Ben says:

    Hey Sandor,

    i have actually seen those guys before, (or at least something very similar to it). Anyhow, glad you got it all working.

    As far as a good estimate, i don’t really know right now :-( the distortion stuff is not fully assembled and tested yet (turns out adding the calibration changes lots of things) and now that my dev machine bit the dust and is out of commission for a week or so I will be going a bit slower on my old G4.

    However, I am pretty excited to get my new table up and working (which requires the distortion stuff to work) so I am still working on it, even on the old machine.

    I have lost probably at least a day, maybe two dealing with the bad machine/ firewire problems, but i hope to get some good work done tomorrow and this weekend.

    Cheers!
    -b

Leave a Reply