FindObject.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 FINDOBJECT_H_
29 #define FINDOBJECT_H_
30 
31 #include "find_object/FindObjectExp.h" // DLL export/import defines
32 
34 
35 #include <QtCore/QObject>
36 #include <QtCore/QString>
37 #include <QtCore/QMap>
38 #include <QtCore/QMultiMap>
39 #include <QtCore/QPair>
40 #include <QtCore/QVector>
41 #include <QtGui/QTransform>
42 #include <QtCore/QRect>
43 #include <opencv2/opencv.hpp>
44 #include <vector>
45 
46 namespace find_object {
47 
48 class ObjSignature;
49 class Vocabulary;
50 class Feature2D;
51 
52 class FINDOBJECT_EXP FindObject : public QObject
53 {
54  Q_OBJECT;
55 public:
56  static void affineSkew(float tilt,
57  float phi,
58  const cv::Mat & image,
59  cv::Mat & skewImage,
60  cv::Mat & skewMask,
61  cv::Mat & Ai);
62 
63 public:
64  FindObject(bool keepImagesInRAM_ = true, QObject * parent = 0);
65  virtual ~FindObject();
66 
67  bool loadSession(const QString & path);
68  bool saveSession(const QString & path);
69  bool isSessionModified() const {return sessionModified_;}
70 
71  bool saveVocabulary(const QString & filePath) const;
72  bool loadVocabulary(const QString & filePath);
73 
74  int loadObjects(const QString & dirPath, bool recursive = false); // call updateObjects()
75  const ObjSignature * addObject(const QString & filePath);
76  const ObjSignature * addObject(const cv::Mat & image, int id=0, const QString & filePath = QString());
77  bool addObject(ObjSignature * obj); // take ownership when true is returned
78  void removeObject(int id);
79  void removeAllObjects();
80 
81  bool detect(const cv::Mat & image, find_object::DetectionInfo & info) const;
82 
83  void updateDetectorExtractor();
84  void updateObjects(const QList<int> & ids = QList<int>());
85  void updateVocabulary(const QList<int> & ids = QList<int>());
86 
87  const QMap<int, ObjSignature*> & objects() const {return objects_;}
88  const Vocabulary * vocabulary() const {return vocabulary_;}
89 
90 public Q_SLOTS:
91  void addObjectAndUpdate(const cv::Mat & image, int id=0, const QString & filePath = QString());
92  void removeObjectAndUpdate(int id);
93  void detect(const cv::Mat & image); // emit objectsFound()
94 
95 Q_SIGNALS:
96  void objectsFound(const find_object::DetectionInfo &);
97 
98 private:
99  void clearVocabulary();
100 
101 private:
102  QMap<int, ObjSignature*> objects_;
104  QMap<int, cv::Mat> objectsDescriptors_;
105  QMap<int, int> dataRange_; // <last id of object's descriptor, id>
110 };
111 
112 } // namespace find_object
113 
114 #endif /* FINDOBJECT_H_ */
bool isSessionModified() const
Definition: FindObject.h:69
QMap< int, cv::Mat > objectsDescriptors_
Definition: FindObject.h:104
#define FINDOBJECT_EXP
Definition: FindObjectExp.h:38
const QMap< int, ObjSignature * > & objects() const
Definition: FindObject.h:87
Feature2D * extractor_
Definition: FindObject.h:107
QMap< int, ObjSignature * > objects_
Definition: FindObject.h:102
Vocabulary * vocabulary_
Definition: FindObject.h:103
const Vocabulary * vocabulary() const
Definition: FindObject.h:88
QMap< int, int > dataRange_
Definition: FindObject.h:105


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