mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
Revert "Fix a heap issue with static on Windows"
This reverts commit 8e93c19de3
.
This commit is contained in:
parent
0be18aca81
commit
032c363ea0
@ -346,27 +346,21 @@ inline LshTable<unsigned char>::LshTable(unsigned int feature_size, unsigned int
|
|||||||
mask_ = std::vector<size_t>((size_t)ceil((float)(feature_size * sizeof(char)) / (float)sizeof(size_t)), 0);
|
mask_ = std::vector<size_t>((size_t)ceil((float)(feature_size * sizeof(char)) / (float)sizeof(size_t)), 0);
|
||||||
|
|
||||||
// A bit brutal but fast to code
|
// A bit brutal but fast to code
|
||||||
static std::vector<size_t>* indices = NULL;
|
static std::vector<size_t> indices(feature_size * CHAR_BIT);
|
||||||
|
|
||||||
//Ensure the Nth bit will be selected only once among the different LshTables
|
//Ensure the Nth bit will be selected only once among the different LshTables
|
||||||
//to avoid having two different tables with signatures sharing many dimensions/many bits
|
//to avoid having two different tables with signatures sharing many dimensions/many bits
|
||||||
if( indices == NULL )
|
if( (indices.size() == feature_size * CHAR_BIT) || (indices.size() < key_size_) )
|
||||||
{
|
{
|
||||||
indices = new std::vector<size_t>( feature_size * CHAR_BIT );
|
indices.resize( feature_size * CHAR_BIT );
|
||||||
}
|
for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = i;
|
||||||
else if( indices->size() < key_size_ )
|
std::random_shuffle(indices.begin(), indices.end());
|
||||||
{
|
|
||||||
indices->resize( feature_size * CHAR_BIT );
|
|
||||||
for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) {
|
|
||||||
(*indices)[i] = i;
|
|
||||||
}
|
|
||||||
std::random_shuffle(indices->begin(), indices->end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a random set of order of subsignature_size_ bits
|
// Generate a random set of order of subsignature_size_ bits
|
||||||
for (unsigned int i = 0; i < key_size_; ++i) {
|
for (unsigned int i = 0; i < key_size_; ++i) {
|
||||||
size_t index = (*indices)[0];
|
size_t index = indices[0];
|
||||||
indices->erase( indices->begin() );
|
indices.erase( indices.begin() );
|
||||||
|
|
||||||
// Set that bit in the mask
|
// Set that bit in the mask
|
||||||
size_t divisor = CHAR_BIT * sizeof(size_t);
|
size_t divisor = CHAR_BIT * sizeof(size_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user