-
Notifications
You must be signed in to change notification settings - Fork 7.4k
lib: pixel: distort: add distortion aka defisheye aka dewarp #88840
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
base: main
Are you sure you want to change the base?
lib: pixel: distort: add distortion aka defisheye aka dewarp #88840
Conversation
A high-level illustration of how it is performed: Re-computing the coordinates for every pixel is a lot of number crunching. Instead, this is pre-computed as a grid, and intermediate pixels are interpolated. That is, it works tile-per-tile performing a perspective transform to get the correct orientation, just like switching between two map projections: Each zone in red becomes an (i.e.) 20x20 pixel square after conversion. From NXP AN13075 for i.MXRT, anything with the "projective transform" can perform the required acceleration: |
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.
Pull Request Overview
This PR introduces defisheye/dewarp distortion functionality into the pixel library. Key changes include new distortion routines in lib/pixel/distort.c and corresponding header updates, additional image processing functions in the pixel library, and updates to maintainers and metadata files.
Reviewed Changes
Copilot reviewed 55 out of 59 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
lib/pixel/stats.c | Added statistics functions; note typo in copyright header. |
lib/pixel/formats.c | New pixel format conversion functions; note typo in header. |
lib/pixel/bayer.c | Bayer conversion functions update; note typo in header. |
lib/pixel/distort.c | Introduced distortion routines for defisheye/dewarp support. |
MAINTAINERS.yml | Added Pixel library group with maintainers and test metadata. |
Other include files (pixel/*.h) | Headers updated to support new features and conversions. |
Files not reviewed (4)
- lib/CMakeLists.txt: Language not supported
- lib/Kconfig: Language not supported
- lib/pixel/CMakeLists.txt: Language not supported
- lib/pixel/Kconfig: Language not supported
Comments suppressed due to low confidence (2)
lib/pixel/formats.c:2
- Typo in header comment: 'Copyir' should be corrected to 'Copyright'.
* Copyir (c) 2025 tinyVision.ai Inc.
lib/pixel/bayer.c:2
- Typo in header comment: 'Copyir' should be corrected to 'Copyright'.
* Copyir (c) 2025 tinyVision.ai Inc.
Introduce the YUV24 format following the Linux V4L2 naming and fourcc definition. Signed-off-by: Josuah Demangeon <me@josuah.net>
Introduce the RGB332 format following the Linux V4L2 naming and fourcc definition. Signed-off-by: Josuah Demangeon <me@josuah.net>
THe RGB565X (big-endian) did not have an entry for the function video_byte_per_pixel(). Fix it by adding the missing entry. Signed-off-by: Josuah Demangeon <me@josuah.net>
The "pixel" library aims facilitating the implementation of all image processing tasks, such as pixel conversion, with a focus on low-resource environments. The processing functions scale down to per-pixel "kernels" to line-based conversion to full streams of several frames. Signed-off-by: Josuah Demangeon <me@josuah.net>
The newly introduced lib/pixel features utilities that help composing video pipelines together for the purpose of stream processing, as well as debug utilities. Signed-off-by: Josuah Demangeon <me@josuah.net>
The tests use data generated by the ffmpeg command line utilty in order to avoid bias by having the same person implementing the tests and the source code. Signed-off-by: Josuah Demangeon <me@josuah.net>
Add "Pixel library" area, which covers the newly introduced lib/pixel and associated tests and samples. Signed-off-by: Josuah Demangeon <me@josuah.net>
Add a distort pixel library module givesto correct the perspective of a fish-eye lens, used to get around 180deg of field of view. Signed-off-by: Josuah Demangeon <me@josuah.net>
The sample uses OpenCV to calibrate a fish-eye lens according to a the OpenCV tutorial, and generates C code usable by the lib/pixel/distort code that will apply at runtime the distortion computed by OpenCV at build-time. Signed-off-by: Josuah Demangeon <me@josuah.net>
5628f7f
to
e7f75ed
Compare
Dependencies:
This performs a distortion operation over an input frame according to a grid, and produces a corrected output frame.
Using a low-res 200x200 pixel preview:

Use-case is to correct the distortion introduced by a fish-eye lens, required to reach very large field of views (a distortion-free image at 180° FoV would have an infinite size).
Planned evolution: