i.MX8QXP DPU image Warp

cancel
Showing results for 
Search instead for 
Did you mean: 

i.MX8QXP DPU image Warp

No ratings

i.MX8QXP DPU image Warp

In this doc will show how to use i.MX8QXP DPU do image warp.

 

SW: i.MX Linux BSP L5.4.24_2.1.0 bsp release and patch in this doc

HW: i.MX8QXP MEK board, ov5640 camera, HDMI display

 

  1. Introduction

Image Warping is the process of digitally manipulating image data such that the image’s projection precisely matches a specific projection surface or shape.1.png

 

i.MX8QXP DPU controller could do image warp work by its blit engine and display engine. I choose to enable blit engine’s fetchwarp9 unit to do warp work.

Check i.MX8QXP RM, Blit Engine support Image Warp as: “Performs a re-sampling of the source image with any pattern. The sample point positions are read from a compressed coordinate buffer.”

So you need prepare two input buffers, one buffer store original image data, the other buffer store resample point coordinate, DPU blit engine will read that two buffer by fetchwarp9 unit, then output result image buffer which contain warped image data.

Note i.MX8QXP DPU blit engine fetchwarp9 unit, for the input original image buffer, support RGB and YUV 4:4:4 format.

The resample point coordinate buffer contents is depend on what kind warp transformation in your use case; and for each resample point coordinate format check i.MX8QXP RM fecthwarp unit description as below. In this doc, using the 2xs12.4 format, each point x coordinate use (12+4) bit, same as y coordinate.2.png

 

For DPU fetchwarp9 unit, to enable it work for image warp, check i.MX8QXP RM:

3.png

 

2.Patch notes and test code

imx8-dpu-warp-kernel.diff contain the kernel side change for drm ioctl api permission and add vmap function of ion dma_buf_ops.

libg2d.so contain the binary for adding warp feature.

g2d.h is header file which add define for G2D_WARP and G2D_YUV4.

imx8-ov5640-dpu-warp-render.c is a sample code which show how to call g2d lib to image warp, need open the G2D_WARP flag.

And this code contain some example calculate the coordinate buffer of rotate, swirl, barrel distortion, affine transformation, perspective transformation, wave transformation.

And this code will show read camera input frame then add warp process , then render warp image frame to display.

 

The test cmd usage as below, read 1080P frame from ov5640 camera, do warp then render warp image to drm plane.

Note as dpu fetchwarp9 unit support YUV 4:4:4 input image frame, so below cmd need set parameter YUV4, which will ask ISI driver output YUV 4:4:4 image frame.

imx8-ov5640-dpu-warp-render  -i /dev/video0 -f YUV4  -S 1920,1080  -M imx-drm -p 91:38 -F XB24  -b 6  -e g2d  -t 5

        -i <video-node> set video node (default: /dev/video0)

        -f <fourcc>     set input format using 4cc

        -S <width,height>       set input resolution

        -s <width,height>@<left,top>    set crop area

        -M <drm-module> set DRM module

        -o <connector_id>:<crtc_id>:<mode>      set a mode

        -p <connector_id>:<crtc_id>     output to a plane

        -F <fourcc>     set output format using 4cc

        -t <warptype>   set 0 neutual 1 rotate 2 swirl 3 divisionmodel 4 affine 5 perpsptive 6 wave

        -b buffer_count set number of buffers

 

 
 

 3.Example

original image:

 4.png

 

 

Untitled.png

 

 

Untitled.png

Untitled.png

 

Untitled.png

Untitled.png

 

 

 

Untitled.png

 

Reference:

  1. https://www.nxp.com/webapp/Download?colCode=IMX8DQXPRM
  2. https://www.nxp.com/webapp/Download?colCode=L5.4.24_2.1.0_MX8QXPC0&appType=license
  3. https://en.wikipedia.org/wiki/Image_geometry_correction
  4. https://lists.freedesktop.org/archives/dri-devel/2012-March/019778.html
  5. https://store.kde.org/p/1246558
  6. https://github.com/ImageMagick/ImageMagick

 

 

 

 

Attachments
Version history
Revision #:
2 of 2
Last update:
‎11-12-2020 07:41 PM
Updated by:
 
Contributors