Forums - Feature Matching - fcvSumOfSquaredDiffs36xNs8

6 posts / 0 new
Last post
Feature Matching - fcvSumOfSquaredDiffs36xNs8
katrin
Join Date: 28 Oct 11
Posts: 14
Posted: Fri, 2011-11-18 03:25

Hi,

I want to match 2 images and need some help. I already extracted the features (with fcvCornerFast9u8) and their descriptors (with fcvDescriptor17x17u8To36s8) for both images and stored them in 2 fcvFeatureType arrays.

Now I want to match these features. As a first step, I just want to implement a bruteforce algorithm for matching. So each descriptor in one image is compared to all descriptors in the second image, the two descriptors with shortest distance will be my match for the feature. I think the function fcvSumOfSquaredDiffs36xNs8 would do the comparision for me, but I don't know how to set invLenA and invLenB. What is meant with "Inverse of vector A"? I set it to 1/sqrt(normSq) but me results seam to be wrong. Do I need something else for the matching or am I completly wrong with my approach?

  • Up0
  • Down0
grk101
Join Date: 26 Oct 11
Posts: 12
Posted: Fri, 2011-11-18 17:55

Hi Katrin, 

Your approach sounds correct. 

invLenA is  the inverse of the L2 norm of  A  and invLenB is an array containing the inverse L2 Norms for each vector in B. 

Note that  fcvDescriptor17x17u8To36s8 only returns the squared norm  and not the length of the descriptor vector. 

Hope that helps. 

Cheers, 

Guy

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

Hi Katrin

Yes that's correct. The inverse of L2 norm is 1/sqrt(sum(X1*X1,X2*X2,...Xn*Xn)) when X1...Xn are the components of the descriptor. 

As you have said, since you already have the squared norm, all you have to compute is 1/sqrt(squaredNorm). 

Cheers

Guy

  • Up0
  • Down0
katrin
Join Date: 28 Oct 11
Posts: 14
Posted: Thu, 2011-12-01 04:17

Thanks for the help so far!

I'm still struggling with the method fcvSumOfSquaredDiffs36xNs8, especially with the parameter b. How do I correctly fill the int8_t** variable b? I have my descriptors stored in an array of fcvFeatureType, so my approach is to iterate over the feature array and copy the descriptors to the variable.

My current approach, which is not working, looks like this:

//allocating memory for parameter b - number of descriptors * size of descriptor
int8_t** descriptorsB = (int8_t**)fcvMemAlloc(numDescriptors*36, 16);  

 int8_t *destination = *descriptorsB;          
for
(uint32_t i = 0; i < numDescriptors; i++){ 
   memcpy
(destination, featureArray[i].descriptor, 36); //here the code crashes - already in the first iteration
   destination += 36;
}

I'm not really used to pointer arithmetics, so I'm probably messing things up. How can I do it right?


  • Up0
  • Down0
tdandroid
Join Date: 9 Nov 11
Posts: 11
Posted: Wed, 2011-12-21 14:27

You probably want to do something like:

// alloc array of pointers
int8_t **descriptorsB = (int8_t **) fcvMemAlloc(numDescriptors * sizeof(int8_t *), 16); 
for (uint32_t i = 0; i < numDescriptors; i++) { 
  // each element of descriptorsB points to a feature vector
  descriptorsB[i] = featureArray[i].descriptor;
}

 

  • Up0
  • Down0
tdandroid
Join Date: 9 Nov 11
Posts: 11
Posted: Wed, 2011-12-21 14:28

Double post, please delete me!

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