Others

Resolution Switching in DirectShow Camera Application

Resolution-Switching-in-DirectShow-Camera-Application

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

Related posts

2 comments

ToonSuperLove June 19, 2010 at 10:05 am

Hi,

I am trying this code but
it didn’t change anything

[I have place in WM_INITDIALOG of FormatSelectDialog is it correct?]

I am very beginner to C++ also, I have doubt how to
actually insert data in radio button, or combobox like your sample

[ I have tried to insert in combobox
hID = GetDlgItem(hDlg, IDC_RESOL);
….
nPos =
SendMessage(hID, CB_INSERTSTRING, -1, (LPARAM)pmtConfig);
SendMessage(hID, CB_SETITEMDATA, nPos, (LPARAM)pmtConfig);
]

if it possible could you please
give me this source code? or answer also fine

thanks
Toon

Prabu Kumar August 4, 2010 at 6:57 pm

Add a new button in the existing
main window of the camera application. Design a UI as per your need and hook the UI using that button.

In the above post, my focus is only on the
overview of handling the resolution switching in the directshow layer, so designing the UI is upto you.

For VC++ related questions please check out
the following forum to get more help.
https://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/threads

Comments are closed.