您的位置:网站首页 / UVC摄像头开发问答

DirectShow设置亮度、对比度等属性

UVC摄像头开发问答 2021-02-23

在DirectShow,对很多设置可以通过 IAMVideoProcAmp接口设置亮度、对比度等属性.
下面m_pVideo是源设备Filter.

IAMVideoProcAmp *pProcAmp = 0;
hr = m_pVideo->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp);
if (SUCCEEDED(hr))
{
    long Min, Max, Step, Default, Flags, Val;

    // 亮度.
    if (g_Brightness > 0)
    {
        hr = pProcAmp->GetRange(VideoProcAmp_Brightness, &Min, &Max, &Step,
            &Default, &Flags);
        if (SUCCEEDED(hr))
        {
            hr = pProcAmp->Get(VideoProcAmp_Brightness, &Val, &Flags);
            Val = Min + (Max - Min)*g_Brightness / 100;
            pProcAmp->Set(VideoProcAmp_Brightness, Val, Flags);
        }
    }

    //对比度
    if (g_Contrast > 0)
    {
        hr = pProcAmp->GetRange(VideoProcAmp_Contrast, &Min, &Max, &Step,
            &Default, &Flags);
        if (SUCCEEDED(hr))
        {
            hr = pProcAmp->Get(VideoProcAmp_Contrast, &Val, &Flags);
            Val = Min + (Max - Min)*g_Contrast / 100;
            pProcAmp->Set(VideoProcAmp_Contrast, Val, Flags);
        }
    }

    //饱和度
    if (g_Saturation > 0)
    {
        hr = pProcAmp->GetRange(VideoProcAmp_Saturation, &Min, &Max, &Step,
            &Default, &Flags);
        if (SUCCEEDED(hr))
        {
            hr = pProcAmp->Get(VideoProcAmp_Saturation, &Val, &Flags);
            Val = Min + (Max - Min)*g_Saturation / 100;
            pProcAmp->Set(VideoProcAmp_Saturation, Val, Flags);
        }
    }
}

原文来源:https://blog.csdn.net/cn_xinxin/article/details/2276159
https://docs.microsoft.com/en-us/previous-versions/ms893692(v=msdn.10)

Linux参见:https://www.cnblogs.com/blfshiye/p/5151167.html

很赞哦!

文章评论

标签云

用户接口

站点信息

  • 建站时间:2019-07-24
  • 联系站长tsingchen2008@163.com
  • 加QQ群 :952873936