Featured image of post Windows Ksproperty 使用方法

Windows Ksproperty 使用方法

KsProperty 可以用來讀寫相機的屬性,像是亮度、彩度、或是相機自定義的 extension unit 等
MSDN 上的簡介在此
IKsControl::KsProperty (ks.h) - Windows drivers | Microsoft Learn

從他的描述來看或許會有點誤導,下面是它的實際呼叫法,以讀取亮度為例。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
HRESULT hr = S_OK;
KSPROPERTY_VIDEOPROCAMP_S kspIn = {0}
KSPROPERTY_VIDEOPROCAMP_S kspOut = {0}
ULONG valueSize = 0;
kspIn.Property.Set    = PROPSETID_VIDCAP_VIDEOPROCAMP;
kspIn.Property.Id     = KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS;
kspIn.Property.Flags  = KSPROPERTY_TYPE_GET;
kspOut.Property.Set   = PROPSETID_VIDCAP_VIDEOPROCAMP;
kspOut.Property.Id    = KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS;
kspOut.Property.Flags = KSPROPERTY_TYPE_GET;

hr = m_spIkscontrol->KsProperty(
    (PKSPROPERTY)&kspIn, sizeof(kspin),
    &kspOut, sizeof(kspout), &valueSize);
)

// 如果正確執行就可以從kspOut.Value取出值,須注意變數型態的轉換。
if(hr == S_OK){
    INT brightnessValue = (INT)kspOut.Value;
}
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy