Forums - Using struct fcvCorrespondences in fcvGeomHomographyFitf32 - wrong homography result!

5 posts / 0 new
Last post
Using struct fcvCorrespondences in fcvGeomHomographyFitf32 - wrong homography result!
Paula_Carrasco
Join Date: 14 Nov 11
Posts: 15
Posted: Mon, 2011-11-14 00:55

Hi everyone, 

I'm building a code where I have 4 corresponding 3d->2d points set manually, then I try to use fcvGeomHomographyFitf32  to get the homography which takes 3d points into those 2d points, and then use it to warp an image.

The problem is that I cannot get a correct homography, and my guess is that I'm filling fcvCorrespondences in a bad way, and of course, i cannot find any example. My result is always ---> matrix = {0,0,0,0,0,1,-0,-0,1} ¿?¿?¿ but it should be the identitymatrix (same points in to, and from)

Can someone help me with this problem?. I only need an example on how to fill correspondences struct and how to use homographies

Thank you all in advance.

PS: this is the code I'm using.

 

//FASTCV

float*__restrict  matrix;

matrix = (float*) malloc(sizeof(float)*9);

fcvCorrespondences corrs;

const float32_t frompts[4*3] = {0.0f,0.0f,1.0f,marker.cols,0.0f,1.0f,marker.cols, marker.rows,1.0f,0.0f,marker.rows,1.0f};

corrs.from = (float32_t *)frompts;

corrs.fromStride=0;

uint16_t indicespts[4] = {0,1,2,3};

corrs.indices = (uint16_t*) indicespts;

corrs.numCorrespondences = 4;

corrs.numIndices = 4;

const float32_t topts[4*2] = {0.0f,0.0f,marker.cols,0.0f,marker.cols,marker.rows,0.0f,marker.rows};

corrs.to = (float32_t*)topts;

corrs.toStride=0;

fcvGeomHomographyFitf32 (&corrs, matrix);

 

  • Up0
  • Down0
Prasun_Choudhury
Join Date: 3 Dec 10
Posts: 15
Posted: Mon, 2011-11-14 20:52

Can you try the ' fcvGeomHomographyFitf32' function with the following setting for fromStride and toStride? I think the documentation is not correct where it says to set fromStride and toStride to 0.

corrs.fromStride = 3;
corrs.toStride = 2;

If the results you are getting is still incorrect, I will take a deeper look inside your code snippet.

 

  • Up0
  • Down0
Paula_Carrasco
Join Date: 14 Nov 11
Posts: 15
Posted: Tue, 2011-11-15 00:57

Hi Prasun! Thank you, you were right, documentation is wrong, now I get a proper homography matrix with "corrs.fromStride = 3; corrs.toStride = 2". The homography I get is exactly the same I get with OpenCV findHomography function.

The problem is that, when I use that homography with the function  fcvWarpPerspectiveu8, I always get a black image as a result.

My source image is 512*512 (multiple of 8), my destination image is 160*120 (both, multiple of 8), if I use the identity matrix, fcvWarpPerspectiveu8 works fine, but if I use the resultant homography of  fcvGeomHomographyFitf32 it does not work properly. (I tested the homography with OpenCV function warpPerspective with good results)

I tried to normalize points between 0 and 1, I tried to change destination image size... but always black image as a result. Any idea about this?

Thank you :)


PS: my code again

 

//FASTCV

float*__restrict  matrix;

matrix = (float* __restrict) malloc(sizeof(float)*9);

fcvCorrespondences corrs;

float width = marker.cols; //512

float height = marker.rows; //512

const float32_t frompts[4*3] = {0.0f,0.0f,0.0f,

width,0.0f,0.0f,

width,height,0.0f,

0.0f,height,0.0f};

corrs.from = (float32_t *)frompts;

corrs.fromStride=3;

uint16_t indicespts[4] = {0,1,2,3};

corrs.indices = (uint16_t*) indicespts;

corrs.numCorrespondences = 4;

corrs.numIndices = 4;

const float32_t topts[4*2] = {20.0f,20.0f,

100.0f,10.0f,

110.0f,60.0f,

10.0f,70.0f};

 

corrs.to = (float32_t*)topts;

corrs.toStride=2;

fcvGeomHomographyFitf32 (&corrs, matrix); //matrix OK -> same as OpenCV and tested with warpPerspective

Mat warpedFCV(Size(512,512), CV_8UC1);

fcvWarpPerspectiveu8(marker.data, marker.cols, marker.rows, warpedFCV.data, warpedFCV.cols, warpedFCV.rows, matrix);

 


  • Up0
  • Down0
Paula_Carrasco
Join Date: 14 Nov 11
Posts: 15
Posted: Wed, 2011-11-16 02:15

Thank you for the quick response again, I already had a handmade bilinear warp perspective method, I just wanted to test fastcv's performance. I'll wait for the next release then... do you know about next release's timing plans?... ;-)

Thanks again!

Paula.

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

We expect to have it in the next couple of months; will update it in the Qualcomm's FastCV website as soon as it is available.

  • 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.