FindObject.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2011-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef FINDOBJECT_H_
00029 #define FINDOBJECT_H_
00030 
00031 #include "find_object/FindObjectExp.h" // DLL export/import defines
00032 
00033 #include "find_object/DetectionInfo.h"
00034 
00035 #include <QtCore/QObject>
00036 #include <QtCore/QString>
00037 #include <QtCore/QMap>
00038 #include <QtCore/QMultiMap>
00039 #include <QtCore/QPair>
00040 #include <QtCore/QVector>
00041 #include <QtGui/QTransform>
00042 #include <QtCore/QRect>
00043 #include <opencv2/opencv.hpp>
00044 #include <vector>
00045 
00046 namespace find_object {
00047 
00048 class ObjSignature;
00049 class Vocabulary;
00050 class KeypointDetector;
00051 class DescriptorExtractor;
00052 
00053 class FINDOBJECT_EXP FindObject : public QObject
00054 {
00055         Q_OBJECT;
00056 public:
00057         static void affineSkew(float tilt,
00058                                 float phi,
00059                                 const cv::Mat & image,
00060                                 cv::Mat & skewImage,
00061                                 cv::Mat & skewMask,
00062                                 cv::Mat & Ai);
00063 
00064 public:
00065         FindObject(QObject * parent = 0);
00066         virtual ~FindObject();
00067 
00068         bool loadSession(const QString & path);
00069         bool saveSession(const QString & path);
00070         bool isSessionModified() const {return sessionModified_;}
00071 
00072         int loadObjects(const QString & dirPath); // call updateObjects()
00073         const ObjSignature * addObject(const QString & filePath);
00074         const ObjSignature * addObject(const cv::Mat & image, int id=0, const QString & filename = QString());
00075         bool addObject(ObjSignature * obj); // take ownership when true is returned
00076         void removeObject(int id);
00077         void removeAllObjects();
00078 
00079         bool detect(const cv::Mat & image, find_object::DetectionInfo & info);
00080 
00081         void updateDetectorExtractor();
00082         void updateObjects(const QList<int> & ids = QList<int>());
00083         void updateVocabulary();
00084 
00085         const QMap<int, ObjSignature*> & objects() const {return objects_;}
00086         const Vocabulary * vocabulary() const {return vocabulary_;}
00087 
00088 public Q_SLOTS:
00089         void addObjectAndUpdate(const cv::Mat & image, int id=0, const QString & filename = QString());
00090         void removeObjectAndUpdate(int id);
00091         void detect(const cv::Mat & image); // emit objectsFound()
00092 
00093 Q_SIGNALS:
00094         void objectsFound(const find_object::DetectionInfo &);
00095 
00096 private:
00097         void clearVocabulary();
00098 
00099 private:
00100         QMap<int, ObjSignature*> objects_;
00101         Vocabulary * vocabulary_;
00102         QMap<int, cv::Mat> objectsDescriptors_;
00103         QMap<int, int> dataRange_; // <last id of object's descriptor, id>
00104         KeypointDetector * detector_;
00105         DescriptorExtractor * extractor_;
00106         bool sessionModified_;
00107 };
00108 
00109 } // namespace find_object
00110 
00111 #endif /* FINDOBJECT_H_ */


find_object_2d
Author(s): Mathieu Labbe
autogenerated on Fri Feb 12 2016 01:18:17