Resolution Switching in DirectShow Camera Application

本文介绍了如何在DirectShow相机应用程序中枚举并切换不同分辨率的方法。通过使用特定的API,可以获取摄像头支持的所有分辨率,并允许用户进行选择,进而设置所选分辨率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值