Support in SDK for lens and projection distortions

Post Reply
suhl79
Posts: 21
Joined: Thu Mar 18, 2010 7:45 am

Support in SDK for lens and projection distortions

Post by suhl79 » Wed Oct 27, 2010 7:29 am

Hi

Do you plan on providing some functionality for correcting lens distortions (barrel distortion) or other type of camera pan&tilt projection problems?

Thanks
Konrad

Seth Steiling
Posts: 1366
Joined: Fri Jun 27, 2008 11:29 am
Location: Corvallis, Oregon

Re: Support in SDK for lens and projection distortions

Post by Seth Steiling » Wed Oct 27, 2010 2:05 pm

OptiTrack M12 lenses are super low distortion compared to others on the market, but the Camera SDK will contain lens distortion models, which should help you account for the minimal distortion that does exist.
Marketing Manager
TrackIR | OptiTrack

kb_kat
Posts: 6
Joined: Sun May 22, 2011 1:30 am

Re: Support in SDK for lens and projection distortions

Post by kb_kat » Sat Jun 04, 2011 10:27 am

Hello,
now the lens distortion model is in the new SDK. Usually the distortion model implies rectification of the gray-level images, i.e. assignment of the proper gray-level to a pixel(x,y). Does that also work for the inverse mapping in case of ObjectMode to assign the pixel (object) a new proper position(x,y)? I used the DistortionModel for the ObjectMode and found no difference when no DistortionModel was used. So i had to make my own software solution for that. Distortion of the lense is not large indeed but using it can still improve the precision. Thank you.

LinusA
Posts: 37
Joined: Mon Nov 08, 2010 8:43 am
Location: Aachen, Germany
Contact:

Re: Support in SDK for lens and projection distortions

Post by LinusA » Mon Jun 06, 2011 3:06 am

Seth, could you elaborate on the exact functions to use from the SDK? I've got V100R2 cams with 3.5mm lenses...

kb_kat, would you be so kind and post your results of the lense distortion you measured? I myself get distortions of between 8 and 12 pixels in the corners of the image (as I said, using 3.5mm wide angle lenses). Are those values the same order of magnitude you observe? Thanks

beckdo
NaturalPoint Employee
NaturalPoint Employee
Posts: 519
Joined: Tue Jan 02, 2007 2:02 pm

Re: Support in SDK for lens and projection distortions

Post by beckdo » Mon Jun 06, 2011 12:00 pm

Every camera in the Camera SDK has a default distortion model that you can 'get' from the device. The default distortion model matches the default lens we ship for that device. If you're running a non-default lens, the 3.5mm wide angle lens for example, you can request a model from us and we can give you the parameters.

Now, all this said, the Camera SDK doesn't actually apply these distortion models, they are simply there as helper functions so that they are easily used by the user.

Once you have the distortion model you want to use and an X,Y coordinate you'd like to remove the distortion on you can simply call Core::Predistort2DPoint which will remove the distortion of the raw coordinate.

If you need more clarification, we can go into this in more detail.

LinusA
Posts: 37
Joined: Mon Nov 08, 2010 8:43 am
Location: Aachen, Germany
Contact:

Re: Support in SDK for lens and projection distortions

Post by LinusA » Mon Jun 06, 2011 1:56 pm

Well, I'm doing my own intrinsic calibration, and then I'm currently using OpenCV undistort functions as well as a custom thing -- but I'm not happy with the OpenCV function.

So if you've got this function inside the camera SDK, I'll happily give Core::Predistort2DPoint() a try. Is there anything else I need for that?

It would be very great if you could send me the 3.5mm distortion model (PM or mail to linus.atorf (at) rwth-aachen.de ), then I could use the "official" exact coefficients and compare them to mine.

Thanks for the answers.

beckdo
NaturalPoint Employee
NaturalPoint Employee
Posts: 519
Joined: Tue Jan 02, 2007 2:02 pm

Re: Support in SDK for lens and projection distortions

Post by beckdo » Mon Jun 06, 2011 3:03 pm

The OpenCV approach should work for you as well. They have a good way of doing it and their model is similar to ours so I would expect good results using that approach.

The other thing you have to keep in mind is that the default distortion models coming out of the Camera SDK are essentially of one device and not your exact device. There are manufacturing tolerances that come into play so if you're going solve the distortion model from actual data (like the OpenCV approach) it's going to give you better results.

I do have 3.5mm model parameters which I will send to you.

LinusA
Posts: 37
Joined: Mon Nov 08, 2010 8:43 am
Location: Aachen, Germany
Contact:

Re: Support in SDK for lens and projection distortions

Post by LinusA » Mon Jun 06, 2011 4:11 pm

[quote=NaturalPoint - Doug]
The OpenCV approach should work for you as well. They have a good way of doing it and their model is similar to ours so I would expect good results using that approach.
[/quote]
Well, just to let you know what I'm doing: I've got a test-app which starts with grid-points on the image plane. Then I distort the points manually using the formula from the OpenCV docs here at the very top ( http://opencv.willowgarage.com/document ... ction.html -- the formula is broken, a correct image of it is here: http://i.imgur.com/t5TZe.png ). When I check, I get the barrel-like distortion pattern I expect. I then use cv::undistortPoints (http://opencv.willowgarage.com/document ... tortpoints ) to undistort the gridpoints again. Finally I compare the original start coords with those resulting positions. It turns out (also depending on my intrinsic calbration quality) that I get differences between 1 and 3 pixels near the corners. I think the reason is that cv::undistortPoints has a fixed limit of iterations in its approximation algorithm.

This was just to back up my claim ("that this OpenCV function is not perfect"). I'll happily look at the function from the camera SDK. Overall I don't have a problem with all of this, I still got alternative ideas to work with it. And now with the 3.5mm lens parameters, I can also cross-check my own intrinsics :-)

kb_kat
Posts: 6
Joined: Sun May 22, 2011 1:30 am

Re: Support in SDK for lens and projection distortions

Post by kb_kat » Mon Jul 18, 2011 2:57 pm

Hello, LinusA.
Sorry for the late response to your request. The idea with the software implementation of the inverse mapping is just iterative applying forward rectification (Barrel model) until your algorithm converges to certain precision. I never tried the Predistort2DPoint function however. Maybe this is the proper hardware solution i needed (and you too). By the way i used the Matlab calibration tool, and found it very handy (google search: "Matlab calibration tool"). If you want to use it too, however ignore their explanation of the rectification equations, i guess they are wrong. I used wiki for that.

By the way. Of course each camera needs its own calibration, when you screw the lense a bit (say for sharpness setting) it needs a new calibration, say nothing about installation of a new lense.

LinusA
Posts: 37
Joined: Mon Nov 08, 2010 8:43 am
Location: Aachen, Germany
Contact:

Re: Support in SDK for lens and projection distortions

Post by LinusA » Mon Jul 18, 2011 9:19 pm

[quote=kb_kat]Hello, LinusA.
Sorry for the late response to your request. The idea with the software implementation of the inverse mapping is just iterative applying forward rectification (Barrel model) until your algorithm converges to certain precision.
[/quote]
Well yeah, I was just disappointed with the results I got from the current OpenCV method. If you do a plain "reverese lookup", i.e. distort every input pixel, remember where it ends up, and do a lookup as undistortion, you don't need an iterative algorithm at all and get better results.


[quote=kb_kat]
I never tried the Predistort2DPoint function however. Maybe this is the proper hardware solution i needed (and you too).
[/quote]
As of yet, I sadly didn't try it myself.

[quote=kb_kat]
By the way i used the Matlab calibration tool, and found it very handy (google search: "Matlab calibration tool"). If you want to use it too, however ignore their explanation of the rectification equations, i guess they are wrong. I used wiki for that.
[/quote]
Yep, I'm a frequent user of Bouguet's camera calibration toolbox. The results seem very good, but the code is horrible :-).

[quote=kb_kat]
By the way. Of course each camera needs its own calibration, when you screw the lense a bit (say for sharpness setting) it needs a new calibration, say nothing about installation of a new lense. [/quote]
Sure.


If I get any new insights on this topic, I'll post here, and I'll of course be thankful for any news by other contributers. But right now, I've got no "problem" :-)

Post Reply