Skip to content

Commit

Permalink
removed to warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsalinas committed Oct 4, 2018
1 parent f897fff commit a6d149d
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/fbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace fbow{


Vocabulary::~Vocabulary(){
if (_data!=0) AlignedFree( _data);
if (_data!=nullptr) AlignedFree( _data);
}


void Vocabulary::setParams(int aligment, int k, int desc_type, int desc_size, int nblocks, std::string desc_name)throw(std::runtime_error){
void Vocabulary::setParams(int aligment, int k, int desc_type, int desc_size, int nblocks, std::string desc_name) {
auto ns= desc_name.size()<static_cast<size_t>(49)?desc_name.size():128;
desc_name.resize(ns);

Expand Down
11 changes: 6 additions & 5 deletions src/fbow.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class FBOW_API Vocabulary
uint64_t hash()const;

private:
void setParams( int aligment,int k,int desc_type,int desc_size, int nblocks,std::string desc_name)throw(std::runtime_error);
void setParams( int aligment,int k,int desc_type,int desc_size, int nblocks,std::string desc_name) ;
struct params{
char _desc_name_[50];//descriptor name. May be empty
uint32_t _aligment=0,_nblocks=0 ;//memory aligment and total number of blocks
Expand All @@ -125,7 +125,7 @@ class FBOW_API Vocabulary
uint32_t _m_k=0;//number of children per node
};
params _params;
char * _data=0;//pointer to data
char * _data=nullptr;//pointer to data

//structure represeting a information about node in a block
struct block_node_info{
Expand Down Expand Up @@ -211,14 +211,14 @@ class FBOW_API Vocabulary
int _block_desc_size_bytes_wp;
register_type *feature=0;
public:
~Lx(){if (feature!=0)AlignedFree(feature);}
virtual ~Lx(){if (feature!=0)AlignedFree(feature);}
void setParams(int desc_size, int block_desc_size_bytes_wp){
assert(block_desc_size_bytes_wp%aligment==0);
_desc_size=desc_size;
_block_desc_size_bytes_wp=block_desc_size_bytes_wp;
assert(_block_desc_size_bytes_wp%sizeof(register_type )==0);
_nwords=_block_desc_size_bytes_wp/sizeof(register_type );//number of aligned words
feature=(register_type*)AlignedAlloc(aligment,_nwords*sizeof(register_type ));
feature=static_cast<register_type*> (AlignedAlloc(aligment,_nwords*sizeof(register_type )));
memset(feature,0,_nwords*sizeof(register_type ));
}
inline void startwithfeature(const register_type *feat_ptr){memcpy(feature,feat_ptr,_desc_size);}
Expand All @@ -228,7 +228,7 @@ class FBOW_API Vocabulary


struct L2_generic:public Lx<float,float,4>{
~L2_generic(){ }
virtual ~L2_generic(){ }
inline float computeDist(float *fptr){
float d=0;
for(int f=0;f<_nwords;f++) d+= (feature[f]-fptr[f])*(feature[f]-fptr[f]);
Expand All @@ -247,6 +247,7 @@ class FBOW_API Vocabulary

#else
struct L2_avx_generic:public Lx<__m256,float,32>{
virtual ~L2_avx_generic(){}
inline float computeDist(__m256 *ptr){
__m256 sum=_mm256_setzero_ps(), sub_mult;
//substract, multiply and accumulate
Expand Down
4 changes: 2 additions & 2 deletions src/vocabulary_creator.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ class FBOW_API VocabularyCreator

}

uint32_t id;//id of this node in the tree
uint32_t parent;//id of the parent node
uint32_t id=std::numeric_limits<uint32_t>::max();//id of this node in the tree
uint32_t parent=std::numeric_limits<uint32_t>::max();//id of the parent node
cv::Mat feature;//feature of this node
//index of the feature this node represent(only if leaf and it stop because not enough points to create a new leave.
//In case the node is a terminal point, but has many points beloging to its cluster, then, this is not set.
Expand Down
4 changes: 2 additions & 2 deletions tests/dbow2/TemplatedVocabulary.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ void TemplatedVocabulary<TDescriptor,F>::create(
m_words.clear();

// expected_nodes = Sum_{i=0..L} ( k^i )
int expected_nodes =
(int)((pow((double)m_k, (double)m_L + 1) - 1)/(m_k - 1));
// int expected_nodes =
// (int)((pow((double)m_k, (double)m_L + 1) - 1)/(m_k - 1));

// m_nodes.reserve(expected_nodes); // avoid allocations when creating the tree

Expand Down
2 changes: 1 addition & 1 deletion tests/test_dbow2VSfbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::vector<cv::Mat> toDescriptorVector(const cv::Mat &Descriptors)
return vDesc;
}

std::vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") throw (std::exception){
std::vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") {
//select detector
cv::Ptr<cv::Feature2D> fdetector;
if (descriptor=="orb") fdetector=cv::ORB::create(2000);
Expand Down
4 changes: 2 additions & 2 deletions utils/fbow_create_voc_step0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void wait()



vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") throw (std::exception){
vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") {
//select detector
cv::Ptr<cv::Feature2D> fdetector;
if (descriptor=="orb") fdetector=cv::ORB::create(2000);
Expand Down Expand Up @@ -70,7 +70,7 @@ vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string desc
}

// ----------------------------------------------------------------------------
void saveToFile(string filename,const vector<cv::Mat> &features, std::string desc_name,bool rewrite =true)throw (std::exception){
void saveToFile(string filename,const vector<cv::Mat> &features, std::string desc_name,bool rewrite =true){

//test it is not created
if (!rewrite){
Expand Down
4 changes: 2 additions & 2 deletions utils/fbow_create_voc_step0_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ vector<string> readImagePathsFromFile(char * txtlist){
return paths;
}

vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") throw (std::exception){
vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") {
//select detector
cv::Ptr<cv::Feature2D> fdetector;
if (descriptor=="orb") fdetector=cv::ORB::create(2000);
Expand Down Expand Up @@ -85,7 +85,7 @@ vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string desc
}

// ----------------------------------------------------------------------------
void saveToFile(string filename,const vector<cv::Mat> &features, std::string desc_name,bool rewrite =true)throw (std::exception){
void saveToFile(string filename,const vector<cv::Mat> &features, std::string desc_name,bool rewrite =true){

//test it is not created
if (!rewrite){
Expand Down
6 changes: 4 additions & 2 deletions utils/fbow_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace std;
#include <chrono>
class CmdLineParser{int argc; char **argv; public: CmdLineParser(int _argc,char **_argv):argc(_argc),argv(_argv){} bool operator[] ( string param ) {int idx=-1; for ( int i=0; i<argc && idx==-1; i++ ) if ( string ( argv[i] ) ==param ) idx=i; return ( idx!=-1 ) ; } string operator()(string param,string defvalue="-1"){int idx=-1; for ( int i=0; i<argc && idx==-1; i++ ) if ( string ( argv[i] ) ==param ) idx=i; if ( idx==-1 ) return defvalue; else return ( argv[ idx+1] ); }};

vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") throw (std::exception){
vector< cv::Mat > loadFeatures( std::vector<string> path_to_images,string descriptor="") {
//select detector
cv::Ptr<cv::Feature2D> fdetector;
if (descriptor=="orb") fdetector=cv::ORB::create(2000);
Expand Down Expand Up @@ -73,7 +73,9 @@ int main(int argc,char **argv){
cout<<"time="<<double(std::chrono::duration_cast<std::chrono::milliseconds>(t_end-t_start).count())<<" ms"<<endl;
cout<<vv.begin()->first<<" "<<vv.begin()->second<<endl;
cout<<vv.rbegin()->first<<" "<<vv.rbegin()->second<<endl;
for(auto v:vv)cout<<v.first<<" ";cout<<endl;
for(auto v:vv)
cout<<v.first<<" ";
cout<<endl;
}

}catch(std::exception &ex){
Expand Down
10 changes: 5 additions & 5 deletions utils/image_matching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace std;
#include <chrono>
class CmdLineParser { int argc; char **argv; public: CmdLineParser(int _argc, char **_argv) :argc(_argc), argv(_argv) {} bool operator[] (string param) { int idx = -1; for (int i = 0; i<argc && idx == -1; i++) if (string(argv[i]) == param) idx = i; return (idx != -1); } string operator()(string param, string defvalue = "-1") { int idx = -1; for (int i = 0; i<argc && idx == -1; i++) if (string(argv[i]) == param) idx = i; if (idx == -1) return defvalue; else return (argv[idx + 1]); } };

vector< cv::Mat > loadFeatures(std::vector<string> path_to_images, string descriptor = "") throw (std::exception) {
vector< cv::Mat > loadFeatures(std::vector<string> path_to_images, string descriptor = "") {
//select detector
cv::Ptr<cv::Feature2D> fdetector;
if (descriptor == "orb") fdetector = cv::ORB::create(2000);
Expand Down Expand Up @@ -67,18 +67,18 @@ int main(int argc, char **argv) {
{
filenames[i - 3] = { argv[i] };
}
for (int i = 0; i<filenames.size(); ++i)
for (size_t i = 0; i<filenames.size(); ++i)
features[i] = loadFeatures({ filenames[i] }, desc_name);

fbow::fBow vv, vv2;
int avgScore = 0;
int counter = 0;
auto t_start = std::chrono::high_resolution_clock::now();
for (int i = 0; i<features.size(); ++i)
for (size_t i = 0; i<features.size(); ++i)
{
vv = voc.transform(features[i][0]);
map<double, int> score;
for (int j = 0; j<features.size(); ++j)
for (size_t j = 0; j<features.size(); ++j)
{

vv2 = voc.transform(features[j][0]);
Expand All @@ -98,7 +98,7 @@ int main(int argc, char **argv) {

std::string command;
int j = 0;
for (int i = 0; i < scores.size(); i++)
for (size_t i = 0; i < scores.size(); i++)
{
std::stringstream str;

Expand Down

0 comments on commit a6d149d

Please sign in to comment.