@@ -1679,12 +1679,10 @@ void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(cons
1679
1679
const AKAZEOptions & options = *options_;
1680
1680
const std::vector<Evolution>& evolution = *evolution_;
1681
1681
1682
- // Matrices for the M-LDB descriptor
1683
- Mat values[3 ] = {
1684
- Mat (4 , options.descriptor_channels , CV_32FC1),
1685
- Mat (9 , options.descriptor_channels , CV_32FC1),
1686
- Mat (16 , options.descriptor_channels , CV_32FC1)
1687
- };
1682
+ // Buffer for the M-LDB descriptor
1683
+ const int max_channels = 3 ;
1684
+ CV_Assert (options.descriptor_channels <= max_channels);
1685
+ float values[16 *max_channels];
1688
1686
1689
1687
// Get the information from the keypoint
1690
1688
ratio = (float )(1 << kpt.octave );
@@ -1739,7 +1737,7 @@ void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(cons
1739
1737
dx /= nsamples;
1740
1738
dy /= nsamples;
1741
1739
1742
- float *val = values[z]. ptr < float >( dcount2) ;
1740
+ float *val = & values[dcount2*max_channels] ;
1743
1741
*(val) = di;
1744
1742
*(val+1 ) = dx;
1745
1743
*(val+2 ) = dy;
@@ -1751,8 +1749,8 @@ void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(cons
1751
1749
const int num = (z + 2 ) * (z + 2 );
1752
1750
for (int i = 0 ; i < num; i++) {
1753
1751
for (int j = i + 1 ; j < num; j++) {
1754
- const float * valI = values[z]. ptr < float >(i) ;
1755
- const float * valJ = values[z]. ptr < float >(j) ;
1752
+ const float * valI = & values[i*max_channels] ;
1753
+ const float * valJ = & values[j*max_channels] ;
1756
1754
for (int k = 0 ; k < 3 ; ++k) {
1757
1755
if (*(valI + k) > *(valJ + k)) {
1758
1756
desc[dcount1 / 8 ] |= (1 << (dcount1 % 8 ));
@@ -1931,7 +1929,11 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
1931
1929
float si = sin (angle);
1932
1930
1933
1931
// Allocate memory for the matrix of values
1934
- Mat values ((4 + 9 + 16 )*options.descriptor_channels , 1 , CV_32FC1);
1932
+ // Buffer for the M-LDB descriptor
1933
+ const int max_channels = 3 ;
1934
+ const int channels = options.descriptor_channels ;
1935
+ CV_Assert (channels <= max_channels);
1936
+ float values[(4 + 9 + 16 )*max_channels];
1935
1937
1936
1938
// Sample everything, but only do the comparisons
1937
1939
const int pattern_size = options.descriptor_pattern_size ;
@@ -1978,23 +1980,23 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
1978
1980
}
1979
1981
}
1980
1982
1981
- *(values.ptr <float >(options.descriptor_channels *i)) = di;
1983
+ float * pValues = &values[channels * i];
1984
+ pValues[0 ] = di;
1982
1985
1983
- if (options. descriptor_channels == 2 ) {
1984
- *(values. ptr < float >(options. descriptor_channels *i + 1 )) = dx;
1986
+ if (channels == 2 ) {
1987
+ pValues[ 1 ] = dx;
1985
1988
}
1986
- else if (options. descriptor_channels == 3 ) {
1987
- *(values. ptr < float >(options. descriptor_channels *i + 1 )) = dx;
1988
- *(values. ptr < float >(options. descriptor_channels *i + 2 )) = dy;
1989
+ else if (channels == 3 ) {
1990
+ pValues[ 1 ] = dx;
1991
+ pValues[ 2 ] = dy;
1989
1992
}
1990
1993
}
1991
1994
1992
1995
// Do the comparisons
1993
- const float *vals = values.ptr <float >(0 );
1994
1996
const int *comps = descriptorBits_.ptr <int >(0 );
1995
1997
1996
1998
for (int i = 0 ; i<descriptorBits_.rows ; i++) {
1997
- if (vals [comps[2 * i]] > vals [comps[2 * i + 1 ]]) {
1999
+ if (values [comps[2 * i]] > values [comps[2 * i + 1 ]]) {
1998
2000
desc[i / 8 ] |= (1 << (i % 8 ));
1999
2001
} else {
2000
2002
desc[i / 8 ] &= ~(1 << (i % 8 ));
0 commit comments