Unverified Commit d2f97086 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8965 from DonLakeFlyer/CameraBrandModel

Plan: Camera brand/model support. Use canonical camera names in Plan files.
parents a8270a44 f0df0818
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "CameraMetaData.h" #include "CameraMetaData.h"
CameraMetaData::CameraMetaData(const QString& name, CameraMetaData::CameraMetaData(const QString& canonicalName,
const QString& brand,
const QString& model,
double sensorWidth, double sensorWidth,
double sensorHeight, double sensorHeight,
double imageWidth, double imageWidth,
...@@ -18,17 +20,21 @@ CameraMetaData::CameraMetaData(const QString& name, ...@@ -18,17 +20,21 @@ CameraMetaData::CameraMetaData(const QString& name,
bool landscape, bool landscape,
bool fixedOrientation, bool fixedOrientation,
double minTriggerInterval, double minTriggerInterval,
const QString& deprecatedTranslatedName,
QObject* parent) QObject* parent)
: QObject (parent) : QObject (parent)
, _name (name) , canonicalName (canonicalName)
, _sensorWidth (sensorWidth) , brand (brand)
, _sensorHeight (sensorHeight) , model (model)
, _imageWidth (imageWidth) , sensorWidth (sensorWidth)
, _imageHeight (imageHeight) , sensorHeight (sensorHeight)
, _focalLength (focalLength) , imageWidth (imageWidth)
, _landscape (landscape) , imageHeight (imageHeight)
, _fixedOrientation (fixedOrientation) , focalLength (focalLength)
, _minTriggerInterval (minTriggerInterval) , landscape (landscape)
, fixedOrientation (fixedOrientation)
, minTriggerInterval (minTriggerInterval)
, deprecatedTranslatedName (deprecatedTranslatedName)
{ {
} }
...@@ -17,7 +17,9 @@ class CameraMetaData : public QObject ...@@ -17,7 +17,9 @@ class CameraMetaData : public QObject
Q_OBJECT Q_OBJECT
public: public:
CameraMetaData(const QString& name, CameraMetaData(const QString& canonicalName,
const QString& brand,
const QString& model,
double sensorWidth, double sensorWidth,
double sensorHeight, double sensorHeight,
double imageWidth, double imageWidth,
...@@ -26,36 +28,37 @@ public: ...@@ -26,36 +28,37 @@ public:
bool landscape, bool landscape,
bool fixedOrientation, bool fixedOrientation,
double minTriggerInterval, double minTriggerInterval,
const QString& deprecatedTranslatedName,
QObject* parent = nullptr); QObject* parent = nullptr);
Q_PROPERTY(QString name READ name CONSTANT) ///< Camera name Q_PROPERTY(QString canonicalName MEMBER canonicalName CONSTANT)
Q_PROPERTY(double sensorWidth READ sensorWidth CONSTANT) ///< Sensor size in millimeters Q_PROPERTY(QString deprecatedTranslatedName MEMBER deprecatedTranslatedName CONSTANT)
Q_PROPERTY(double sensorHeight READ sensorHeight CONSTANT) ///< Sensor size in millimeters Q_PROPERTY(QString brand MEMBER brand CONSTANT)
Q_PROPERTY(double imageWidth READ imageWidth CONSTANT) ///< Image size in pixels Q_PROPERTY(QString model MEMBER model CONSTANT)
Q_PROPERTY(double imageHeight READ imageHeight CONSTANT) ///< Image size in pixels Q_PROPERTY(double sensorWidth MEMBER sensorWidth CONSTANT)
Q_PROPERTY(double focalLength READ focalLength CONSTANT) ///< Focal length in millimeters Q_PROPERTY(double sensorHeight MEMBER sensorHeight CONSTANT)
Q_PROPERTY(bool landscape READ landscape CONSTANT) ///< true: camera is in landscape orientation Q_PROPERTY(double imageWidth MEMBER imageWidth CONSTANT)
Q_PROPERTY(bool fixedOrientation READ fixedOrientation CONSTANT) ///< true: camera is in fixed orientation Q_PROPERTY(double imageHeight MEMBER imageHeight CONSTANT)
Q_PROPERTY(double minTriggerInterval READ minTriggerInterval CONSTANT) ///< Minimum time in seconds between each photo taken, 0 for not specified Q_PROPERTY(double focalLength MEMBER focalLength CONSTANT)
Q_PROPERTY(bool landscape MEMBER landscape CONSTANT)
Q_PROPERTY(bool fixedOrientation MEMBER fixedOrientation CONSTANT)
Q_PROPERTY(double minTriggerInterval MEMBER minTriggerInterval CONSTANT)
QString name (void) const { return _name; } QString canonicalName; ///< Canonical name saved in plan files. Not translated.
double sensorWidth (void) const { return _sensorWidth; } QString brand; ///< Camera brand. Used for grouping.
double sensorHeight (void) const { return _sensorHeight; } QString model; ///< Camerar model
double imageWidth (void) const { return _imageWidth; } double sensorWidth; ///< Sensor size in millimeters
double imageHeight (void) const { return _imageHeight; } double sensorHeight; ///< Sensor size in millimeters
double focalLength (void) const { return _focalLength; } double imageWidth; ///< Image size in pixels
bool landscape (void) const { return _landscape; } double imageHeight; ///< Image size in pixels
bool fixedOrientation (void) const { return _fixedOrientation; } double focalLength; ///< Focal length in millimeters
double minTriggerInterval (void) const { return _minTriggerInterval; } bool landscape; ///< true: camera is in landscape orientation
bool fixedOrientation; ///< true: camera is in fixed orientation
double minTriggerInterval; ///< Minimum time in seconds between each photo taken, 0 for not specified
private: /// In older builds camera names were incorrect marked for translation. This leads to plan files which have are language
QString _name; /// dependant which is not a good thing. Newer plan files use the canonical name which is not translated. In order to support
double _sensorWidth; /// loading older plan files we continue to include the incorrect translation so we can match against them as needed.
double _sensorHeight; /// Newly added CameraMetaData entries should leave this value empty.
double _imageWidth; QString deprecatedTranslatedName;
double _imageHeight;
double _focalLength;
bool _landscape;
bool _fixedOrientation;
double _minTriggerInterval;
}; };
...@@ -174,7 +174,7 @@ bool FirmwarePlugin::sendHomePositionToVehicle(void) ...@@ -174,7 +174,7 @@ bool FirmwarePlugin::sendHomePositionToVehicle(void)
return false; return false;
} }
QList<MAV_CMD> FirmwarePlugin::supportedMissionCommands(QGCMAVLink::VehicleClass_t vehicleClass) QList<MAV_CMD> FirmwarePlugin::supportedMissionCommands(QGCMAVLink::VehicleClass_t /* vehicleClass */)
{ {
// Generic supports all commands // Generic supports all commands
return QList<MAV_CMD>(); return QList<MAV_CMD>();
...@@ -336,356 +336,432 @@ const QVariantList& FirmwarePlugin::cameraList(const Vehicle*) ...@@ -336,356 +336,432 @@ const QVariantList& FirmwarePlugin::cameraList(const Vehicle*)
CameraMetaData* metaData; CameraMetaData* metaData;
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Canon S100 @ 5.2mm f/2"), // Canon S100 @ 5.2mm f/2
tr("Canon S100 PowerShot"), "Canon S100 PowerShot", // canonical name saved in plan file
7.6, // sensorWidth tr("Canon"), // brand
5.7, // sensorHeight tr("S100 PowerShot"), // model
4000, // imageWidth 7.6, // sensorWidth
3000, // imageHeight 5.7, // sensorHeight
5.2, // focalLength 4000, // imageWidth
true, // true: landscape orientation 3000, // imageHeight
false, // true: camera is fixed orientation 5.2, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Canon S100 PowerShot"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Canon EOS-M 22mm f/2"), //tr("Canon EOS-M 22mm f/2"),
tr("Canon EOS-M 22mm"), "Canon EOS-M 22mm",
22.3, // sensorWidth tr("Canon"),
14.9, // sensorHeight tr("EOS-M 22mm"),
5184, // imageWidth 22.3, // sensorWidth
3456, // imageHeight 14.9, // sensorHeight
22, // focalLength 5184, // imageWidth
true, // true: landscape orientation 3456, // imageHeight
false, // true: camera is fixed orientation 22, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Canon EOS-M 22mm"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Canon G9X @ 10.2mm f/2"), // Canon G9X @ 10.2mm f/2
tr("Canon G9 X PowerShot"), "Canon G9 X PowerShot",
13.2, // sensorWidth tr("Canon"),
8.8, // sensorHeight tr("G9 X PowerShot"),
5488, // imageWidth 13.2, // sensorWidth
3680, // imageHeight 8.8, // sensorHeight
10.2, // focalLength 5488, // imageWidth
true, // true: landscape orientation 3680, // imageHeight
false, // true: camera is fixed orientation 10.2, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Canon G9 X PowerShot"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Canon SX260 HS @ 4.5mm f/3.5"), // Canon SX260 HS @ 4.5mm f/3.5
tr("Canon SX260 HS PowerShot"), "Canon SX260 HS PowerShot",
6.17, // sensorWidth tr("Canon"),
4.55, // sensorHeight tr("SX260 HS PowerShot"),
4000, // imageWidth 6.17, // sensorWidth
3000, // imageHeight 4.55, // sensorHeight
4.5, // focalLength 4000, // imageWidth
true, // true: landscape orientation 3000, // imageHeight
false, // true: camera is fixed orientation 4.5, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Canon SX260 HS PowerShot"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("GoPro Hero 4"), "GoPro Hero 4",
6.17, // sensorWidth tr("GoPro"),
4.55, // sendsorHeight tr("Hero 4"),
4000, // imageWidth 6.17, // sensorWidth
3000, // imageHeight 4.55, // sendsorHeight
2.98, // focalLength 4000, // imageWidth
true, // landscape 3000, // imageHeight
false, // fixedOrientation 2.98, // focalLength
0, // minTriggerInterval true, // landscape
this); false, // fixedOrientation
0, // minTriggerInterval
tr("GoPro Hero 4"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Parrot Sequoia RGB"), "Parrot Sequioa RGB",
tr("Parrot Sequioa RGB"), tr("Parrot"),
6.17, // sensorWidth tr("Sequioa RGB"),
4.63, // sendsorHeight 6.17, // sensorWidth
4608, // imageWidth 4.63, // sendsorHeight
3456, // imageHeight 4608, // imageWidth
4.9, // focalLength 3456, // imageHeight
true, // landscape 4.9, // focalLength
false, // fixedOrientation true, // landscape
1, // minTriggerInterval false, // fixedOrientation
this); 1, // minTriggerInterval
tr("Parrot Sequioa RGB"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Parrot Sequoia Monochrome"), "Parrot Sequioa Monochrome",
tr("Parrot Sequioa Monochrome"), tr("Parrot"),
4.8, // sensorWidth tr("Sequioa Monochrome"),
3.6, // sendsorHeight 4.8, // sensorWidth
1280, // imageWidth 3.6, // sendsorHeight
960, // imageHeight 1280, // imageWidth
4.0, // focalLength 960, // imageHeight
true, // landscape 4.0, // focalLength
false, // fixedOrientation true, // landscape
0.8, // minTriggerInterval false, // fixedOrientation
this); 0.8, // minTriggerInterval
tr("Parrot Sequioa Monochrome"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("RedEdge"), "RedEdge",
4.8, // sensorWidth tr("RedEdge"),
3.6, // sendsorHeight tr("RedEdge"),
1280, // imageWidth 4.8, // sensorWidth
960, // imageHeight 3.6, // sendsorHeight
5.5, // focalLength 1280, // imageWidth
true, // landscape 960, // imageHeight
false, // fixedOrientation 5.5, // focalLength
0, // minTriggerInterval true, // landscape
this); false, // fixedOrientation
0, // minTriggerInterval
tr("RedEdge"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Ricoh GR II 18.3mm f/2.8"), // Ricoh GR II 18.3mm f/2.8
tr("Ricoh GR II"), "Ricoh GR II",
23.7, // sensorWidth tr("Ricoh"),
15.7, // sendsorHeight tr("GR II"),
4928, // imageWidth 23.7, // sensorWidth
3264, // imageHeight 15.7, // sendsorHeight
18.3, // focalLength 4928, // imageWidth
true, // landscape 3264, // imageHeight
false, // fixedOrientation 18.3, // focalLength
0, // minTriggerInterval true, // landscape
this); false, // fixedOrientation
0, // minTriggerInterval
tr("Ricoh GR II"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sentera Double 4K Sensor"), "Sentera Double 4K Sensor",
6.2, // sensorWidth tr("Sentera"),
4.65, // sendsorHeight tr("Double 4K Sensor"),
4000, // imageWidth 6.2, // sensorWidth
3000, // imageHeight 4.65, // sendsorHeight
5.4, // focalLength 4000, // imageWidth
true, // landscape 3000, // imageHeight
false, // fixedOrientation 5.4, // focalLength
0, // minTriggerInterval true, // landscape
this); false, // fixedOrientation
0, // minTriggerInterval
tr("Sentera Double 4K Sensor"),// SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sentera NDVI Single Sensor"), "Sentera NDVI Single Sensor",
4.68, // sensorWidth tr("Sentera"),
3.56, // sendsorHeight tr("NDVI Single Sensor"),
1248, // imageWidth 4.68, // sensorWidth
952, // imageHeight 3.56, // sendsorHeight
4.14, // focalLength 1248, // imageWidth
true, // landscape 952, // imageHeight
false, // fixedOrientation 4.14, // focalLength
0, // minTriggerInterval true, // landscape
this); false, // fixedOrientation
0, // minTriggerInterval
tr("Sentera NDVI Single Sensor"),// SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this);
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//-- http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-6000-body-kit#product_details_default //-- http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-6000-body-kit#product_details_default
//tr("Sony a6000 Sony 16mm f/2.8"), // Sony a6000 Sony 16mm f/2.8"
tr("Sony a6000 16mm"), "Sony a6000 16mm",
23.5, // sensorWidth tr("Sony"),
15.6, // sensorHeight tr("a6000 16mm"),
6000, // imageWidth 23.5, // sensorWidth
4000, // imageHeight 15.6, // sensorHeight
16, // focalLength 6000, // imageWidth
true, // true: landscape orientation 4000, // imageHeight
false, // true: camera is fixed orientation 16, // focalLength
2.0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
2.0, // minimum trigger interval
tr("Sony a6000 16mm"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sony a6300 Zeiss 21mm f/2.8"), "Sony a6300 Zeiss 21mm f/2.8",
23.5, // sensorWidth tr("Sony"),
15.6, // sensorHeight tr("a6300 Zeiss 21mm f/2.8"),
6000, // imageWidth 23.5, // sensorWidth
4000, // imageHeight 15.6, // sensorHeight
21, // focalLength 6000, // imageWidth
true, // true: landscape orientation 4000, // imageHeight
true, // true: camera is fixed orientation 21, // focalLength
2.0, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
2.0, // minimum trigger interval
tr("Sony a6300 Zeiss 21mm f/2.8"),// SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sony a6300 Sony 28mm f/2.0"), "Sony a6300 Sony 28mm f/2.0",
23.5, // sensorWidth tr("Sony"),
15.6, // sensorHeight tr("a6300 Sony 28mm f/2.0"),
6000, // imageWidth 23.5, // sensorWidth
4000, // imageHeight 15.6, // sensorHeight
28, // focalLength 6000, // imageWidth
true, // true: landscape orientation 4000, // imageHeight
true, // true: camera is fixed orientation 28, // focalLength
2.0, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
2.0, // minimum trigger interval
tr("Sony a6300 Sony 28mm f/2.0"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sony a7R II Zeiss 21mm f/2.8"), "Sony a7R II Zeiss 21mm f/2.8",
35.814, // sensorWidth tr("Sony"),
23.876, // sensorHeight tr("a7R II Zeiss 21mm f/2.8"),
7952, // imageWidth 35.814, // sensorWidth
5304, // imageHeight 23.876, // sensorHeight
21, // focalLength 7952, // imageWidth
true, // true: landscape orientation 5304, // imageHeight
true, // true: camera is fixed orientation 21, // focalLength
2.0, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
2.0, // minimum trigger interval
tr("Sony a7R II Zeiss 21mm f/2.8"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sony a7R II Sony 28mm f/2.0"), "Sony a7R II Sony 28mm f/2.0",
35.814, // sensorWidth tr("Sony"),
23.876, // sensorHeight tr("a7R II Sony 28mm f/2.0"),
7952, // imageWidth 35.814, // sensorWidth
5304, // imageHeight 23.876, // sensorHeight
28, // focalLength 7952, // imageWidth
true, // true: landscape orientation 5304, // imageHeight
true, // true: camera is fixed orientation 28, // focalLength
2.0, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
2.0, // minimum trigger interval
tr("Sony a7R II Sony 28mm f/2.0"),// SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sony DSC-QX30U @ 4.3mm f/3.5"), "Sony DSC-QX30U @ 4.3mm f/3.5",
7.82, // sensorWidth tr("Sony"),
5.865, // sensorHeight tr("DSC-QX30U @ 4.3mm f/3.5"),
5184, // imageWidth 7.82, // sensorWidth
3888, // imageHeight 5.865, // sensorHeight
4.3, // focalLength 5184, // imageWidth
true, // true: landscape orientation 3888, // imageHeight
false, // true: camera is fixed orientation 4.3, // focalLength
2.0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
2.0, // minimum trigger interval
tr("Sony DSC-QX30U @ 4.3mm f/3.5"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Sony DSC-RX0"), "Sony DSC-RX0",
13.2, // sensorWidth tr("Sony"),
8.8, // sensorHeight tr("DSC-RX0"),
4800, // imageWidth 13.2, // sensorWidth
3200, // imageHeight 8.8, // sensorHeight
7.7, // focalLength 4800, // imageWidth
true, // true: landscape orientation 3200, // imageHeight
false, // true: camera is fixed orientation 7.7, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Sony DSC-RX0"),// SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//-- http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-qx1-body-kit/specifications //-- http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-qx1-body-kit/specifications
//-- http://www.sony.com/electronics/camera-lenses/sel16f28/specifications //-- http://www.sony.com/electronics/camera-lenses/sel16f28/specifications
//tr("Sony ILCE-QX1 Sony 16mm f/2.8"), //tr("Sony ILCE-QX1 Sony 16mm f/2.8"),
tr("Sony ILCE-QX1"), "Sony ILCE-QX1",
23.2, // sensorWidth tr("Sony"),
15.4, // sensorHeight tr("ILCE-QX1"),
5456, // imageWidth 23.2, // sensorWidth
3632, // imageHeight 15.4, // sensorHeight
16, // focalLength 5456, // imageWidth
true, // true: landscape orientation 3632, // imageHeight
false, // true: camera is fixed orientation 16, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Sony ILCE-QX1"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//-- http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-qx1-body-kit/specifications //-- http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-qx1-body-kit/specifications
//tr("Sony NEX-5R Sony 20mm f/2.8"), // Sony NEX-5R Sony 20mm f/2.8"
tr("Sony NEX-5R 20mm"), "Sony NEX-5R 20mm",
23.2, // sensorWidth tr("Sony"),
15.4, // sensorHeight tr("NEX-5R 20mm"),
4912, // imageWidth 23.2, // sensorWidth
3264, // imageHeight 15.4, // sensorHeight
20, // focalLength 4912, // imageWidth
true, // true: landscape orientation 3264, // imageHeight
false, // true: camera is fixed orientation 20, // focalLength
1, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
1, // minimum trigger interval
tr("Sony NEX-5R 20mm"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
//tr("Sony RX100 II @ 10.4mm f/1.8"), // Sony RX100 II @ 10.4mm f/1.8
tr("Sony RX100 II 28mm"), "Sony RX100 II 28mm",
13.2, // sensorWidth tr("Sony"),
8.8, // sensorHeight tr("RX100 II 28mm"),
5472, // imageWidth 13.2, // sensorWidth
3648, // imageHeight 8.8, // sensorHeight
10.4, // focalLength 5472, // imageWidth
true, // true: landscape orientation 3648, // imageHeight
false, // true: camera is fixed orientation 10.4, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent false, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Sony RX100 II 28mm"),// SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Yuneec CGOET"), "Yuneec CGOET",
5.6405, // sensorWidth tr("Yuneec"),
3.1813, // sensorHeight tr("CGOET"),
1920, // imageWidth 5.6405, // sensorWidth
1080, // imageHeight 3.1813, // sensorHeight
3.5, // focalLength 1920, // imageWidth
true, // true: landscape orientation 1080, // imageHeight
true, // true: camera is fixed orientation 3.5, // focalLength
1.3, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
1.3, // minimum trigger interval
tr("Yuneec CGOET"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Yuneec E10T"), "Yuneec E10T",
5.6405, // sensorWidth tr("Yuneec"),
3.1813, // sensorHeight tr("E10T"),
1920, // imageWidth 5.6405, // sensorWidth
1080, // imageHeight 3.1813, // sensorHeight
23, // focalLength 1920, // imageWidth
true, // true: landscape orientation 1080, // imageHeight
true, // true: camera is fixed orientation 23, // focalLength
1.3, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
1.3, // minimum trigger interval
tr("Yuneec E10T"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Yuneec E50"), "Yuneec E50",
6.2372, // sensorWidth tr("Yuneec"),
4.7058, // sensorHeight tr("E50"),
4000, // imageWidth 6.2372, // sensorWidth
3000, // imageHeight 4.7058, // sensorHeight
7.2, // focalLength 4000, // imageWidth
true, // true: landscape orientation 3000, // imageHeight
true, // true: camera is fixed orientation 7.2, // focalLength
1.3, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
1.3, // minimum trigger interval
tr("Yuneec E50"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Yuneec E90"), "Yuneec E90",
13.3056, // sensorWidth tr("Yuneec"),
8.656, // sensorHeight tr("E90"),
5472, // imageWidth 13.3056, // sensorWidth
3648, // imageHeight 8.656, // sensorHeight
8.29, // focalLength 5472, // imageWidth
true, // true: landscape orientation 3648, // imageHeight
true, // true: camera is fixed orientation 8.29, // focalLength
1.3, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
1.3, // minimum trigger interval
tr("Yuneec E90"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData( metaData = new CameraMetaData(
tr("Flir Duo R"), "Flir Duo R",
160, // sensorWidth tr("Flir"),
120, // sensorHeight tr("Duo R"),
1920, // imageWidth 160, // sensorWidth
1080, // imageHeight 120, // sensorHeight
1.9, // focalLength 1920, // imageWidth
true, // true: landscape orientation 1080, // imageHeight
true, // true: camera is fixed orientation 1.9, // focalLength
0, // minimum trigger interval true, // true: landscape orientation
this); // parent true, // true: camera is fixed orientation
0, // minimum trigger interval
tr("Flir Duo R"), // SHOULD BE BLANK FOR NEWLY ADDED CAMERAS. Deprecated translation from older builds.
this); // parent
_cameraList.append(QVariant::fromValue(metaData)); _cameraList.append(QVariant::fromValue(metaData));
} }
......
{ {
"version": 1, "version": 1,
"fileType": "FactMetaData", "fileType": "FactMetaData",
"QGC.MetaData.Facts": "QGC.MetaData.Facts":
[ [
{ {
"name": "CameraName", "name": "CameraName",
"shortDesc": "Camera name.", "shortDesc": "Camera name.",
"type": "string", "type": "string",
"default": "Manual (no camera specs)" "default": "Manual (no camera specs)"
}, },
{ {
"name": "ValueSetIsDistance", "name": "ValueSetIsDistance",
"shortDesc": "Value specified is distance to surface.", "shortDesc": "Value specified is distance to surface.",
"type": "bool", "type": "bool",
"default": 1 "default": 1
}, },
{ {
"name": "DistanceToSurface", "name": "DistanceToSurface",
"shortDesc": "Distance vehicle is away from surface.", "shortDesc": "Distance vehicle is away from surface.",
"type": "double", "type": "double",
"min": 0.1, "min": 0.1,
"units": "m", "units": "m",
"decimalPlaces": 2, "decimalPlaces": 2,
"default": 50.0 "default": 50.0
}, },
{ {
"name": "ImageDensity", "name": "ImageDensity",
"shortDesc": "Image desity at surface.", "shortDesc": "Image desity at surface.",
"type": "double", "type": "double",
"min": 0, "min": 0,
"units": "cm/px", "units": "cm/px",
"decimalPlaces": 1, "decimalPlaces": 1,
"default": 1.2 "default": 1.2
}, },
{ {
"name": "FrontalOverlap", "name": "FrontalOverlap",
"shortDesc": "Amount of overlap between images in the forward facing direction.", "shortDesc": "Amount of overlap between images in the forward facing direction.",
"type": "double", "type": "double",
"decimalPlaces": 0, "decimalPlaces": 0,
"min": 0, "min": 0,
"max": 85, "max": 85,
"units": "%", "units": "%",
"default": 70 "default": 70
}, },
{ {
"name": "SideOverlap", "name": "SideOverlap",
"shortDesc": "Amount of overlap between images in the side facing direction.", "shortDesc": "Amount of overlap between images in the side facing direction.",
"type": "double", "type": "double",
"decimalPlaces": 0, "decimalPlaces": 0,
"min": 0, "min": 0,
"max": 85, "max": 85,
"units": "%", "units": "%",
"default": 70 "default": 70
}, },
{ {
"name": "AdjustedFootprintFrontal", "name": "AdjustedFootprintFrontal",
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
"decimalPlaces": 2, "decimalPlaces": 2,
"min": 0, "min": 0,
"units": "m", "units": "m",
"default": 25 "default": 25
}, },
{ {
"name": "AdjustedFootprintSide", "name": "AdjustedFootprintSide",
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
"decimalPlaces": 2, "decimalPlaces": 2,
"min": 0, "min": 0,
"units": "m", "units": "m",
"default": 25 "default": 25
} }
] ]
} }
...@@ -29,9 +29,7 @@ const char* CameraCalc::_jsonCameraSpecTypeKey = "CameraSpecType"; ...@@ -29,9 +29,7 @@ const char* CameraCalc::_jsonCameraSpecTypeKey = "CameraSpecType";
CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& settingsGroup, QObject* parent) CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& settingsGroup, QObject* parent)
: CameraSpec (settingsGroup, parent) : CameraSpec (settingsGroup, parent)
, _dirty (false) , _knownCameraList (masterController->controllerVehicle()->staticCameraList())
, _disableRecalc (false)
, _distanceToSurfaceRelative (true)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CameraCalc.FactMetaData.json"), this)) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CameraCalc.FactMetaData.json"), this))
, _cameraNameFact (settingsGroup, _metaDataMap[cameraNameName]) , _cameraNameFact (settingsGroup, _metaDataMap[cameraNameName])
, _valueSetIsDistanceFact (settingsGroup, _metaDataMap[valueSetIsDistanceName]) , _valueSetIsDistanceFact (settingsGroup, _metaDataMap[valueSetIsDistanceName])
...@@ -41,9 +39,6 @@ CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& se ...@@ -41,9 +39,6 @@ CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& se
, _sideOverlapFact (settingsGroup, _metaDataMap[sideOverlapName]) , _sideOverlapFact (settingsGroup, _metaDataMap[sideOverlapName])
, _adjustedFootprintSideFact (settingsGroup, _metaDataMap[adjustedFootprintSideName]) , _adjustedFootprintSideFact (settingsGroup, _metaDataMap[adjustedFootprintSideName])
, _adjustedFootprintFrontalFact (settingsGroup, _metaDataMap[adjustedFootprintFrontalName]) , _adjustedFootprintFrontalFact (settingsGroup, _metaDataMap[adjustedFootprintFrontalName])
, _imageFootprintSide (0)
, _imageFootprintFrontal (0)
, _knownCameraList (masterController->controllerVehicle()->staticCameraList())
{ {
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
...@@ -72,7 +67,18 @@ CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& se ...@@ -72,7 +67,18 @@ CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& se
connect(focalLength(), &Fact::rawValueChanged, this, &CameraCalc::_recalcTriggerDistance); connect(focalLength(), &Fact::rawValueChanged, this, &CameraCalc::_recalcTriggerDistance);
connect(landscape(), &Fact::rawValueChanged, this, &CameraCalc::_recalcTriggerDistance); connect(landscape(), &Fact::rawValueChanged, this, &CameraCalc::_recalcTriggerDistance);
// Build the brand list from known cameras
_cameraBrandList.append(xlatManualCameraName());
_cameraBrandList.append(xlatCustomCameraName());
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
CameraMetaData* cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (!_cameraBrandList.contains(cameraMetaData->brand)) {
_cameraBrandList.append(cameraMetaData->brand);
}
}
_cameraNameChanged(); _cameraNameChanged();
_setBrandModelFromCanonicalName(_cameraNameFact.rawValue().toString());
setDirty(false); setDirty(false);
} }
...@@ -93,48 +99,43 @@ void CameraCalc::_cameraNameChanged(void) ...@@ -93,48 +99,43 @@ void CameraCalc::_cameraNameChanged(void)
QString cameraName = _cameraNameFact.rawValue().toString(); QString cameraName = _cameraNameFact.rawValue().toString();
// Validate known camera name if (isManualCamera() || isCustomCamera()) {
bool foundKnownCamera = false; fixedOrientation()->setRawValue(false);
CameraMetaData* cameraMetaData = nullptr; minTriggerInterval()->setRawValue(0);
if (!isManualCamera() && !isCustomCamera()) { if (isManualCamera() && !valueSetIsDistance()->rawValue().toBool()) {
valueSetIsDistance()->setRawValue(true);
}
} else {
// Look for known camera
CameraMetaData* knownCameraMetaData = nullptr;
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) { for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>(); CameraMetaData* cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (cameraName == cameraMetaData->name()) { if (cameraName == cameraMetaData->canonicalName) {
foundKnownCamera = true; knownCameraMetaData = cameraMetaData;
break; break;
} }
} }
if (!foundKnownCamera) { if (!knownCameraMetaData) {
// This will cause another camera changed signal which will recurse back to this routine // Lookup failed. Force to custom as fallback.
_cameraNameFact.setRawValue(customCameraName()); // This will cause another camera changed signal which will recurse back into this routine
_cameraNameFact.setRawValue(canonicalCustomCameraName());
return; return;
} }
}
_disableRecalc = true; _disableRecalc = true;
if (foundKnownCamera) {
sensorWidth()->setRawValue (cameraMetaData->sensorWidth()); sensorWidth()->setRawValue (knownCameraMetaData->sensorWidth);
sensorHeight()->setRawValue (cameraMetaData->sensorHeight()); sensorHeight()->setRawValue (knownCameraMetaData->sensorHeight);
imageWidth()->setRawValue (cameraMetaData->imageWidth()); imageWidth()->setRawValue (knownCameraMetaData->imageWidth);
imageHeight()->setRawValue (cameraMetaData->imageHeight()); imageHeight()->setRawValue (knownCameraMetaData->imageHeight);
focalLength()->setRawValue (cameraMetaData->focalLength()); focalLength()->setRawValue (knownCameraMetaData->focalLength);
landscape()->setRawValue (cameraMetaData->landscape()); landscape()->setRawValue (knownCameraMetaData->landscape);
fixedOrientation()->setRawValue (cameraMetaData->fixedOrientation()); fixedOrientation()->setRawValue (knownCameraMetaData->fixedOrientation);
minTriggerInterval()->setRawValue (cameraMetaData->minTriggerInterval()); minTriggerInterval()->setRawValue (knownCameraMetaData->minTriggerInterval);
} else {
if (isManualCamera() || isCustomCamera()) { _disableRecalc = false;
// These values are unknown for these types
fixedOrientation()->setRawValue(false);
minTriggerInterval()->setRawValue(0);
if (isManualCamera() && !valueSetIsDistance()->rawValue().toBool()) {
valueSetIsDistance()->setRawValue(true);
}
} else {
qWarning() << "Internal Error: Not known camera, but now manual or custom either";
}
} }
_disableRecalc = false;
_recalcTriggerDistance(); _recalcTriggerDistance();
_adjustDistanceToSurfaceRelative(); _adjustDistanceToSurfaceRelative();
...@@ -212,9 +213,9 @@ bool CameraCalc::load(const QJsonObject& json, QString& errorString) ...@@ -212,9 +213,9 @@ bool CameraCalc::load(const QJsonObject& json, QString& errorString)
// _jsonCameraNameKey only set if CameraSpecKnown // _jsonCameraNameKey only set if CameraSpecKnown
int cameraSpec = v1Json[_jsonCameraSpecTypeKey].toInt(CameraSpecNone); int cameraSpec = v1Json[_jsonCameraSpecTypeKey].toInt(CameraSpecNone);
if (cameraSpec == CameraSpecCustom) { if (cameraSpec == CameraSpecCustom) {
v1Json[cameraNameName] = customCameraName(); v1Json[cameraNameName] = canonicalCustomCameraName();
} else if (cameraSpec == CameraSpecNone) { } else if (cameraSpec == CameraSpecNone) {
v1Json[cameraNameName] = manualCameraName(); v1Json[cameraNameName] = canonicalManualCameraName();
} }
v1Json.remove(_jsonCameraSpecTypeKey); v1Json.remove(_jsonCameraSpecTypeKey);
v1Json[JsonHelper::jsonVersionKey] = 1; v1Json[JsonHelper::jsonVersionKey] = 1;
...@@ -241,11 +242,15 @@ bool CameraCalc::load(const QJsonObject& json, QString& errorString) ...@@ -241,11 +242,15 @@ bool CameraCalc::load(const QJsonObject& json, QString& errorString)
_distanceToSurfaceRelative = v1Json[distanceToSurfaceRelativeName].toBool(); _distanceToSurfaceRelative = v1Json[distanceToSurfaceRelativeName].toBool();
_cameraNameFact.setRawValue (v1Json[cameraNameName].toString());
_adjustedFootprintSideFact.setRawValue (v1Json[adjustedFootprintSideName].toDouble()); _adjustedFootprintSideFact.setRawValue (v1Json[adjustedFootprintSideName].toDouble());
_adjustedFootprintFrontalFact.setRawValue (v1Json[adjustedFootprintFrontalName].toDouble()); _adjustedFootprintFrontalFact.setRawValue (v1Json[adjustedFootprintFrontalName].toDouble());
_distanceToSurfaceFact.setRawValue (v1Json[distanceToSurfaceName].toDouble()); _distanceToSurfaceFact.setRawValue (v1Json[distanceToSurfaceName].toDouble());
// We have to clean up camera names. Older builds incorrectly used translated the camera names in the persisted plan file.
// Newer builds use a canonical english camera name in plan files.
QString canonicalCameraName = _validCanonicalCameraName(v1Json[cameraNameName].toString());
_cameraNameFact.setRawValue(canonicalCameraName);
if (!isManualCamera()) { if (!isManualCamera()) {
QList<JsonHelper::KeyValidateInfo> keyInfoList2 = { QList<JsonHelper::KeyValidateInfo> keyInfoList2 = {
{ valueSetIsDistanceName, QJsonValue::Bool, true }, { valueSetIsDistanceName, QJsonValue::Bool, true },
...@@ -271,15 +276,29 @@ bool CameraCalc::load(const QJsonObject& json, QString& errorString) ...@@ -271,15 +276,29 @@ bool CameraCalc::load(const QJsonObject& json, QString& errorString)
_disableRecalc = false; _disableRecalc = false;
_setBrandModelFromCanonicalName(canonicalCameraName);
return true; return true;
} }
QString CameraCalc::customCameraName(void) QString CameraCalc::canonicalCustomCameraName(void)
{
// This string should NOT be translated
return "Custom Camera";
}
QString CameraCalc::canonicalManualCameraName(void)
{
// This string should NOT be translated
return "Manual (no camera specs)";
}
QString CameraCalc::xlatCustomCameraName(void)
{ {
return tr("Custom Camera"); return tr("Custom Camera");
} }
QString CameraCalc::manualCameraName(void) QString CameraCalc::xlatManualCameraName(void)
{ {
return tr("Manual (no camera specs)"); return tr("Manual (no camera specs)");
} }
...@@ -303,3 +322,122 @@ void CameraCalc::_setDirty(void) ...@@ -303,3 +322,122 @@ void CameraCalc::_setDirty(void)
{ {
setDirty(true); setDirty(true);
} }
void CameraCalc::setCameraBrand(const QString& cameraBrand)
{
// Note that cameraBrand can also be manual or custom camera
if (cameraBrand != _cameraBrand) {
QString newCameraName = cameraBrand;
_cameraBrand = cameraBrand;
_cameraModel.clear();
if (_cameraBrand != xlatManualCameraName() && _cameraBrand != xlatCustomCameraName()) {
CameraMetaData* firstCameraMetaData = nullptr;
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
firstCameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (firstCameraMetaData->brand == _cameraBrand) {
break;
}
}
newCameraName = firstCameraMetaData->canonicalName;
_cameraModel = firstCameraMetaData->model;
}
emit cameraBrandChanged();
emit cameraModelChanged();
_rebuildCameraModelList();
_cameraNameFact.setRawValue(newCameraName);
}
}
void CameraCalc::setCameraModel(const QString& cameraModel)
{
if (cameraModel != _cameraModel) {
_cameraModel = cameraModel;
emit cameraModelChanged();
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
CameraMetaData* cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (cameraMetaData->brand == _cameraBrand && cameraMetaData->model == _cameraModel) {
_cameraNameFact.setRawValue(cameraMetaData->canonicalName);
break;
}
}
}
}
void CameraCalc::_setBrandModelFromCanonicalName(const QString& cameraName)
{
_cameraBrand = cameraName;
_cameraModel.clear();
_cameraModelList.clear();
if (cameraName != canonicalManualCameraName() && cameraName != canonicalCustomCameraName()) {
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
CameraMetaData* cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (cameraMetaData->canonicalName == cameraName) {
_cameraBrand = cameraMetaData->brand;
_cameraModel = cameraMetaData->model;
break;
}
}
}
emit cameraBrandChanged();
emit cameraModelChanged();
_rebuildCameraModelList();
}
void CameraCalc::_rebuildCameraModelList(void)
{
_cameraModelList.clear();
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
CameraMetaData* cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (cameraMetaData->brand == _cameraBrand) {
_cameraModelList.append(cameraMetaData->model);
}
}
emit cameraModelListChanged();
}
void CameraCalc::_setCameraNameFromV3TransectLoad(const QString& cameraName)
{
// We don't recalc here since the rest of the camera values are already loaded from the json
_disableRecalc = true;
QString canonicalCameraName = _validCanonicalCameraName(cameraName);
_cameraNameFact.setRawValue(cameraName);
_disableRecalc = true;
_setBrandModelFromCanonicalName(canonicalCameraName);
}
QString CameraCalc::_validCanonicalCameraName(const QString& cameraName)
{
QString canonicalCameraName = cameraName;
if (canonicalCameraName != canonicalCustomCameraName() && canonicalCameraName != canonicalManualCameraName()) {
if (cameraName == xlatManualCameraName()) {
canonicalCameraName = canonicalManualCameraName();
} else if (cameraName == xlatCustomCameraName()) {
canonicalCameraName = canonicalCustomCameraName();
} else {
// Look for known camera
for (int cameraIndex=0; cameraIndex<_knownCameraList.count(); cameraIndex++) {
CameraMetaData* cameraMetaData = _knownCameraList[cameraIndex].value<CameraMetaData*>();
if (cameraName == cameraMetaData->canonicalName || cameraName == cameraMetaData->deprecatedTranslatedName) {
return cameraMetaData->canonicalName;
}
}
canonicalCameraName = canonicalCustomCameraName();
}
}
return canonicalCameraName;
}
...@@ -21,11 +21,14 @@ class CameraCalc : public CameraSpec ...@@ -21,11 +21,14 @@ class CameraCalc : public CameraSpec
public: public:
CameraCalc(PlanMasterController* masterController, const QString& settingsGroup, QObject* parent = nullptr); CameraCalc(PlanMasterController* masterController, const QString& settingsGroup, QObject* parent = nullptr);
Q_PROPERTY(QString customCameraName READ customCameraName CONSTANT) ///< Camera name for custom camera setting Q_PROPERTY(QString xlatCustomCameraName READ xlatCustomCameraName CONSTANT) ///< User visible camera name for custom camera setting
Q_PROPERTY(QString manualCameraName READ manualCameraName CONSTANT) ///< Camera name for manual camera setting Q_PROPERTY(QString xlatManualCameraName READ xlatManualCameraName CONSTANT) ///< User visible camera name for manual camera setting
Q_PROPERTY(bool isManualCamera READ isManualCamera NOTIFY isManualCameraChanged) Q_PROPERTY(bool isManualCamera READ isManualCamera NOTIFY isManualCameraChanged)
Q_PROPERTY(bool isCustomCamera READ isCustomCamera NOTIFY isCustomCameraChanged) Q_PROPERTY(bool isCustomCamera READ isCustomCamera NOTIFY isCustomCameraChanged)
Q_PROPERTY(Fact* cameraName READ cameraName CONSTANT) Q_PROPERTY(QString cameraBrand MEMBER _cameraBrand WRITE setCameraBrand NOTIFY cameraBrandChanged)
Q_PROPERTY(QString cameraModel MEMBER _cameraModel WRITE setCameraModel NOTIFY cameraModelChanged)
Q_PROPERTY(QStringList cameraBrandList MEMBER _cameraBrandList CONSTANT)
Q_PROPERTY(QStringList cameraModelList MEMBER _cameraModelList NOTIFY cameraModelListChanged)
Q_PROPERTY(Fact* valueSetIsDistance READ valueSetIsDistance CONSTANT) ///< true: distance specified, resolution calculated Q_PROPERTY(Fact* valueSetIsDistance READ valueSetIsDistance CONSTANT) ///< true: distance specified, resolution calculated
Q_PROPERTY(Fact* distanceToSurface READ distanceToSurface CONSTANT) ///< Distance to surface for image foot print calculation Q_PROPERTY(Fact* distanceToSurface READ distanceToSurface CONSTANT) ///< Distance to surface for image foot print calculation
Q_PROPERTY(Fact* imageDensity READ imageDensity CONSTANT) ///< Image density on surface (cm/px) Q_PROPERTY(Fact* imageDensity READ imageDensity CONSTANT) ///< Image density on surface (cm/px)
...@@ -46,10 +49,11 @@ public: ...@@ -46,10 +49,11 @@ public:
Q_PROPERTY(double imageFootprintSide READ imageFootprintSide NOTIFY imageFootprintSideChanged) ///< Size of image size side in meters Q_PROPERTY(double imageFootprintSide READ imageFootprintSide NOTIFY imageFootprintSideChanged) ///< Size of image size side in meters
Q_PROPERTY(double imageFootprintFrontal READ imageFootprintFrontal NOTIFY imageFootprintFrontalChanged) ///< Size of image size frontal in meters Q_PROPERTY(double imageFootprintFrontal READ imageFootprintFrontal NOTIFY imageFootprintFrontalChanged) ///< Size of image size frontal in meters
static QString customCameraName(void); static QString xlatCustomCameraName (void);
static QString manualCameraName(void); static QString xlatManualCameraName (void);
static QString canonicalCustomCameraName(void);
static QString canonicalManualCameraName(void);
Fact* cameraName (void) { return &_cameraNameFact; }
Fact* valueSetIsDistance (void) { return &_valueSetIsDistanceFact; } Fact* valueSetIsDistance (void) { return &_valueSetIsDistanceFact; }
Fact* distanceToSurface (void) { return &_distanceToSurfaceFact; } Fact* distanceToSurface (void) { return &_distanceToSurfaceFact; }
Fact* imageDensity (void) { return &_imageDensityFact; } Fact* imageDensity (void) { return &_imageDensityFact; }
...@@ -67,18 +71,22 @@ public: ...@@ -67,18 +71,22 @@ public:
const Fact* adjustedFootprintFrontal (void) const { return &_adjustedFootprintFrontalFact; } const Fact* adjustedFootprintFrontal (void) const { return &_adjustedFootprintFrontalFact; }
bool dirty (void) const { return _dirty; } bool dirty (void) const { return _dirty; }
bool isManualCamera (void) const { return _cameraNameFact.rawValue().toString() == manualCameraName(); } bool isManualCamera (void) const { return _cameraNameFact.rawValue().toString() == canonicalManualCameraName(); }
bool isCustomCamera (void) const { return _cameraNameFact.rawValue().toString() == customCameraName(); } bool isCustomCamera (void) const { return _cameraNameFact.rawValue().toString() == canonicalCustomCameraName(); }
double imageFootprintSide (void) const { return _imageFootprintSide; } double imageFootprintSide (void) const { return _imageFootprintSide; }
double imageFootprintFrontal (void) const { return _imageFootprintFrontal; } double imageFootprintFrontal (void) const { return _imageFootprintFrontal; }
bool distanceToSurfaceRelative (void) const { return _distanceToSurfaceRelative; } bool distanceToSurfaceRelative (void) const { return _distanceToSurfaceRelative; }
void setDirty (bool dirty); void setDirty (bool dirty);
void setDistanceToSurfaceRelative (bool distanceToSurfaceRelative); void setDistanceToSurfaceRelative (bool distanceToSurfaceRelative);
void setCameraBrand (const QString& cameraBrand);
void setCameraModel (const QString& cameraModel);
void save(QJsonObject& json) const; void save(QJsonObject& json) const;
bool load(const QJsonObject& json, QString& errorString); bool load(const QJsonObject& json, QString& errorString);
void _setCameraNameFromV3TransectLoad (const QString& cameraName);
static const char* cameraNameName; static const char* cameraNameName;
static const char* valueSetIsDistanceName; static const char* valueSetIsDistanceName;
static const char* distanceToSurfaceName; static const char* distanceToSurfaceName;
...@@ -96,6 +104,10 @@ signals: ...@@ -96,6 +104,10 @@ signals:
void distanceToSurfaceRelativeChanged (bool distanceToSurfaceRelative); void distanceToSurfaceRelativeChanged (bool distanceToSurfaceRelative);
void isManualCameraChanged (void); void isManualCameraChanged (void);
void isCustomCameraChanged (void); void isCustomCameraChanged (void);
void cameraBrandChanged (void);
void cameraModelChanged (void);
void cameraModelListChanged (void);
void updateCameraStats (void);
private slots: private slots:
void _recalcTriggerDistance (void); void _recalcTriggerDistance (void);
...@@ -104,9 +116,20 @@ private slots: ...@@ -104,9 +116,20 @@ private slots:
void _cameraNameChanged (void); void _cameraNameChanged (void);
private: private:
bool _dirty; void _setBrandModelFromCanonicalName (const QString& cameraName);
bool _disableRecalc; void _rebuildCameraModelList (void);
bool _distanceToSurfaceRelative; QString _validCanonicalCameraName (const QString& cameraName);
bool _dirty = false;
bool _disableRecalc = false;
QString _cameraBrand;
QString _cameraModel;
QStringList _cameraBrandList;
QStringList _cameraModelList;
bool _distanceToSurfaceRelative = true;
double _imageFootprintSide = 0;
double _imageFootprintFrontal = 0;
QVariantList _knownCameraList;
QMap<QString, FactMetaData*> _metaDataMap; QMap<QString, FactMetaData*> _metaDataMap;
...@@ -119,11 +142,6 @@ private: ...@@ -119,11 +142,6 @@ private:
SettingsFact _adjustedFootprintSideFact; SettingsFact _adjustedFootprintSideFact;
SettingsFact _adjustedFootprintFrontalFact; SettingsFact _adjustedFootprintFrontalFact;
double _imageFootprintSide;
double _imageFootprintFrontal;
QVariantList _knownCameraList;
// The following are deprecated usage and only included in order to convert older formats // The following are deprecated usage and only included in order to convert older formats
enum CameraSpecType { enum CameraSpecType {
......
...@@ -23,7 +23,7 @@ void CameraCalcTest::init(void) ...@@ -23,7 +23,7 @@ void CameraCalcTest::init(void)
_masterController = new PlanMasterController(this); _masterController = new PlanMasterController(this);
_controllerVehicle = _masterController->controllerVehicle(); _controllerVehicle = _masterController->controllerVehicle();
_cameraCalc = new CameraCalc(_masterController, "CameraCalcUnitTest" /* settingsGroup */, this); _cameraCalc = new CameraCalc(_masterController, "CameraCalcUnitTest" /* settingsGroup */, this);
_cameraCalc->cameraName()->setRawValue(_cameraCalc->customCameraName()); _cameraCalc->setCameraBrand(CameraCalc::canonicalCustomCameraName());
_cameraCalc->setDirty(false); _cameraCalc->setDirty(false);
_rgSignals[dirtyChangedIndex] = SIGNAL(dirtyChanged(bool)); _rgSignals[dirtyChangedIndex] = SIGNAL(dirtyChanged(bool));
...@@ -87,7 +87,7 @@ void CameraCalcTest::_testDirty(void) ...@@ -87,7 +87,7 @@ void CameraCalcTest::_testDirty(void)
QVERIFY(_cameraCalc->dirty()); QVERIFY(_cameraCalc->dirty());
_multiSpy->clearAllSignals(); _multiSpy->clearAllSignals();
_cameraCalc->cameraName()->setRawValue(_cameraCalc->manualCameraName()); _cameraCalc->setCameraBrand(CameraCalc::canonicalManualCameraName());
QVERIFY(_cameraCalc->dirty()); QVERIFY(_cameraCalc->dirty());
_multiSpy->clearAllSignals(); _multiSpy->clearAllSignals();
} }
......
...@@ -85,7 +85,7 @@ void StructureScanComplexItemTest::_initItem(void) ...@@ -85,7 +85,7 @@ void StructureScanComplexItemTest::_initItem(void)
mapPolygon->appendVertex(vertex); mapPolygon->appendVertex(vertex);
} }
_structureScanItem->cameraCalc()->cameraName()->setRawValue(CameraCalc::manualCameraName()); _structureScanItem->cameraCalc()->setCameraBrand(CameraCalc::canonicalManualCameraName());
_structureScanItem->layers()->setCookedValue(2); _structureScanItem->layers()->setCookedValue(2);
_structureScanItem->setDirty(false); _structureScanItem->setDirty(false);
......
...@@ -324,7 +324,7 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu ...@@ -324,7 +324,7 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu
_cameraCalc.adjustedFootprintFrontal()->setRawValue (complexObject[_jsonV3CameraTriggerDistanceKey].toDouble()); _cameraCalc.adjustedFootprintFrontal()->setRawValue (complexObject[_jsonV3CameraTriggerDistanceKey].toDouble());
if (manualGrid) { if (manualGrid) {
_cameraCalc.cameraName()->setRawValue(_cameraCalc.manualCameraName()); _cameraCalc.setCameraBrand(CameraCalc::canonicalManualCameraName());
} else { } else {
if (!complexObject.contains(_jsonV3CameraObjectKey)) { if (!complexObject.contains(_jsonV3CameraObjectKey)) {
errorString = tr("%1 but %2 object is missing").arg("manualGrid = false").arg("camera"); errorString = tr("%1 but %2 object is missing").arg("manualGrid = false").arg("camera");
...@@ -359,7 +359,6 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu ...@@ -359,7 +359,6 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu
return false; return false;
} }
_cameraCalc.cameraName()->setRawValue (cameraObject[_jsonV3CameraNameKey].toString());
_cameraCalc.landscape()->setRawValue (cameraObject[_jsonV3CameraOrientationLandscapeKey].toBool(true)); _cameraCalc.landscape()->setRawValue (cameraObject[_jsonV3CameraOrientationLandscapeKey].toBool(true));
_cameraCalc.frontalOverlap()->setRawValue (cameraObject[_jsonV3FrontalOverlapKey].toInt()); _cameraCalc.frontalOverlap()->setRawValue (cameraObject[_jsonV3FrontalOverlapKey].toInt());
_cameraCalc.sideOverlap()->setRawValue (cameraObject[_jsonV3SideOverlapKey].toInt()); _cameraCalc.sideOverlap()->setRawValue (cameraObject[_jsonV3SideOverlapKey].toInt());
...@@ -371,6 +370,7 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu ...@@ -371,6 +370,7 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu
_cameraCalc.minTriggerInterval()->setRawValue (cameraObject[_jsonV3CameraMinTriggerIntervalKey].toDouble(0)); _cameraCalc.minTriggerInterval()->setRawValue (cameraObject[_jsonV3CameraMinTriggerIntervalKey].toDouble(0));
_cameraCalc.imageDensity()->setRawValue (cameraObject[_jsonV3GroundResolutionKey].toDouble()); _cameraCalc.imageDensity()->setRawValue (cameraObject[_jsonV3GroundResolutionKey].toDouble());
_cameraCalc.fixedOrientation()->setRawValue (false); _cameraCalc.fixedOrientation()->setRawValue (false);
_cameraCalc._setCameraNameFromV3TransectLoad (cameraObject[_jsonV3CameraNameKey].toString());
} }
// Polygon shape // Polygon shape
......
...@@ -20,7 +20,7 @@ void TransectStyleComplexItemTest::init(void) ...@@ -20,7 +20,7 @@ void TransectStyleComplexItemTest::init(void)
_transectStyleItem = new TestTransectStyleItem(_masterController, this); _transectStyleItem = new TestTransectStyleItem(_masterController, this);
_transectStyleItem->cameraTriggerInTurnAround()->setRawValue(false); _transectStyleItem->cameraTriggerInTurnAround()->setRawValue(false);
_transectStyleItem->cameraCalc()->cameraName()->setRawValue(_transectStyleItem->cameraCalc()->customCameraName()); _transectStyleItem->cameraCalc()->setCameraBrand(CameraCalc::canonicalCustomCameraName());
_transectStyleItem->cameraCalc()->valueSetIsDistance()->setRawValue(true); _transectStyleItem->cameraCalc()->valueSetIsDistance()->setRawValue(true);
_transectStyleItem->cameraCalc()->distanceToSurface()->setRawValue(100); _transectStyleItem->cameraCalc()->distanceToSurface()->setRawValue(100);
_transectStyleItem->setDirty(false); _transectStyleItem->setDirty(false);
...@@ -192,9 +192,9 @@ void TransectStyleComplexItemTest::_testAltMode(void) ...@@ -192,9 +192,9 @@ void TransectStyleComplexItemTest::_testAltMode(void)
// Manual camera allows non-relative altitudes, validate that changing back to known // Manual camera allows non-relative altitudes, validate that changing back to known
// camera switches back to relative // camera switches back to relative
_transectStyleItem->cameraCalc()->cameraName()->setRawValue(_transectStyleItem->cameraCalc()->manualCameraName()); _transectStyleItem->cameraCalc()->setCameraBrand(CameraCalc::canonicalManualCameraName());
_transectStyleItem->cameraCalc()->setDistanceToSurfaceRelative(false); _transectStyleItem->cameraCalc()->setDistanceToSurfaceRelative(false);
_transectStyleItem->cameraCalc()->cameraName()->setRawValue(_transectStyleItem->cameraCalc()->customCameraName()); _transectStyleItem->cameraCalc()->setCameraBrand(CameraCalc::canonicalCustomCameraName());
QVERIFY(_transectStyleItem->cameraCalc()->distanceToSurfaceRelative()); QVERIFY(_transectStyleItem->cameraCalc()->distanceToSurfaceRelative());
// When you turn off terrain following mode make sure that the altitude mode changed back to relative altitudes // When you turn off terrain following mode make sure that the altitude mode changed back to relative altitudes
......
...@@ -17,42 +17,13 @@ Column { ...@@ -17,42 +17,13 @@ Column {
property var cameraCalc property var cameraCalc
property real _margin: ScreenTools.defaultFontPixelWidth / 2 property real _margin: ScreenTools.defaultFontPixelWidth / 2
property string _cameraName: cameraCalc.cameraName.value
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
property var _cameraList: [ ]
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
property var _vehicleCameraList: _vehicle ? _vehicle.staticCameraList : [] property var _vehicleCameraList: _vehicle ? _vehicle.staticCameraList : []
property bool _cameraComboFilled: false
readonly property int _gridTypeManual: 0 Component.onCompleted:{
readonly property int _gridTypeCustomCamera: 1 cameraBrandCombo.selectCurrentBrand()
readonly property int _gridTypeCamera: 2 cameraModelCombo.selectCurrentModel()
Component.onCompleted: _fillCameraCombo()
on_CameraNameChanged: _updateSelectedCamera()
function _fillCameraCombo() {
_cameraComboFilled = true
_cameraList.push(cameraCalc.manualCameraName)
_cameraList.push(cameraCalc.customCameraName)
for (var i=0; i<_vehicle.staticCameraList.length; i++) {
_cameraList.push(_vehicle.staticCameraList[i].name)
}
gridTypeCombo.model = _cameraList
_updateSelectedCamera()
}
function _updateSelectedCamera() {
if (_cameraComboFilled) {
var knownCameraIndex = gridTypeCombo.find(_cameraName)
if (knownCameraIndex !== -1) {
gridTypeCombo.currentIndex = knownCameraIndex
} else {
console.log("Internal error: Known camera not found", _cameraName)
gridTypeCombo.currentIndex = _gridTypeCustomCamera
}
}
} }
QGCPalette { id: qgcPal; colorGroupEnabled: true } QGCPalette { id: qgcPal; colorGroupEnabled: true }
...@@ -67,13 +38,41 @@ Column { ...@@ -67,13 +38,41 @@ Column {
spacing: _margin spacing: _margin
QGCComboBox { QGCComboBox {
id: gridTypeCombo id: cameraBrandCombo
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
model: _cameraList model: cameraCalc.cameraBrandList
currentIndex: -1 onModelChanged: selectCurrentBrand()
onActivated: cameraCalc.cameraName.value = gridTypeCombo.textAt(index) onActivated: cameraCalc.cameraBrand = currentText
} // QGCComboxBox
Connections {
target: cameraCalc
onCameraBrandChanged: cameraBrandCombo.selectCurrentBrand()
}
function selectCurrentBrand() {
currentIndex = cameraBrandCombo.find(cameraCalc.cameraBrand)
}
}
QGCComboBox {
id: cameraModelCombo
anchors.left: parent.left
anchors.right: parent.right
model: cameraCalc.cameraModelList
visible: !cameraCalc.isManualCamera && !cameraCalc.isCustomCamera
onModelChanged: selectCurrentModel()
onActivated: cameraCalc.cameraModel = currentText
Connections {
target: cameraCalc
onCameraModelChanged: cameraModelCombo.selectCurrentModel()
}
function selectCurrentModel() {
currentIndex = cameraModelCombo.find(cameraCalc.cameraModel)
}
}
// Camera based grid ui // Camera based grid ui
Column { Column {
...@@ -108,7 +107,7 @@ Column { ...@@ -108,7 +107,7 @@ Column {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
spacing: _margin spacing: _margin
visible: cameraCalc.isCustomCamera enabled: cameraCalc.isCustomCamera
RowLayout { RowLayout {
anchors.left: parent.left anchors.left: parent.left
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment