Code Monkey home page Code Monkey logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
Hey Thibault

I might be able to help here - I spent a while working with distortion models 
during the "calibration phase" of my thesis.

"CameraPinhole::normImageToPixelCoordinates()" will convert from undistorted 
normalized coordinates to undistorted pixel co-ordinates, right?

And you want "CameraPinholeDistor::normImageToPixelCoordinates()" to convert 
from the undistorted, normalized coordinates to the DISTORTED pixel 
co-ordinates? So you are missing the step that applies a distortion model to a 
set of normalized image co-ordinates?

In that case, I have some code that might help. Obviously it will depend on the 
particular distortion model, but I implemented a solution for the rational 
model in OpenCV and it was quite simple, and I'm sure it can be adjusted to 
suit more models (such as ones using 5 or less coefficients).

Do you want me to try and implement it? Here is a bit of a sample of my old 
code:

------------------------------------------------------------

fx0 = cameraMatrix.at<double>(0, 0);
fy0 = cameraMatrix.at<double>(1, 1);
ifx0 = 1./fx0;
ify0 = 1./fy0;
cx0 = cameraMatrix.at<double>(0, 2);
cy0 = cameraMatrix.at<double>(1, 2);
// and k is an array containing the distortion model coefficients for a 
rational model

// x & y are the normalized, undistorted co-ordinates
// Determine radial and tangential distances/factors
r2 = x*x + y*y;
icdist = (1 + ((k[7]*r2 + k[6])*r2 + k[5])*r2)/(1 + ((k[4]*r2 + k[1])*r2 + 
k[0])*r2);
deltaX = 2*k[2]*x*y + k[3]*(r2 + 2*x*x);
deltaY = k[2]*(r2 + 2*y*y) + 2*k[3]*x*y;

// x_new and y_new are the re-distorted co-ordinates, but are still normalized
x_new = (x0/icdist) + deltaX;
y_new = (y0/icdist) + deltaY;

// x2 and y2 are now denormalized as well as redistorted, so should be 
equivalent to the positions on the original image
x2 = (x1/ifx0) + cx0;
y2 = (y1/ify0) + cy0;

------------------------------------------------------------

I'm happy to help with this front-end stuff (image I/O, calibration, features) 
when I can because I'm probably more knowledgable with this than I am with the 
actual SFM algorithms! 

Original comment by [email protected] on 3 Aug 2011 at 7:43

  • Added labels: ****
  • Removed labels: ****

from gsoc2011sfm.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
this would be very useful!!!
You can make changes and test via the testcamera.cpp tutorial (named "Learn 
what you can do with a pinhole distorded camera") if the 
distortion/undistortion work well. If it's the case, you can commit ;)

Original comment by [email protected] on 12 Aug 2011 at 11:54

  • Added labels: ****
  • Removed labels: ****

from gsoc2011sfm.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
Hey Thibault

OK, I've added in some re-distortion and the changes seem to work (although 
there are slight floating-point inaccuracies in the results of Test 8 Option 
1). I've committed it too (clumsily - I left out the log message accidentally 
:P). So once you've verified that the changes work feel free to close this 
issue.

Steve

Original comment by [email protected] on 17 Aug 2011 at 2:55

  • Added labels: ****
  • Removed labels: ****

from gsoc2011sfm.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
Great work! This issue is now closed!

Original comment by [email protected] on 18 Aug 2011 at 10:48

  • Changed state: Done
  • Added labels: ****
  • Removed labels: ****

from gsoc2011sfm.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.