Full HD Global Shutter Camera
Resolution-Switching-in-DirectShow-Camera-Application

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()

CTO at | Website | + posts

Prabu is the Chief Technology Officer and Head of Camera Products at e-con Systems, and comes with a rich experience of more than 15 years in the embedded vision space. He brings to the table a deep knowledge in USB cameras, embedded vision cameras, vision algorithms and FPGAs. He has built 50+ camera solutions spanning various domains such as medical, industrial, agriculture, retail, biometrics, and more. He also comes with expertise in device driver development and BSP development. Currently, Prabu’s focus is to build smart camera solutions that power new age AI based applications.

Recently Published