DetectionInfo.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 #ifndef DETECTIONINFO_H_
28 #define DETECTIONINFO_H_
29 
30 #include <QtCore/QMultiMap>
31 #include <QtGui/QTransform>
32 #include <QtCore/QSize>
33 #include <QtCore/QString>
34 #include <opencv2/features2d/features2d.hpp>
35 #include <vector>
36 
37 namespace find_object {
38 
40 {
41 public:
42  enum TimeStamp{
51  };
61  };
62 
63 public:
67  {}
68 
69 public:
70  // Those maps have the same size
71  QMultiMap<int, QTransform> objDetected_;
72  QMultiMap<int, QSize> objDetectedSizes_; // Object ID <width, height> match the number of detected objects
73  QMultiMap<int, QString > objDetectedFilePaths_; // Object ID <filename> match the number of detected objects
74  QMultiMap<int, int> objDetectedInliersCount_; // ObjectID <count> match the number of detected objects
75  QMultiMap<int, int> objDetectedOutliersCount_; // ObjectID <count> match the number of detected objects
76  QMultiMap<int, QMultiMap<int, int> > objDetectedInliers_; // ObjectID Map< ObjectDescriptorIndex, SceneDescriptorIndex >, match the number of detected objects
77  QMultiMap<int, QMultiMap<int, int> > objDetectedOutliers_; // ObjectID Map< ObjectDescriptorIndex, SceneDescriptorIndex >, match the number of detected objects
78 
79  QMap<TimeStamp, float> timeStamps_;
80  std::vector<cv::KeyPoint> sceneKeypoints_;
82  QMultiMap<int, int> sceneWords_;
83  QMap<int, QMultiMap<int, int> > matches_; // ObjectID Map< ObjectDescriptorIndex, SceneDescriptorIndex >, match the number of objects
84 
85  // Those maps have the same size
86  QMultiMap<int, QMultiMap<int, int> > rejectedInliers_; // ObjectID Map< ObjectDescriptorIndex, SceneDescriptorIndex >
87  QMultiMap<int, QMultiMap<int, int> > rejectedOutliers_; // ObjectID Map< ObjectDescriptorIndex, SceneDescriptorIndex >
88  QMultiMap<int, RejectedCode> rejectedCodes_; // ObjectID rejected code
89 
92 };
93 
94 inline QDataStream & operator<<(QDataStream &out, const DetectionInfo & info)
95 {
96  out << quint32(info.objDetected_.size());
97 
98  QMultiMap<int, int>::const_iterator iterInliers = info.objDetectedInliersCount_.constBegin();
99  QMultiMap<int, int>::const_iterator iterOutliers = info.objDetectedOutliersCount_.constBegin();
100  QMultiMap<int, QSize>::const_iterator iterSizes = info.objDetectedSizes_.constBegin();
101  QMultiMap<int, QString>::const_iterator iterFilenames = info.objDetectedFilePaths_.constBegin();
102  for(QMultiMap<int, QTransform>::const_iterator iter=info.objDetected_.constBegin();
103  iter!=info.objDetected_.constEnd();
104  ++iter)
105  {
106  // ID
107  out << iter.key();
108 
109  // Size
110  out << iterSizes.value();
111 
112  // Transform
113  out << iter.value();
114 
115  // Filename
116  out << iterFilenames.value();
117 
118  // inliers and outliers count
119  out << iterInliers.value();
120  out << iterOutliers.value();
121 
122  ++iterInliers;
123  ++iterOutliers;
124  ++iterSizes;
125  ++iterFilenames;
126  }
127  return out;
128 }
129 
130 inline QDataStream & operator>>(QDataStream &in, DetectionInfo & info)
131 {
132  QDataStream::Status oldStatus = in.status();
133  in.resetStatus();
134  info = DetectionInfo();
135 
136  quint32 n;
137  in >> n;
138 
139  for (quint32 i = 0; i < n; ++i) {
140  if (in.status() != QDataStream::Ok)
141  break;
142 
143  int id;
144  QSize size;
145  QTransform homography;
146  QString filename;
147  int inliers, outliers;
148  in >> id >> size >> homography >> filename >> inliers >> outliers;
149  info.objDetected_.insert(id, homography);
150  info.objDetectedSizes_.insert(id, size);
151  info.objDetectedFilePaths_.insert(id, filename);
152  info.objDetectedInliersCount_.insert(id, inliers);
153  info.objDetectedOutliersCount_.insert(id, outliers);
154  }
155  if (in.status() != QDataStream::Ok)
156  info = DetectionInfo();
157  if (oldStatus != QDataStream::Ok)
158  in.setStatus(oldStatus);
159  return in;
160 }
161 
162 } // namespace find_object
163 
164 #endif /* DETECTIONINFO_H_ */
filename
QMultiMap< int, QString > objDetectedFilePaths_
Definition: DetectionInfo.h:73
QDataStream & operator>>(QDataStream &in, DetectionInfo &info)
QDataStream & operator<<(QDataStream &out, const DetectionInfo &info)
Definition: DetectionInfo.h:94
std::vector< cv::KeyPoint > sceneKeypoints_
Definition: DetectionInfo.h:80
QMultiMap< int, QSize > objDetectedSizes_
Definition: DetectionInfo.h:72
QMultiMap< int, RejectedCode > rejectedCodes_
Definition: DetectionInfo.h:88
QMap< int, QMultiMap< int, int > > matches_
Definition: DetectionInfo.h:83
QMultiMap< int, int > objDetectedInliersCount_
Definition: DetectionInfo.h:74
QMap< TimeStamp, float > timeStamps_
Definition: DetectionInfo.h:79
QMultiMap< int, QTransform > objDetected_
Definition: DetectionInfo.h:71
QMultiMap< int, QMultiMap< int, int > > rejectedInliers_
Definition: DetectionInfo.h:86
QMultiMap< int, QMultiMap< int, int > > objDetectedInliers_
Definition: DetectionInfo.h:76
QMultiMap< int, int > objDetectedOutliersCount_
Definition: DetectionInfo.h:75
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
QMultiMap< int, int > sceneWords_
Definition: DetectionInfo.h:82
QMultiMap< int, QMultiMap< int, int > > rejectedOutliers_
Definition: DetectionInfo.h:87
QMultiMap< int, QMultiMap< int, int > > objDetectedOutliers_
Definition: DetectionInfo.h:77


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