Configure the Video Quality (Windows Embedded CE 6.0)
1/6/2010
Video capture devices can support various properties that control the quality of the output, such as brightness, contrast, saturation, and so forth. To set these properties, do the following:
- Query the capture filter for the IAMVideoProcAmp interface.
- For each property that you want to control, call the IAMVideoProcAmp::GetRange method. This method returns the range of values that the device supports for that property, the default value, and the minimum increments for the settings. The IAMVideoProcAmp::Get method returns the current value of the property. The VideoProcAmpProperty enumeration defines flags for each of the properties.
- To set a property, call the IAMVideoProcAmp::Set method. To restore a property to its default value, use IAMVideoProcAmp::GetRange to find the default and pass that value to the IAMVideoProcAmp::Set method. You do not have to stop the filter graph when you set the properties.
The following code configures a trackbar control so that it can be used to set the brightness. The range of the trackbar corresponds to the brightness range that the device supports, and position of the trackbar corresponds to the device's initial brightness setting.
HWND hTrackbar; // Handle to the trackbar control.
// Initialize hTrackbar (not shown).
// Query the capture filter for the IAMVideoProcAmp interface.
IAMVideoProcAmp *pProcAmp = 0;
hr = pCap->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp);
if (FAILED(hr))
{
// The device does not support IAMVideoProcAmp, so disable
// the control.
EnableWindow(hTrackbar, FALSE);
}
else
{
long Min, Max, Step, Default, Flags, Val;
// Get the range and default value.
hr = m_pProcAmp->GetRange(VideoProcAmp_Brightness, &Min, &Max, &Step,
&Default, &Flags);
if (SUCCEEDED(hr))
{
// Get the current value.
hr = m_pProcAmp->Get(VideoProcAmp_Brightness, &Val, &Flags);
}
if (SUCCEEDED(hr))
{
// Set the trackbar range and position.
SendMessage(hTrackbar, TBM_SETRANGE, TRUE, MAKELONG(Min, Max));
SendMessage(hTrackbar, TBM_SETPOS, TRUE, Val);
EnableWindow(hTrackbar, TRUE);
}
else
{
// This property is not supported, so disable the control.
EnableWindow(hTrackbar, FALSE);
}
}