设置摄像头属性页信息(调整画质)

bool set_property_pages_infos(const wchar_t* camera, const VideoProcAmpPropertyInfo  videoProcAmpPropertyInfo, const CameraControlPropertyInfo cameraControlPropertyInfo)

{

CoInitialize(NULL);

 

bool ret = true;

HRESULT hr = S_OK;

if (camera == NULL || camera[0] == 0)

return false;

 

ATL::CComPtr<ICreateDevEnum> pSysDevEnum;

hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);

if (hr != S_OK) {

XLOG_ERROR("CoCreateInstance CLSID_SystemDeviceEnum.error = %d", hr);

return false;

}

 

ATL::CComPtr<IEnumMoniker> pEnumCat;

hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);

if (hr != S_OK) {

XLOG_ERROR("CreateClassEnumerator CLSID_VideoInputDeviceCategory.error = %d", hr);

return false;

}

 

ATL::CComPtr<IBaseFilter> flter;

while (1)

{

ATL::CComPtr<IMoniker> pMoniker;

ULONG cFetched = 0;

hr = pEnumCat->Next(1, &pMoniker, &cFetched);

if (hr != S_OK || cFetched == 0)

break;

 

ATL::CComPtr<IPropertyBag> pPropBag;

hr = pMoniker->BindToStorage(NULL, 0, IID_IPropertyBag, (void **)&pPropBag);

if (hr == S_OK)

{

_variant_t varName;

hr = pPropBag->Read(L"FriendlyName", &varName, NULL);

if (hr == S_OK)

{

std::wstring str = varName.bstrVal;

if (str.compare(camera) == 0)

{

hr = pMoniker->BindToObject(NULL, 0, IID_IBaseFilter, (void**)&flter);

break;

}

}

}

}

 

if (flter == NULL)

return false;

 

CComPtr<IAMCameraControl> pSpec2;

CComPtr<IAMVideoProcAmp> pSpec;

CAUUID cauuid;

CComPtr<IAMCameraControl> pCameraControl;

 

hr = flter->QueryInterface(IID_IAMVideoProcAmp, (void **)&pSpec);

if (pSpec) {

//视频

hr = pSpec->Set(VideoProcAmp_Brightness, videoProcAmpPropertyInfo.VideoProcAmp_Brightness_Value, videoProcAmpPropertyInfo.VideoProcAmp_Brightness_Flag);

hr = pSpec->Set(VideoProcAmp_Contrast, videoProcAmpPropertyInfo.VideoProcAmp_Contrast_Value, videoProcAmpPropertyInfo.VideoProcAmp_Contrast_Flag);

hr = pSpec->Set(VideoProcAmp_Hue, videoProcAmpPropertyInfo.VideoProcAmp_Hue_Value, videoProcAmpPropertyInfo.VideoProcAmp_Hue_Flag);

hr = pSpec->Set(VideoProcAmp_Saturation, videoProcAmpPropertyInfo.VideoProcAmp_Saturation_Value, videoProcAmpPropertyInfo.VideoProcAmp_Saturation_Flag);

hr = pSpec->Set(VideoProcAmp_Sharpness, videoProcAmpPropertyInfo.VideoProcAmp_Sharpness_Value, videoProcAmpPropertyInfo.VideoProcAmp_Sharpness_Flag);

hr = pSpec->Set(VideoProcAmp_Gamma, videoProcAmpPropertyInfo.VideoProcAmp_Gamma_Value, videoProcAmpPropertyInfo.VideoProcAmp_Gamma_Flag);

hr = pSpec->Set(VideoProcAmp_ColorEnable, videoProcAmpPropertyInfo.VideoProcAmp_ColorEnable_Value, videoProcAmpPropertyInfo.VideoProcAmp_ColorEnable_Flag);

hr = pSpec->Set(VideoProcAmp_WhiteBalance, videoProcAmpPropertyInfo.VideoProcAmp_WhiteBalance_Value, videoProcAmpPropertyInfo.VideoProcAmp_WhiteBalance_Flag);

hr = pSpec->Set(VideoProcAmp_BacklightCompensation, videoProcAmpPropertyInfo.VideoProcAmp_BacklightCompensation_Value, videoProcAmpPropertyInfo.VideoProcAmp_BacklightCompensation_Flag);

hr = pSpec->Set(VideoProcAmp_Gain, videoProcAmpPropertyInfo.VideoProcAmp_Gain_Value, videoProcAmpPropertyInfo.VideoProcAmp_Gain_Flag);

}

hr = flter->QueryInterface(IID_IAMCameraControl, (void **)&pSpec2);

if (pSpec2) {

//相机

hr = pSpec2->Set(CameraControl_Pan, cameraControlPropertyInfo.CameraControl_Pan_Value, cameraControlPropertyInfo.CameraControl_Pan_Flag);

hr = pSpec2->Set(CameraControl_Tilt, cameraControlPropertyInfo.CameraControl_Tilt_Value, cameraControlPropertyInfo.CameraControl_Tilt_Flag);

hr = pSpec2->Set(CameraControl_Roll, cameraControlPropertyInfo.CameraControl_Roll_Value, cameraControlPropertyInfo.CameraControl_Roll_Flag);

hr = pSpec2->Set(CameraControl_Zoom, cameraControlPropertyInfo.CameraControl_Zoom_Value, cameraControlPropertyInfo.CameraControl_Zoom_Flag);

hr = pSpec2->Set(CameraControl_Exposure, cameraControlPropertyInfo.CameraControl_Exposure_Value, cameraControlPropertyInfo.CameraControl_Exposure_Flag);

hr = pSpec2->Set(CameraControl_Iris, cameraControlPropertyInfo.CameraControl_Iris_Value, cameraControlPropertyInfo.CameraControl_Iris_Flag);

hr = pSpec2->Set(CameraControl_Focus, cameraControlPropertyInfo.CameraControl_Focus_Value, cameraControlPropertyInfo.CameraControl_Focus_Flag);

}

 

CoUninitialize();

return ret;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值