Vocabulary.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2011-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef VOCABULARY_H_
29 #define VOCABULARY_H_
30 
31 #include <QtCore/QMultiMap>
32 #include <QtCore/QVector>
33 #include <opencv2/opencv.hpp>
34 
35 namespace find_object {
36 
37 class Vocabulary {
38 public:
39  Vocabulary();
40  virtual ~Vocabulary();
41 
42  void clear();
43  QMultiMap<int, int> addWords(const cv::Mat & descriptors, int objectId);
44  void update();
45  void search(const cv::Mat & descriptors, cv::Mat & results, cv::Mat & dists, int k);
46  int size() const {return indexedDescriptors_.rows + notIndexedDescriptors_.rows;}
47  int dim() const {return !indexedDescriptors_.empty()?indexedDescriptors_.cols:notIndexedDescriptors_.cols;}
48  int type() const {return !indexedDescriptors_.empty()?indexedDescriptors_.type():notIndexedDescriptors_.type();}
49  const QMultiMap<int, int> & wordToObjects() const {return wordToObjects_;}
50  const cv::Mat & indexedDescriptors() const {return indexedDescriptors_;}
51 
52  void save(QDataStream & streamSessionPtr) const;
53  void load(QDataStream & streamSessionPtr);
54  bool save(const QString & filename) const;
55  bool load(const QString & filename);
56 
57 private:
58  cv::flann::Index flannIndex_;
61  QMultiMap<int, int> wordToObjects_; // <wordId, ObjectId>
62  QVector<int> notIndexedWordIds_;
63 };
64 
65 } // namespace find_object
66 
67 #endif /* VOCABULARY_H_ */
filename
cv::Mat notIndexedDescriptors_
Definition: Vocabulary.h:60
void save(QDataStream &streamSessionPtr) const
Definition: Vocabulary.cpp:73
void load(QDataStream &streamSessionPtr)
Definition: Vocabulary.cpp:87
const cv::Mat & indexedDescriptors() const
Definition: Vocabulary.h:50
QVector< int > notIndexedWordIds_
Definition: Vocabulary.h:62
cv::flann::Index flannIndex_
Definition: Vocabulary.h:58
QMultiMap< int, int > addWords(const cv::Mat &descriptors, int objectId)
Definition: Vocabulary.cpp:148
void search(const cv::Mat &descriptors, cv::Mat &results, cv::Mat &dists, int k)
Definition: Vocabulary.cpp:371
QMultiMap< int, int > wordToObjects_
Definition: Vocabulary.h:61
const QMultiMap< int, int > & wordToObjects() const
Definition: Vocabulary.h:49


find_object_2d
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 19:22:26