提交 b3f68d29 编写于 作者: M Maria Dimashova

fixed bow sample

上级 319c20c7
...@@ -2014,7 +2014,7 @@ struct VocabTrainParams ...@@ -2014,7 +2014,7 @@ struct VocabTrainParams
// It shouldn't matter which object class is specified here - visual vocab will still be the same. // It shouldn't matter which object class is specified here - visual vocab will still be the same.
int vocabSize; //number of visual words in vocabulary to train int vocabSize; //number of visual words in vocabulary to train
int memoryUse; // Memory to preallocate (in MB) when training vocab. int memoryUse; // Memory to preallocate (in MB) when training vocab.
// Change this depending on the size of the dataset/available memory. // Change this depending on the size of the dataset/available memory.
float descProportion; // Specifies the number of descriptors to use from each image as a proportion of the total num descs. float descProportion; // Specifies the number of descriptors to use from each image as a proportion of the total num descs.
}; };
...@@ -2126,8 +2126,10 @@ static Mat trainVocabulary( const string& filename, VocData& vocData, const Voca ...@@ -2126,8 +2126,10 @@ static Mat trainVocabulary( const string& filename, VocData& vocData, const Voca
if( !readVocabulary( filename, vocabulary) ) if( !readVocabulary( filename, vocabulary) )
{ {
CV_Assert( dextractor->descriptorType() == CV_32FC1 ); CV_Assert( dextractor->descriptorType() == CV_32FC1 );
const int descByteSize = dextractor->descriptorSize()*4; const int elemSize = CV_ELEM_SIZE(dextractor->descriptorType());
const int maxDescCount = (trainParams.memoryUse * 1048576) / descByteSize; // Total number of descs to use for training. const int descByteSize = dextractor->descriptorSize() * elemSize;
const int bytesInMB = 1048576;
const int maxDescCount = (trainParams.memoryUse * bytesInMB) / descByteSize; // Total number of descs to use for training.
cout << "Extracting VOC data..." << endl; cout << "Extracting VOC data..." << endl;
vector<ObdImage> images; vector<ObdImage> images;
...@@ -2142,9 +2144,8 @@ static Mat trainVocabulary( const string& filename, VocData& vocData, const Voca ...@@ -2142,9 +2144,8 @@ static Mat trainVocabulary( const string& filename, VocData& vocData, const Voca
while( images.size() > 0 ) while( images.size() > 0 )
{ {
if( bowTrainer.descripotorsCount() >= maxDescCount ) if( bowTrainer.descripotorsCount() > maxDescCount )
{ {
assert( bowTrainer.descripotorsCount() == maxDescCount );
#ifdef DEBUG_DESC_PROGRESS #ifdef DEBUG_DESC_PROGRESS
cout << "Breaking due to full memory ( descriptors count = " << bowTrainer.descripotorsCount() cout << "Breaking due to full memory ( descriptors count = " << bowTrainer.descripotorsCount()
<< "; descriptor size in bytes = " << descByteSize << "; all used memory = " << "; descriptor size in bytes = " << descByteSize << "; all used memory = "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册