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(飽和度)等參數。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章