视频中的图片的配置参数一般有亮度、饱和度、对比度、锐度等,以前一直以为这些需要通过厂家的私有协议SDK来设置才行,后面通过研究Onvif Device Manager 和 Onvif Device Test Tool 这两个onvif开发的必备工具以后,发现onvif协议也具备了修改 亮度、色彩度、饱和度这三个参数,当然这三个参数我见过的摄像机厂家(主流的十几种)都具备,还有些大厂做的设备还提供了其他详细图片参数的设置比如ICAT。
通过万能的超级牛逼的抓包工具Wireshark抓包分析,发现 对图片参数进行设置(亮度、色彩度、饱和度)的参数中除了指定填入亮度、色彩度、饱和度的值以外,还需要指定VideoSourceToken,这玩意从哪里来呢?需要通过获取VideoSource拿到,即GetVideoSources命令,一般来说会在获取设备的rtsp地址、ptz云台地址等信息的时候一并获取,获取到以后存入onvifdevice类的变量中,下次设置图片参数的时候直接取就行。
onvif主要的功能:
onvif的处理流程:
QString OnvifOther::getVideoSource()
{
QString result = writeData(" <trt:GetVideoSources/>", "", "获取视频参数", false, false, 1);
QStringList list = result.split(ResultSplit);
QString videosource = list.first().split(":").last();
device->videoSource = videosource;
return result;
}
QString OnvifOther::getImageSetting(int &brightness, int &colorSaturation, int &contrast)
{
brightness = colorSaturation = contrast = 0;
QString wsdl = "http://www.onvif.org/ver20/imaging/wsdl";
QStringList list;
list << QString(" <GetImagingSettings xmlns=\"%1\">").arg(wsdl);
list << QString(" <VideoSourceToken>%1</VideoSourceToken>").arg(device->videoSource);
list << QString(" </GetImagingSettings>");
QString result = writeData(list.join("\r\n"), "Brightness|ColorSaturation|Contrast", "获取图片参数", false);
list = result.split(ResultSplit);
if (list.count() != 3) {
return result;
}
brightness = list.at(0).split(":").last().toInt();
colorSaturation = list.at(1).split(":").last().toInt();
contrast = list.at(2).split(":").last().toInt();
return result;
}
bool OnvifOther::setImageSetting(int brightness, int colorSaturation, int contrast)
{
QString wsdl = "http://www.onvif.org/ver20/imaging/wsdl";
QString schema = "http://www.onvif.org/ver10/schema";
QStringList list;
list << QString(" <SetImagingSettings xmlns=\"%1\">").arg(wsdl);
list << QString(" <VideoSourceToken>%1</VideoSourceToken>").arg(device->videoSource);
list << QString(" <ImagingSettings>");
list << QString(" <Brightness xmlns=\"%1\">%2</Brightness>").arg(schema).arg(brightness);
list << QString(" <ColorSaturation xmlns=\"%1\">%2</ColorSaturation>").arg(schema).arg(colorSaturation);
list << QString(" <Contrast xmlns=\"%1\">%2</Contrast>").arg(schema).arg(contrast);
list << QString(" </ImagingSettings>");
list << QString(" <ForcePersistence>true</ForcePersistence>");
list << QString(" </SetImagingSettings>");
QString result = writeData(list.join("\r\n"), "SetImagingSettingsResponse", "设置图片参数", false);
return result.contains("SetImagingSettingsResponse");
}
原文:https://www.cnblogs.com/feiyangqingyun/p/13825984.html