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


find_object_2d
Author(s): Mathieu Labbe
autogenerated on Mon Dec 12 2022 03:20:09