QGC -- 配置相机参数数据流说明(1)

一、相关配置文件及对应画面
1.界面GeneralSettings.qml
在这里插入图片描述
2.Video.SettingsGroup.json对应界面如下:

{
    "name":             "VideoSource",
    "shortDescription": "Video source",
    "longDescription":  "Source for video. UDP, TCP, RTSP and UVC Cameras may be supported depending on Vehicle and ground station version.",
    "type":             "string",
    "defaultValue":     ""
},
{
    "name":             "VideoUDPPort",
    "shortDescription": "Video UDP Port",
    "longDescription":  "UDP port to bind to for video stream.",
    "type":             "uint16",
    "min":              1025,
    "defaultValue":     5600
},

在这里插入图片描述
3.相机配置参数写到QGroundControl.ini配置文件

[General]
AudioMuted=true
BaseDeviceFontPointSize=13
DroneConnectionTimeout=5
MaxDiskCache=1024
MaxMemoryCache=128
SavePath=/home/xt/\x6587\x6863/QGroundControl
SettingsVersion=7
StreamEnabled=true
VideoRTSPUrl=rtsp://127.0.0.1:8554/
VideoSource=UDP Video Stream
VideoUDPPort=5600
VirtualTabletJoystick=false
VisibleWidgets=
_geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\x41\0\0\0\x34\0\0\x4@\0\0\x2\x8b\0\0\0\x41\0\0\0P\0\0\x4@\0\0\x2\x8b\0\0\0\0\0\0\0\0\x6\x8e)

二、程序片段说明
GeneralSettings.qml

Row {
                            spacing:    ScreenTools.defaultFontPixelWidth
                            visible:    QGroundControl.settingsManager.videoSettings.videoSource.visible
                            QGCLabel {
                                text:               qsTr("Video Source:")
                                width:              _labelWidth
                                anchors.verticalCenter: parent.verticalCenter
                            }
                            FactComboBox {
                                id:         videoSource
                                width:      _editFieldWidth
                                indexModel: false
                                fact:       QGroundControl.settingsManager.videoSettings.videoSource
                                anchors.verticalCenter: parent.verticalCenter
                            }
                        }
                        Row {
                            spacing:    ScreenTools.defaultFontPixelWidth
                            visible:    QGroundControl.settingsManager.videoSettings.udpPort.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 1
                            QGCLabel {
                                text:               qsTr("UDP Port:")
                                width:              _labelWidth
                                anchors.verticalCenter: parent.verticalCenter
                            }
                            FactTextField {
                                width:              _editFieldWidth
                                fact:               QGroundControl.settingsManager.videoSettings.udpPort
                                anchors.verticalCenter: parent.verticalCenter
                            }
                        }

对QGroundControl.settingsManager.videoSettings.videoSource说明

Fact* VideoSettings::videoSource(void)
{
    if (!_videoSourceFact) {
        _videoSourceFact = _createSettingsFact(videoSourceName);
        connect(_videoSourceFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
    }
    return _videoSourceFact;
}
const char* VideoSettings::videoSourceName =        "VideoSource";

SettingsGroup::SettingsGroup(const QString& name, const QString& settingsGroup, QObject* parent)
    : QObject(parent)
    , _name(name)
    , _settingsGroup(settingsGroup)
    , _visible(qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(name))
{
    QString jsonNameFormat(":/json/%1.SettingsGroup.json");
     ///home/xt/GDU/protocol3/qgroundcontrol/src/Settings  根据传进来值创建json
    _nameToMetaDataMap = FactMetaData::createMapFromJsonFile(jsonNameFormat.arg(name), this);//读取json文件--》json对象---》createFromJsonObject
}

SettingsFact* SettingsGroup::_createSettingsFact(const QString& name)
{
    return new SettingsFact(_settingsGroup, _nameToMetaDataMap[name], this);
}
VideoSettings::VideoSettings(QObject* parent)
    : SettingsGroup(videoSettingsGroupName, QString() /* root settings group */, parent)
const char* VideoSettings::videoSettingsGroupName = "Video";
SettingsFact::SettingsFact(QString settingGroup, FactMetaData* metaData, QObject* parent)
    : Fact(0, metaData->name(), metaData->type(), parent)
    , _settingGroup(settingGroup)
    , _visible(true)
{
    QSettings settings;

    if (!_settingGroup.isEmpty()) {
        settings.beginGroup(_settingGroup);
    }

    // Allow core plugin a chance to override the default value
    _visible = qgcApp()->toolbox()->corePlugin()->adjustSettingMetaData(*metaData);
    setMetaData(metaData);

    QVariant rawDefaultValue = metaData->rawDefaultValue();
    if (_visible) {
        QVariant typedValue;
        QString errorString;
        metaData->convertAndValidateRaw(settings.value(_name, rawDefaultValue), true /* conertOnly */, typedValue, errorString);
        _rawValue = typedValue;
    } else {
        // Setting is not visible, force to default value always
        settings.setValue(_name, rawDefaultValue);
        _rawValue = rawDefaultValue;
    }

    connect(this, &Fact::rawValueChanged, this, &SettingsFact::_rawValueChanged);
}
const char* FactMetaData::_decimalPlacesJsonKey =       "decimalPlaces";
const char* FactMetaData::_nameJsonKey =                "name";
const char* FactMetaData::_typeJsonKey =                "type";
const char* FactMetaData::_shortDescriptionJsonKey =    "shortDescription";
const char* FactMetaData::_longDescriptionJsonKey =     "longDescription";
const char* FactMetaData::_unitsJsonKey =               "units";
const char* FactMetaData::_defaultValueJsonKey =        "defaultValue";
const char* FactMetaData::_mobileDefaultValueJsonKey =  "mobileDefaultValue";
const char* FactMetaData::_minJsonKey =                 "min";
const char* FactMetaData::_maxJsonKey =                 "max";
const char* FactMetaData::_hasControlJsonKey =          "control";

三、ParameterEditorDialog.qml对话框

 function accept() {
        if (bitmaskColumn.visible && !manualEntry.checked) {
            fact.value = bitmaskValue();
            fact.valueChanged(fact.value)
            hideDialog();
        } else if (factCombo.visible && !manualEntry.checked) {
            fact.enumIndex = factCombo.currentIndex
            hideDialog()
        } else {
            var errorString = fact.validate(valueField.text, forceSave.checked)
            if (errorString === "") {
                fact.value = valueField.text
                fact.valueChanged(fact.value)
                hideDialog()
            } else {
                validationError.text = errorString
                if (_allowForceSave) {
                    forceSave.visible = true
                }
            }
        }
    }

    function reject() {
        fact.valueChanged(fact.value)
        hideDialog();
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

屁小猪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值