PXP Rotation setup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PXP Rotation setup

601 Views
mborgerson
Contributor I

I am trying to set up the PXP to perform a 90-degree rotation of an input image with dimensions of 480 x 320 pixels in RGB565 format.  I do not get the desired results with the following processed surface and output setup:

OUT_PITCH: 960 OUT_LRC: 479,319    // OUT_ULC assumed to be 0,0
OUT_PS_ULC: 0, 0 OUT_PS_LRC: 479,319
 
If I start with an image with 320 x 320 dimensions,  I do get a successful rotation.
 
A PXP rotation  example  from the SDKs has the following cryptic code:
#define APP_IMG_WIDTH  WIDTH  480 // my own image definitions
#define APP_IMG_HEIGHT HEIGHT 320

/* PS input buffer is square. */  Why did they use a square--was it not designed to rotate the whole input image??
#if APP_IMG_WIDTH > APP_IMG_HEIGHT // from the SDK example
#define APP_PS_SIZE APP_IMG_HEIGHT  
#else
#define APP_PS_SIZE APP_IMG_WIDTH
#endif
#define APP_PS_ULC_X ((APP_IMG_WIDTH / 2) - (APP_PS_SIZE / 2))
#define APP_PS_ULC_Y ((APP_IMG_HEIGHT / 2) - (APP_PS_SIZE / 2))
#define APP_PS_LRC_X ((APP_IMG_WIDTH / 2) + (APP_PS_SIZE / 2) - 1U)
#define APP_PS_LRC_Y ((APP_IMG_HEIGHT / 2) + (APP_PS_SIZE / 2) - 1U)
 
 
If I use these defines,  I get the following register setup before the rotation:
OUT_PITCH: 960 OUT_LRC: 479,319
OUT_PS_ULC: 80, 0 OUT_PS_LRC: 399,319
 
Now the OUT_PS corners are a square in the middle of the desired image.  This does not seem to be a good recipe for rotating a complete rectangular image!   There are fewer pixels in the OUT_PS boundaries than there are in the output image.
 
I've got a pretty good understanding of the PXP capabilities for scaling, offsetting and blending images and was able to write an app to do a slide show with slide-in, zoom in, fade out, and other transitions as well as a Ken-Burns display of an image (slow zoom and offsets).
 
Rotation remains a mystery.   The text in the PXP section Rev3 of the  IMXRT1023 reference manual is helpful,  but does not have any particular detail on the setup of the PXP for rotation.
 
 
 

 

Labels (1)
0 Kudos
2 Replies

577 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @mborgerson ,

I modify the pxp_rotate example to rotate a rectangle. Please take a look.

 

Regards,

Jing

0 Kudos

567 Views
mborgerson
Contributor I

Unfortunately, while the changes may rotate the full image rectangle, the code still has all the defines with no explanation:

#define APP_IMG_WIDTH  DEMO_BUFFER_WIDTH     //480
#define APP_IMG_HEIGHT DEMO_BUFFER_HEIGHT    //272

/* PS input buffer is not square. */
#if APP_IMG_WIDTH > APP_IMG_HEIGHT
#define APP_PS_WIDTH APP_IMG_HEIGHT      //272
#define APP_PS_HEIGHT (APP_IMG_HEIGHT/2+8)      //272

#else
#define APP_PS_SIZE APP_IMG_WIDTH
#endif

#define APP_PS_ULC_X ((APP_IMG_WIDTH / 2) - (APP_PS_WIDTH / 2))
#define APP_PS_ULC_Y ((APP_IMG_HEIGHT / 2) - (APP_PS_HEIGHT / 2))
#define APP_PS_LRC_X ((APP_IMG_WIDTH / 2) + (APP_PS_WIDTH / 2) - 1U)
#define APP_PS_LRC_Y ((APP_IMG_HEIGHT / 2) + (APP_PS_HEIGHT / 2) - 1U)

#define APP_PS_ULC_X1 ((APP_IMG_WIDTH / 2) - (APP_PS_HEIGHT / 2))
#define APP_PS_ULC_Y1 ((APP_IMG_HEIGHT / 2) - (APP_PS_WIDTH / 2))
#define APP_PS_LRC_X1 ((APP_IMG_WIDTH / 2) + (APP_PS_HEIGHT / 2) - 1U)
#define APP_PS_LRC_Y1 ((APP_IMG_HEIGHT / 2) + (APP_PS_WIDTH / 2) - 1U)

What is needed is an explanation of why these #define statements are part of the code.

In my own experiments, I get good result by just setting the PS corners to (0,0) and (width-1, height-1).  I set the output surface to the same dimensions because the reference manual tells me so:

 

36.6.7 Output Surface Lower Right Coordinate (PXP_OUT_LRC)

This register contains the size, or lower right coordinate, of the output buffer NOT rotated. It is implied that the upper left coordinate of the output surface is always [0,0]. When rotating the framebuffer, the PXP will automatically swap the X/Y, or WIDTH/ HEIGHT, to accomodate the rotated size.

0 Kudos