FPGA Image Signal Processor - FPGA ISP Accelerators - Undistort
FPGA Image Signal Processor |
---|
Introduction |
FPGA ISP Accelerators/Modules |
Getting the Code |
Examples |
GStreamer Pipelines |
Tested Platforms |
Contact Us |
Introduction
The FPGA-ISP Undistort allows you to fix lens distortion from the images retrieved by a camera based on the camera matrices and the distortion parameters. It performs the same operation to the OpenCV undistort
[1] and fisheye::undistortImage
[2] functions.
This accelerator performs the inverse mapping from the undistorted (fixed) image to the input image (distorted), and also produces the undistorted image at the accelerator's output, interpolating with Nearest Neighbor (we are currently working on integrating the bilinear interpolator.
The FPGA-ISP Undistort can work as any of the following options: module and accelerator.
Supported caps
The FPGA-ISP Interpolators are capable of managing the following image properties:
Maximum input: 2047x2047 Maximum output: 2047x2047 Pixels-per-clock: 2 (monochannel and multichannel) - limited by the interpolator Number of channels: monochannel, multichannel Formats: Any (the pixel size is templated) unless planar Pixel-arrangement support: interleaved
Algorithm overview
The interpolators are modules. You can configure them according to your application. The module I/O is presented below:
Input
- Image pointer: the reference to the RAM (BRAM if FPGA does not have one)
- Input/Output image dimensions: width/height in pixels
- Camera matrix (intrinsic): represented in Fixed Point Qs11.20
- Enhanced camera matrix: represented in Fixed Point Qs11.20 (called
newcameramatrix
in OpenCV) - Distortion coefficients: represented in Fixed Point Qs11.20. This accelerator supports 5 distortion parameters (k1,k2,p1,p2,k3) for Brown-Conrady and 4 distortion parameters (k1,k2,k3,k4) for Fisheye Model.
- Pixel-width: templated (up to 32 bits)
You can generate the camera matrices and the distortion coefficients by using OpenCV calibration function calibrateCamera().
For more information about camera calibration, please refer to [3].
Output
- Out stream: Depending on the Pixel-width
Public members
- Camera matrix struct:
camera_matrix_t
- Distortion coefficients struct:
distortion_t
Algorithms
The algorithms are based on the Brown–Conrady model:
and on the Fisheye model:
Some of the equations have been simplified and tailored to the application.
Results
-
Figure 1. Input image
-
Figure 2. Output (fisheye undistorted) image
Note: The results could vary depending on the camera matrix and distortion parameters. Accurate parameters may result in better image correction.
Benchmarks
Since the PicoEVB doesn't support 1080p images because of memory availability, the following performances are theoretical and approximate based on the performance obtained by the latency reported by the synthesizer:
Resolution | Maximum framerate (ARGB-NN) | Maximum framerate (GRAY8-NN) |
---|---|---|
4k | N/A | N/A |
1080p | 21.5 | 42 |
720p | 44.73 | 87,39 |
These estimates were generated by the latency produced by the RTL simulation.
Disclaimer: The accelerator performance shown above is intended to give an idea of the peak performance for a PicoEVB (PCI-e 2.0 1 lane) with more DSP available and a RAM attached to it. With a better device, this performance can be reached, leading to better results.
Known issues
1. GStreamer autonegotiation: The caps, such as width, height, and format, must be specified in the pipeline.
2. Numerical precision: Since the resolution is lower than using floating-point numbers, different results might be obtained.
References
- ↑ https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20undistort(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20newCameraMatrix)
- ↑ https://docs.opencv.org/3.4/db/d58/group__calib3d__fisheye.html
- ↑ https://docs.opencv.org/3.4.9/d4/d94/tutorial_camera_calibration.html
- ↑ https://developer.ridgerun.com/wiki/index.php?title=V4L2_FPGA/Examples/Pass_Through