3#include <QtCore/QJsonArray>
4#include <QtCore/QJsonDocument>
5#include <QtCore/QJsonObject>
13 const QString &brand_,
14 const QString &model_,
21 bool fixedOrientation_,
22 double minTriggerInterval_,
23 const QString &deprecatedTranslatedName_)
24 : canonicalName(canonicalName_)
27 , sensorWidth(sensorWidth_)
28 , sensorHeight(sensorHeight_)
29 , imageWidth(imageWidth_)
30 , imageHeight(imageHeight_)
31 , focalLength(focalLength_)
32 , landscape(landscape_)
33 , fixedOrientation(fixedOrientation_)
34 , minTriggerInterval(minTriggerInterval_)
35 , deprecatedTranslatedName(deprecatedTranslatedName_)
37 qCDebug(CameraMetaDataLog) <<
this;
40CameraMetaData::~CameraMetaData()
42 qCDebug(CameraMetaDataLog) <<
this;
45QList<CameraMetaData*> CameraMetaData::parseCameraMetaData()
47 QList<CameraMetaData*> cameraList;
53 qCWarning(CameraMetaDataLog) <<
"Internal Error:" <<
errorString;
57 static const QList<JsonHelper::KeyValidateInfo> rootKeyInfoList = {
58 {
"cameraMetaData", QJsonValue::Array,
true }
65 static const QList<JsonHelper::KeyValidateInfo> cameraKeyInfoList = {
66 {
"canonicalName", QJsonValue::String,
true },
67 {
"brand", QJsonValue::String,
true },
68 {
"model", QJsonValue::String,
true },
69 {
"sensorWidth", QJsonValue::Double,
true },
70 {
"sensorHeight", QJsonValue::Double,
true },
71 {
"imageWidth", QJsonValue::Double,
true },
72 {
"imageHeight", QJsonValue::Double,
true },
73 {
"focalLength", QJsonValue::Double,
true },
74 {
"landscape", QJsonValue::Bool,
true },
75 {
"fixedOrientation", QJsonValue::Bool,
true },
76 {
"minTriggerInterval", QJsonValue::Double,
true },
77 {
"deprecatedTranslatedName", QJsonValue::String,
true },
79 const QJsonArray cameraInfo = jsonObject[
"cameraMetaData"].toArray();
80 for (
const QJsonValue &jsonValue : cameraInfo) {
81 if (!jsonValue.isObject()) {
82 qCWarning(CameraMetaDataLog) <<
"Entry in CameraMetaData array is not object";
86 const QJsonObject obj = jsonValue.toObject();
92 const QString canonicalName = obj[
"canonicalName"].toString();
93 const QString brand = obj[
"brand"].toString();
94 const QString model = obj[
"model"].toString();
95 const double sensorWidth = obj[
"sensorWidth"].toDouble();
96 const double sensorHeight = obj[
"sensorHeight"].toDouble();
97 const double imageWidth = obj[
"imageWidth"].toDouble();
98 const double imageHeight = obj[
"imageHeight"].toDouble();
99 const double focalLength = obj[
"focalLength"].toDouble();
100 const bool landscape = obj[
"landscape"].toBool();
101 const bool fixedOrientation = obj[
"fixedOrientation"].toBool();
102 const double minTriggerInterval = obj[
"minTriggerInterval"].toDouble();
103 const QString deprecatedTranslatedName = obj[
"deprecatedTranslatedName"].toString();
106 canonicalName, brand, model, sensorWidth, sensorHeight,
107 imageWidth, imageHeight, focalLength, landscape,
108 fixedOrientation, minTriggerInterval, deprecatedTranslatedName);
109 cameraList.append(metaData);
#define QGC_LOGGING_CATEGORY(name, categoryStr)
QJsonObject openInternalQGCJsonFile(const QString &jsonFilename, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString)
returned error string if validation fails
bool validateKeys(const QJsonObject &jsonObject, const QList< KeyValidateInfo > &keyInfo, QString &errorString)