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).
// 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()
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.
2 Comment
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
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