31 #include <QtCore/QFile> 32 #include <QtCore/QTextStream> 33 #include <QtCore/QFileInfo> 51 QMultiMap<int, QSize>::const_iterator iterSizes = info.
objDetectedSizes_.constBegin();
53 for(QMultiMap<int, QTransform>::const_iterator iter = info.
objDetected_.constBegin(); iter!= info.
objDetected_.end();)
57 while(iter != info.
objDetected_.constEnd() &&
id == iter.key())
59 QString name = QString(
"object_%1%2").arg(
id).arg(info.
objDetected_.count(
id)>1?QString(index++):
"");
60 detections.
append(name.toStdString());
63 homography.
append(iter.value().m11());
64 homography.
append(iter.value().m12());
65 homography.
append(iter.value().m13());
66 homography.
append(iter.value().m21());
67 homography.
append(iter.value().m22());
68 homography.
append(iter.value().m23());
69 homography.
append(iter.value().m31());
70 homography.
append(iter.value().m32());
71 homography.
append(iter.value().m33());
72 root[name.toStdString()][
"width"] = iterSizes.value().width();
73 root[name.toStdString()][
"height"] = iterSizes.value().height();
74 root[name.toStdString()][
"homography"] = homography;
75 root[name.toStdString()][
"inliers"] = iterInliers.value();
76 root[name.toStdString()][
"outliers"] = iterOutliers.value();
77 root[name.toStdString()][
"filepath"] = iterFilePaths.value().toStdString();
79 if(!iterFilePaths.value().isEmpty())
81 QFileInfo file(iterFilePaths.value());
82 filename=file.fileName();
84 root[name.toStdString()][
"filename"] = filename.toStdString();
93 root[
"objects"] = detections;
99 const QMap<int, QMultiMap<int, int> > & matches = info.
matches_;
100 for(QMap<
int, QMultiMap<int, int> >::const_iterator iter = matches.constBegin();
101 iter != matches.end();
104 QString name = QString(
"matches_%1").arg(iter.key());
105 root[name.toStdString()] = iter.value().
size();
106 matchesValues.
append(name.toStdString());
108 root[
"matches"] = matchesValues;
115 file.open(QIODevice::WriteOnly | QIODevice::Text);
116 QTextStream out(&file);
117 out << styledWriter.
write(root).c_str();
QMultiMap< int, QString > objDetectedFilePaths_
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
QMultiMap< int, QSize > objDetectedSizes_
QMap< int, QMultiMap< int, int > > matches_
QMultiMap< int, int > objDetectedInliersCount_
QMultiMap< int, QTransform > objDetected_
QMultiMap< int, int > objDetectedOutliersCount_
ULogger class and convenient macros.
static void write(const DetectionInfo &info, const QString &path)
Writes a Value in JSON format in a human friendly way.
ArrayIndex size() const
Number of values in array or object.
Value & append(const Value &value)
Append value to array at the end.