onvif 修改摄像头参数

可以根据对应的接口函数进行修改(例如:imaging、media相关的接口)。
修改方法:

  1. 获取要修改的参数
    每个设置函数均有对应的获取配置函数,为了不造成系统内存错误,应先用对应的获取函数获取配置信息。
  2. 修改参数
    这一步是直接用获取到的参数,只需要修改部分你想修改参数即可,不涉及到内存的分配。
  3. 将修改后的参数用设置函数写入至摄像机
    这一步则是调用设置函数,将修改后的参数写入设备。

示例代码如下:

int ONVIF_IMG_SetImagingSettings(char *pcImagingXAddr, char *ProfileToken, struct _imagingSettings * pstru_ImgSettingRsu)
{
	int result = 0;
    struct soap *soap = NULL;
	struct _timg__GetImagingSettings reqG;
	struct _timg__GetImagingSettingsResponse repG;
	struct _timg__SetImagingSettings reqS;
	struct _timg__SetImagingSettingsResponse repS;
	enum xsd__boolean ForceStorage;

	SOAP_ASSERT(NULL != pcImagingXAddr);
	SOAP_ASSERT(NULL != ProfileToken);
	SOAP_ASSERT(NULL != pstru_ImgSettingRsu);
	SOAP_ASSERT(NULL != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT)));

	memset(&reqS, 0x00, sizeof(struct _timg__SetImagingSettings));
	memset(&repS, 0x00, sizeof(struct _timg__SetImagingSettingsResponse));
	memset(&reqG, 0x00, sizeof(struct _timg__SetImagingSettings));
	memset(&repG, 0x00, sizeof(struct _timg__SetImagingSettingsResponse));

	//获取系统原来的配置
	reqG.VideoSourceToken = ProfileToken;
	ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD);	//鉴权
	result = soap_call___timg__GetImagingSettings(soap, pcImagingXAddr, NULL, &reqG, &repG);
	SOAP_CHECK_ERROR(result, soap, "GetImagingSettings");

	//修改某些参数写入设备
	reqS.VideoSourceToken = ProfileToken;
	reqS.ForcePersistence = &ForceStorage;
	*reqS.ForcePersistence = pstru_ImgSettingRsu->ForceStorage;
	reqS.ImagingSettings = repG.ImagingSettings;
	*reqS.ImagingSettings->Brightness = pstru_ImgSettingRsu->Brightness;
	*reqS.ImagingSettings->ColorSaturation = pstru_ImgSettingRsu->ColorSaturation;
	*reqS.ImagingSettings->Contrast = pstru_ImgSettingRsu->Contrast;
	reqS.ImagingSettings->Focus->AutoFocusMode = pstru_ImgSettingRsu->FocusMode;
	
	ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD);	//鉴权
	result = soap_call___timg__SetImagingSettings(soap, pcImagingXAddr, NULL, &reqS, &repS);
	SOAP_CHECK_ERROR(result, soap, "SetImagingSettings");

EXIT:

    if (NULL != soap) {
        ONVIF_soap_delete(soap);
    }

    return result;
}

main函数调用

//修改一些参数
gstru_ImgSetting.ForceStorage = xsd__boolean__true_;
gstru_ImgSetting.FocusMode = (enum tt__AutoFocusMode)fSpeed;//auto
ONVIF_IMG_SetImagingSettings(gstru_CapaAddr.caImagingAddr, gstru_CapaAddr.caMainVideoSourceToken, &gstru_ImgSetting);

以上示例代码实现了通过onvif协议修改摄像头的AutoFocusMode(对焦模式)、Brightness(亮度)、ColorSaturation(色彩饱和度)、Contrast(饱和度)等参数。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值