Resolution-Switching

Resolution Switching in DirectShow Camera Application

Published on March 12, 2010

DirectShow sample camera test application source code resides in the ($(WINCEROOT)\PRIVATE\TEST\MULTIMEDIA\DIRECTX\DSHOW\CAMERA) directory of the WINCE 6.0 installation.

The CameraFramework source present on the private code supports functions which can be used to develop full functional directshow camera application.

Many of them were asking about the how to switch between the supported resolutions of the PINS in the application.

In the default application source present in the PRIVATE source we don’t have option for switching between the resolutions supported by camera driver.

The default application will simply make use of the first resolution supported by the camera driver(say for ex:320×240).

Following are the routines which are used for enumerating the supported resolutions of the camera driver.

int iCount = 0, iSize = 0;
hr = g_DShowCaptureGraph.GetNumberOfCapabilities(nStream, &iCount, &iSize);

nStream – Pin details(CAPTURE,PREVIEW,STILL)
iCount – Number of formats supported by the driver for the selected PIN.

Calling the GetStreamCaps () function will retrieve the format capabilities of the selected PIN. Enumerate the supported resolutions using following calls and list it in the application(ex : Using List box or group Radio Buttons).

Resolution Swtiching in DirectShow Camera Application

// Check the size to make sure we pass in the correct structure.
if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
{
// Use the video capabilities structure.
for (int iFormat = 0; iFormat < iCount; iFormat++)
{
VIDEO_STREAM_CONFIG_CAPS scc;
AM_MEDIA_TYPE *pmtConfig;
VIDEOINFOHEADER *pVih;
hr = g_DShowCaptureGraph.GetStreamCaps(nStream,iFormat, &pmtConfig, (BYTE*)&scc);
if (SUCCEEDED(hr))
{
// Examine the format.
pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;
RETAILMSG(1,(TEXT("Width = %d , Height = %d \r\n"),pVih->bmiHeader.biWidth, pVih->bmiHeader.biHeight));
}
}
}

After allowing the user to select the format set the corresponding resolution format using the following call of the camera framework.

hr = g_DShowCaptureGraph.SetFormat(nStream,pmtConfig);
if (SUCCEEDED(hr))
{
RETAILMSG(1,(TEXT("SetFormat Success ***********\r\n")));
}

nStream – Pin details(CAPTURE,PREVIEW,STILL)
pmtConfig – Structure returned by the GetStreamCaps()

Recently Published