Code Monkey home page Code Monkey logo

fbow's Introduction

FBOW

FBOW (Fast Bag of Words) is an extremmely optimized version of the DBow2/DBow3 libraries. The library is highly optimized to speed up the Bag of Words creation using AVX,SSE and MMX instructions. In loading a vocabulary, fbow is ~80x faster than DBOW2 (see tests directory and try). In transforming an image into a bag of words using on machines with AVX instructions, it is ~6.4x faster.

Main features:

* Only depends on OpenCV 
* Any type of descriptors allowed out of the box (binary and real)
* Dictionary creation from a set of images. Bugs found in DBOW2/3 corrected.
* Extremmely fast bow creation using specialized versions using AVX,SSE and MMX instructions both for binary and floating point descriptors.
* Very fast load of vocabularies

The main differences with DBOW2/3 are:

* Not yet implemented indexing of images. 

Citing

If you use this project in academic research you must cite us. This project is part of the ucoslam project. Visit ucoslam.com for more information

Vocabularies

In directory vocabularies you have one already prepared for orb.

Test speed

Go to test and run the program test_dbow2VSfbow

License

This software is distributed under MIT License

fbow's People

Contributors

rmsalinas avatar shinsumicco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbow's Issues

cluster center initialization

Hey,

is there a reason why the mechanics for determining the cluster centers changed from the kmpp algorithm used inside DBoW2 to the version now used in fbow?

I noticed that especially with smaller vocabularies, sometimes the exact same feature is chosen multiple times as the initial cluster center which results in one of them always being empty (because all features fall into the one being found first during linear search) and therefore generating unused/meaningless words.

I ported the DBoW2 KMPP implementation over to fbow and can do a PR. Just wanted to make sure I'm not missing any domain knowledge before doing so.

Greets

Issues when creating boost.python wrapper

Hi, I am trying to create a boost.python wrapper for this library based on the pyDBoW3 wrapper created by @foxis. However, I have run into an interesting issue where I am unable to import into python when I reference any function from fbow's vocabular_creator.h.

My wrapper repo is at https://github.com/vik748/pyfbow and the full detailed description of the issue is on stackoverflow.

I suspect that there might be issues due to the compiler flags used to optimize the code using AVX, SSE and MMX. In order to address this, I also tried compiling pyfbow in the same package with the same CMakeLists.txt, but that didn't help either.

Since pyDBoW3 wrapper worked, I was hoping you can shed some light onto the subtle differences in fbow that might be causing conflicts / issues.

Thanks in advance for your help.

Cheers !

Fixed building failure with Visual Studio 2015

First compiler error found here:
cpu_x86.h(42): error C2556: '__int64 fbow::cpu_x86::xgetbv(unsigned int)': overloaded function differs only by return type from 'uint64_t fbow::cpu_x86::xgetbv(unsigned int)'

I checked the definition in line 36 of the same header:
static inline uint64_t xgetbv(unsigned int x);
and resolved this issue by changing the return type from uint64_t to uint64_t.

The second error is:
cpu_x86.h(71): error C2653: 'cpu_x86': is not a class or namespace name
which is due to the } in line 61 that prematurely closes namespace fbow{.

The third error encountered:
src\fbow.cpp(150): error C3861: 'aligned_alloc': identifier not found
is fixed by using _aligned_malloc instead of aligned_alloc. I added
#ifdef WIN32
#define aligned_alloc _aligned_malloc
#endif
to the header fbow.h to get rid of that one.

Word weights not normalized when generating BowVectors

I've noticed that the weights of the words in the fbow map are computed without any form of normalization.

fbow/src/fbow.h

Line 434 in e148dbc

r1[bn_info->getId()]+=bn_info->weight;

What's more, it appears that the vocabulary itself is not normalized.

This is quite inconsistent, especially regarding DBoW2 implementation where every bag of words is normalized upon its generation: https://github.com/dorian3d/DBoW2/blob/3924753db6145f12618e7de09b7e6b258db93c6e/include/DBoW2/TemplatedVocabulary.h#L1191

It it thus not suprising to see that loop closure and relocalization do not seem to work properly in frameworks like openvslam as highlighted by several issues including the following: #31 (comment)

Compiling on ARM64 architecture

Hello @rmsalinas and @shinsumicco,

It seems this project hasn't had any update in many years, but I hope you can help me with this small issue.

For what I've seen, the CMakeLists.txt file contemplates compiling with several architectures (ARM included), but then cpu.h and fbow.h/cpp don't offer any alternative to compile under ARM64. Is there any easy way to enable this?

Thanks!

Compilation on OS X

Hi,

I try to compile on OS X but I have many errors:

fbow-master/src/./fbow.h:210:37: error: use of undeclared
identifier '__m256'
struct L2_avx_generic:public Lx<__m256,float,32>{
^
fbow-master/src/./fbow.h:210:53: error: expected class name
struct L2_avx_generic:public Lx<__m256,float,32>{
^
fbow-master/src/./fbow.h:211:34: error: unknown type name
'__m256'
inline float computeDist(__m256 *ptr){
^
fbow-master/src/./fbow.h:258:32: error: use of undeclared
identifier '__m256'
struct L2_avx_8w:public Lx<__m256,float,32> {
^
fbow-master/src/./fbow.h:258:49: error: expected class name
struct L2_avx_8w:public Lx<__m256,float,32> {
^
fbow-master/src/./fbow.h:260:34: error: unknown type name
'__m256'
inline float computeDist(__m256 *ptr){
^
fbow-master/src/./fbow.h:212:14: error: unknown type name
'__m256'
__m256 sum=_mm256_setzero_ps(), sub_mult;
...

Alos, DBOW2/3 works.

Any idea ?

Thanks

Query to FBOW

After creating vocabulary tree, how can I create a database for quering.

Can i still use this Project?

I just started investigating BoW-matchers today and don't have much experience with this technique. I saw that the last commit to this repo was 2 years ago.

So my issue is can i still use this project as is? DBoW2 had some commits in the meantime. Are the benefits over the original repo still there?

Different vocabularies generated from same data

I tested fbow on same data for several times. It is worth noticing that different instances operating on the same data generated different vocabularies, while dbow3 generated the exact same vocabulary. is this normal?

instead DBow

I will use fbow in the ORB-SLAM2 instead of DBow.but what the class should I use to replace the ORBVocabulary?and are there other precautions?

Is there a node's weight in orb_mur.fbow??

I try to apply FBOW instead of DBOW2 to my SLAM.

A runtime error occurs when transforming the ORB descriptor to calculate the bow vector from the image.

The place where the error occurs is the bn_info-> weight of line 384 of fbow / src / fbow.h.

A runtime error occurs when outputting the weight of the node.

So I wonder if there is weight in orb_mur.fbow file.

Vocabulary::transform features are of different size than the vocabulary ones

I'm trying to run image_matching, with ORB, and I'm getting this error. the output of the program:

voc desc name=orb Extracting features... reading image: C:\Users\Marco\Desktop\Datasets\KITTIColor\sequences\00\image_2_few_images\000000.png extracting features done detecting features Extracting features... reading image: C:\Users\Marco\Desktop\Datasets\KITTIColor\sequences\00\image_2_few_images\000001.png extracting features done detecting features Extracting features... reading image: C:\Users\Marco\Desktop\Datasets\KITTIColor\sequences\00\image_2_few_images\000002.png extracting features done detecting features features[i][0].type(): 0 - features[i][0].depth(): 0 - features[i][0].channels(): 1 features[i][0].rows: 2000 - features[i][0].cols: 32 Vocabulary::transform features are of a different size than the vocabulary ones

The offending line 79 of utils/image_matching.cpp:

vv = voc.transform(features[i][0]);

Information about the example vocabulary

Hello @rmsalinas @shinsumicco ,
When creating my own vocabulary I noticed that the weight of all nodes is the same (1) and that creating a BoW vector just counts the number of appearances (no tf or idf).
Using the data set the example vocab is apparently based on (Bovisa_2008-09-01) and taking a closer look at the resulting BoW Vectors, I tried to replicate the performance of the example vocab but was not able to get similar results For the vocabulary given in the vocabularies folder there seems to be some kind of weighting included.

For this reason, I wanted to ask how the example vocabulary was created (e.g. using fbow or by converting some existing vocab into fbow format) and what kind of weighting technique was used.
Adding this information would be helpful for anyone wanting to build their own vocabularies.

Information that would be helpful:

  • Which tool was used to create the vocabulary (fbow, dbow2/3, something else?)
  • Which image data set has been used and what was its resolution?
  • Have all images of this dataset been used or e.g. only every nth image?
  • How many keypoints have been extracted per image (500, 2000?)
  • How was the vocabulary size of K10L6 determined? Is there a good approach to come up with a well-suited vocabulary size?
  • Which weighting technique was used to give the words different weights?

Thank you very much in advance!

Query images from database

Wanted to check if there is an option to create a database from a set of images using an existing vocabulary and then query the database for matches with test images. As it is there in DBoW2/3.
Thank you for your time.

Compilation failure on the Raspberry Pi

It seems this library doesn't work on the raspberry pi, probably because it uses an arm7l architecture; which doesn't support AVX. Any chance this could be adjusted to support the Pi?
The library I'm attempting to use "ucoslam" which is a closed source library that imports this library, making it impossible to switch to DBOW2.

How to use float descriptor?

Hi! I have test your work,it's so great!
Now i want to build a float descriptor vocabulary,but how can i set the data type to 'CV_32FC1' ?I have found the function 'void Vocabulary::setParams(int aligment, int k, int desc_type, int desc_size, int nblocks, std::string desc_name)',but it is a private function.

Convert DBoW3 vocabulary to fbow

Hello,
I have a DBoW3 vocabulary and I want to convert it to fbow format to use with this repo, Does anyone knows how to do it? I really appreciate any suggestions and advice!

Tree parameters do not have any effect!

Hi,

I try playing around with the parameters (branch, depth) of the tree but they do not
really affect the results.

I expect to get higher precision by increasing both parameters but that is unfortunately not the case :(

the two "transform" method do not get the same fbow::fBow

`fbow::Vocabulary vocab;
vocab.readFromFile("my.fbow");

Mat descriptor1;
getdescriptor("mydescriptor",descriptor1);

fbow::fBow fbow1;
fbow::fBow2 bow1;
vocab.transform(descriptor1 , 5 , fbow1 , bow1);

fbow::fBow fbow2;
fbow2 = vocab.transform(descriptor1);`

i find that fbow1 and fbow2 is not the same result.And if i use feature2.score() method to any other fbow,it will always return 1.
i can't find the problem,could you help me?

does the vocabulary we should use depend on our data ?

Hello @rmsalinas @shinsumicco ,

I had to test DBoW2, DBoW3, and FBoW, and I didn't understand something important.
On DBoW2, a demo.cpp code has been provided with a dataset of 4 images, the first step is to retrieve the features, then create the vocabulary with these features, and see the score between each pair of images.

On FBoW, it's a little bit the same, except that a "vocabulary" file with the "Orb" descriptor was provided, so I used it directly to see the correspondence between each pair of images in my dataset which gave me pretty good results, but I also built my own vocabulary with my dataset, and I redid the test on my dataset, I get fairly good results (maybe less good than the first ones), and so my question is:

  • the exiting vocabulary, it was built with which image dataset?
  • the vocabulary to use, does it depend on our data? (I think not, since I tested my own dataset with the existing vocabulary, and it gave me good results)
  • To say that a vocabulary is rich and robust, should it be created with a huge dataset containing images from different places?
  • In addition, I would like to know what is the impact of the choice of L (depth/level of the tree), and of K (number of children of each node)

Thank you kindly for clarifying my ideas a little bit, and thank you for your codes which are very clean, and which will be used by a lot of people

Good luck for the future.

Compile error

Hi, i got the compile error below, do you have any advice? (Ubuntu 14.04 64bit, opencv3.2.)

And another question is about '* Not yet implemented indexing of images. '. Does this mean that it can not be used by ORB-SLAM for the moment (as it needs invert index from descriptor to image)?

Regards.

Scanning dependencies of target fbow
[ 12%] Building CXX object src/CMakeFiles/fbow.dir/fbow.cpp.o
In file included from /opt/opencv3.2/include/opencv2/core/mat.hpp:3518:0,
from /opt/opencv3.2/include/opencv2/core.hpp:59,
from /home/jp/Libraries/fbow/src/fbow.h:5,
from /home/jp/Libraries/fbow/src/fbow.cpp:1:
/opt/opencv3.2/include/opencv2/core/mat.inl.hpp: In instantiation of ‘const _Tp* cv::Mat::ptr(int) const [with _Tp = __vector(4) float]’:
/home/jp/Libraries/fbow/src/fbow.h:336:13: required from ‘fbow::fBow fbow::Vocabulary::_transform(const cv::Mat&) [with Computer = fbow::Vocabulary::L2_sse3_16w]’
/home/jp/Libraries/fbow/src/fbow.cpp:85:83: required from here
/opt/opencv3.2/include/opencv2/core/mat.inl.hpp:836:1: error: ‘const _Tp* cv::Mat::ptr(int) const [with _Tp = __vector(4) float]’ conflicts with a previous declaration
}
^
/opt/opencv3.2/include/opencv2/core/mat.inl.hpp:832:12: note: previous declaration ‘const _Tp* cv::Mat::ptr(int) const [with _Tp = __vector(8) float]’
const _Tp* Mat::ptr(int y) const
^
/opt/opencv3.2/include/opencv2/core/mat.inl.hpp:832:12: note: -fabi-version=6 (or =0) avoids this error with a change in mangling
In file included from /home/jp/Libraries/fbow/src/fbow.cpp:1:0:
/home/jp/Libraries/fbow/src/fbow.h: In instantiation of ‘T* fbow::Vocabulary::Block::getFeature(int) [with T = __vector(4) float]’:
/home/jp/Libraries/fbow/src/fbow.h:345:82: required from ‘fbow::fBow fbow::Vocabulary::_transform(const cv::Mat&) [with Computer = fbow::Vocabulary::L2_sse3_16w]’
/home/jp/Libraries/fbow/src/fbow.cpp:85:83: required from here
/home/jp/Libraries/fbow/src/fbow.h:155:125: error: ‘T* fbow::Vocabulary::Block::getFeature(int) [with T = __vector(4) float]’ conflicts with a previous declaration
template inline TgetFeature(int i){return (T) (_blockstart+_feature_off_start+i*_desc_size_bytes_wp);}
^
/home/jp/Libraries/fbow/src/fbow.h:155:40: note: previous declaration ‘T* fbow::Vocabulary::Block::getFeature(int) [with T = __vector(8) float]’
template inline TgetFeature(int i){return (T) (_blockstart+_feature_off_start+i*_desc_size_bytes_wp);}
^
/home/jp/Libraries/fbow/src/fbow.h:155:40: note: -fabi-version=6 (or =0) avoids this error with a change in mangling
make[2]: *** [src/CMakeFiles/fbow.dir/fbow.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/fbow.dir/all] Error 2
make: *** [all] Error 2

How to create a Superpoint vocabulary?

Hi, i am building a relocalization system using Superpoint deep features.

Can i just follow the steps in this repo, but use the 256 bit descriptor? Will this cause any issues? or will it 'just work?'

Thank you!

malloc max size error

I try to traning a big code book based on about 50000 vectors and each vector is a 4086 dimension float vector.
Meet error in convertIntoVoc->Voc.setParams()->AlignedAlloc()->.malloc() .
The _params._total_size may be larger than 1 billion and malloc function encontour segment fault.
How can I train such a big codebook ?

Compilation error on Ubuntu 16.04 (host machine: macbook pro)

When I tried to compile fbow, I got
error: inlining failed in call to always_inline '.............’: target specific option mismatch

So, I googled it and found a solution which simply add -msse4.1 to compile flag.

I think it should be considered in CMakefiles. So I just leave a short issue.

ORB-SLAM support

Hi, Does the words "Not yet implemented indexing of images" means that it can not support ORB-SLAM2, which needs invert index from descriptor to image, for the moment?

fbow::VocabularyCreator::create(),fbow::Vocabulary::saveToFile() no reference defined

When I try to link fbow in cmakefiles, and call VocabularyCreator::create(),fbow::Vocabulary::saveToFile() in the main function but it fails.

There is: set(FBOW_INCLUDE_DIRS "/usr/local/include") in my CMakeList.txt
set(FBOW_LIBS "/usr/local/lib/libfbow.so"). target_link_libraries( main ${FBOW_LIBS}).

The error shows: 'fbow::VocabularyCreator::create(fbow::Vocabulary&, std::vector<cv::Mat, std::allocatorcv::Mat > const&, std::string const&, fbow:: VocabularyCreator::Params)' undefined reference
feature_training_fbow.cpp:(.text.startup+0xd0b): undefined reference to 'fbow::Vocabulary::saveToFile(std::string const&)'

I want to know why something goes wrong?

some unexpected errors happened

Hi, When I set the k = 5 & L = 3, I find that the feature generated from the trained vocabulary has different length, and the length is even larger than the number of words..... I do not understand why this happens. Thank you ~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.