00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef DETECTIONINFO_H_
00028 #define DETECTIONINFO_H_
00029
00030 #include <QtCore/QMultiMap>
00031 #include <QtGui/QTransform>
00032 #include <QtCore/QSize>
00033 #include <QtCore/QString>
00034 #include <opencv2/features2d/features2d.hpp>
00035 #include <vector>
00036
00037 namespace find_object {
00038
00039 class DetectionInfo
00040 {
00041 public:
00042 enum TimeStamp{
00043 kTimeKeypointDetection,
00044 kTimeDescriptorExtraction,
00045 kTimeSkewAffine,
00046 kTimeIndexing,
00047 kTimeMatching,
00048 kTimeHomography,
00049 kTimeTotal
00050 };
00051 enum RejectedCode{
00052 kRejectedUndef,
00053 kRejectedLowMatches,
00054 kRejectedLowInliers,
00055 kRejectedSuperposed,
00056 kRejectedAllInliers,
00057 kRejectedNotValid,
00058 kRejectedCornersOutside,
00059 kRejectedByAngle
00060 };
00061
00062 public:
00063 DetectionInfo() :
00064 minMatchedDistance_(-1),
00065 maxMatchedDistance_(-1)
00066 {}
00067
00068 public:
00069
00070 QMultiMap<int, QTransform> objDetected_;
00071 QMultiMap<int, QSize> objDetectedSizes_;
00072 QMultiMap<int, QString > objDetectedFilenames_;
00073 QMultiMap<int, int> objDetectedInliersCount_;
00074 QMultiMap<int, int> objDetectedOutliersCount_;
00075 QMultiMap<int, QMultiMap<int, int> > objDetectedInliers_;
00076 QMultiMap<int, QMultiMap<int, int> > objDetectedOutliers_;
00077
00078 QMap<TimeStamp, float> timeStamps_;
00079 std::vector<cv::KeyPoint> sceneKeypoints_;
00080 cv::Mat sceneDescriptors_;
00081 QMultiMap<int, int> sceneWords_;
00082 QMap<int, QMultiMap<int, int> > matches_;
00083
00084
00085 QMultiMap<int, QMultiMap<int, int> > rejectedInliers_;
00086 QMultiMap<int, QMultiMap<int, int> > rejectedOutliers_;
00087 QMultiMap<int, RejectedCode> rejectedCodes_;
00088
00089 float minMatchedDistance_;
00090 float maxMatchedDistance_;
00091 };
00092
00093 inline QDataStream & operator<<(QDataStream &out, const DetectionInfo & info)
00094 {
00095 out << quint32(info.objDetected_.size());
00096
00097 QMultiMap<int, int>::const_iterator iterInliers = info.objDetectedInliersCount_.constBegin();
00098 QMultiMap<int, int>::const_iterator iterOutliers = info.objDetectedOutliersCount_.constBegin();
00099 QMultiMap<int, QSize>::const_iterator iterSizes = info.objDetectedSizes_.constBegin();
00100 QMultiMap<int, QString>::const_iterator iterFilenames = info.objDetectedFilenames_.constBegin();
00101 for(QMultiMap<int, QTransform>::const_iterator iter=info.objDetected_.constBegin();
00102 iter!=info.objDetected_.constEnd();
00103 ++iter)
00104 {
00105
00106 out << iter.key();
00107
00108
00109 out << iterSizes.value();
00110
00111
00112 out << iter.value();
00113
00114
00115 out << iterFilenames.value();
00116
00117
00118 out << iterInliers.value();
00119 out << iterOutliers.value();
00120
00121 ++iterInliers;
00122 ++iterOutliers;
00123 ++iterSizes;
00124 ++iterFilenames;
00125 }
00126 return out;
00127 }
00128
00129 inline QDataStream & operator>>(QDataStream &in, DetectionInfo & info)
00130 {
00131 QDataStream::Status oldStatus = in.status();
00132 in.resetStatus();
00133 info = DetectionInfo();
00134
00135 quint32 n;
00136 in >> n;
00137
00138 for (quint32 i = 0; i < n; ++i) {
00139 if (in.status() != QDataStream::Ok)
00140 break;
00141
00142 int id;
00143 QSize size;
00144 QTransform homography;
00145 QString filename;
00146 int inliers, outliers;
00147 in >> id >> size >> homography >> filename >> inliers >> outliers;
00148 info.objDetected_.insert(id, homography);
00149 info.objDetectedSizes_.insert(id, size);
00150 info.objDetectedFilenames_.insert(id, filename);
00151 info.objDetectedInliersCount_.insert(id, inliers);
00152 info.objDetectedOutliersCount_.insert(id, outliers);
00153 }
00154 if (in.status() != QDataStream::Ok)
00155 info = DetectionInfo();
00156 if (oldStatus != QDataStream::Ok)
00157 in.setStatus(oldStatus);
00158 return in;
00159 }
00160
00161 }
00162
00163 #endif