Forums - Transformations and warpings, how to use them?

4 posts / 0 new
Last post
Transformations and warpings, how to use them?
Paula_Carrasco
Join Date: 14 Nov 11
Posts: 15
Posted: Wed, 2011-11-16 04:04

Hi everyone, I'm trying to use fcvTransformAffine8x8u8 function, but I cannot set the parameters corretly. I'm having issues with this two parameters:

nPos[2 ] Position in the image in 32 bit fixed point 
WARNING: must be 64-bit aligned.nAffine[2 ][ 2 ] Transformation matrix in 32 bit fixed point 
WARNING: must be 128-bit aligned.

I cannot make it work, not even with hardcoded values.

Have someone tested that functions?

Thank in advance, 

Paula.

 

  • Up0
  • Down0
grk101
Join Date: 26 Oct 11
Posts: 12
Posted: Wed, 2011-11-16 15:04

Hi Paula, 

The function transforms a canonical 8x8 rectanlge centered at 0,0 to a region in the image and samples in that small region. 

nPos[2] is the translation component of the affine transform in 32 bit fixed point 

affine[2][2] is the rotation and scaling component also in 32 bit fixed point. 

Below is a code snipet that shows how the function can be used.

 

static inline int float2Fx32( float nFloat )

{

    int fixed = ( int )( nFloat*( 1<<16 ) );

    return fixed;

}

static void float2Fx32( float * nFloat, int* fixed,int size )

{

   for ( int k = 0; k < size; k++ )

   {

      fixed[ k ] = float2Fx32( nFloat[ k ] );

  }

}

  float posf[2], matf[4];

  posf[ 0 ] = 12.25f; posf[ 1 ] = 52.0f;

  matf[0] = 0.013717344f; 

  matf[1] = 0.69070274f; 

  matf[2] = -0.67423344f;

  matf[3] =  0.024732463f;

  //Make sure arrays are 128 bits aligned

  int FASTCV_ALIGN128(posi32[2]), FASTCV_ALIGN(mati32[4]);

  float2Fx32( posf,posi32,2 );

  float2Fx32( matf,mati32,4 );

  unsigned char FASTCV_ALIGN128(img[480*320]);

  unsigned char FASTCV_ALIGN128(patch[8*8]);

  int res = fcvTransformAffine8x8u8( img,480,320, posi32, mati32, patch);

 

 

 Cheers,

 Guy

  • Up0
  • Down0
Prasun_Choudhury
Join Date: 3 Dec 10
Posts: 15
Posted: Wed, 2011-11-16 16:22

The above code provides a very good description of using the TransformAffine8x8 function and should work as expected. In general, whenver there is a byte mis-alignment (of size 4, 8, 16), one can use the following FastCV macro functions to align the data properly:

FASTCV_ALIGN32 // macro to align memory at 4 bytes (32 bits)

FASTCV_ALIGN64  // macro to align memory at 8 bytes (64 bits)

FASTCV_ALIGN128 // macro to align memory at 16 bytes (128 bits)

Thanks!

  • Up0
  • Down0
Paula_Carrasco
Join Date: 14 Nov 11
Posts: 15
Posted: Mon, 2011-11-21 04:18

Hi Guy, I'm still struggling to get good results, about your comments.

1. Result:

Reading Qualcomm's FastCV documentation it says:

FASTCV_API int fcvTransformAffine8x8u8 [...] Returns: true if the transformation is valid

 FASTCV_API int fcvTransformAffineu8 [...] Returns: true if the transformation is valid

So my guess was: result == 0 --> false, hence error; resulta == 1 --> true ,  hence OK

(y always get 0, yep)

2. Typo

It isn't a typo, OpenCV stores width and height that way: 

width = number of columns of an image

height = number of rows of an image

(anyway I tried inverting those numbers, but same behavior ocurred)

 

Next, I followed your advice and tested int fcvTransformAffineu8:

Sadly on the documentation they don't specify source and destination alignments, and the parameters "position" and "affine" are different types comparing with fcvTransformAffine8x8u8  (the are not 32bit fixed point anymore)

I tried everything possible, I'm starting to feel desperate, it's been a whole week for just warping an image. It should't be that difficult... 

Just a final question. Has someone tested any of these functions sucessfully? 

 

Thank you for your help, sincerilly.

Paula.




 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.