-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image undistortion for fisheye lenses #2308
Conversation
…storting fisheye camera images
…ling the original image directly. Also, it was apparently important to use uint32_t as buffer indices.
struct video_listener *listener = NULL; | ||
|
||
// Camera calibration matrix (of the Bebop2 for a specific part of the visual sensor): | ||
static float K[9] = {189.69f, 0.0f, 165.04f, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be made configurable as it is camera/drone specific
0.0f, 188.60f, 118.44f, | ||
0.0f, 0.0f, 1.0f}; | ||
|
||
//static float k; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unnecessary comment
//static float k; | ||
|
||
// Function | ||
struct image_t *undistort_image_func(struct image_t *img); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declaration vs definition - probably no need to declare the function, unless you want to put this in a separate header
struct image_t img_distorted; | ||
image_create(&img_distorted, img->w, img->h, img->type); | ||
// this info is not created in image_create, but is necessary for streaming...: | ||
//img_distorted.ts = img->ts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so should it be here?
for(float x_n = min_x_normalized; x_n < max_x_normalized; x_n += normalized_step, x++) { | ||
uint32_t y = 0; | ||
for(float y_n = min_y_normalized; y_n < max_y_normalized; y_n += normalized_step, y++) { | ||
// for faster execution but smaller FOV, uncomment the next line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be controllable via a flag or a variable that the user can switch on/off
As described in the newest commit, cdf55d6, I followed up on all advice, adding camera calibration parameters and removing unnecessary comments. |
Was talking about the "Documentation" of the XML module, it had this incorrect line. No worries, I honord the pull and will fixup the documentation self. BTW I also have only "limited time™" . 😉 |
Thanks for looking at it and merging it. On my mobile phone, the description tags did not show, so I only saw that "the colorfilter" was incorrect... You can use this as a description: |
* Addition of an undistortion module that has the supporting functions for undistorting fisheye camera images
I have added undistortion functions to the vision library. These can be used to convert image coordinates from distorted fisheye lenses to undistorted coordinates and back, taking into account the camera calibration matrix and the distortion of the specific lens. The distortion function is the one from Dhane, P., Kutty, K., & Bangadkar, S. (2012). A generic non-linear method for fisheye correction. International Journal of Computer Applications, 51(10). (invertible fisheye model), as it is an invertible model.
I also made a module, undistort_image, that uses the functions to undistort a whole image. This is quite a slow process, so it is not really advisable to use this in a vision pipeline leading to control. However, it can be used to find the right undistortion parameter k, and shows that the undistortion functions work.
I have tested the functions and module on a Bebop 2, using the front image. I added a specific airframe to the TU Delft airframes for this purpose.