如何在 Windows C++ 上获取每个摄像头的可用分辨率列表

How to get a list of available resolutions for every camera on Windows C++

我的 Windows 11 系统中有多个摄像头,我想知道如何为它们获取所有可用的分辨率。我不打算进行视频捕获,但我愿意只获取这些属性。

此外,我不关心使用哪个 API,无论是 DirectShow 还是 MMF (Microsoft Media Foundation)。 我以前也没有用过这些。

我发现有多个资源在 C# 中执行此操作(如 here), but similar suggested answers for C++ are hard to understand - some code is given, but what libraries and 'includes' used is not given (as in here

我也检查了 DirectShow samples 希望有什么东西在那里,但我没有找到任何东西。

所以,我也检查了 MMF(1, 2, 3) and docs,但是所有的帖子似乎都已经过时了,并且没有给出完整的代码来展示如何在正确的 'includes' 旁边使用某些函数,因为尝试代码给出我 未解析的符号

所以我现在有点卡住了,找不到解决办法。

如有任何帮助,我将不胜感激。

Also, I don't care which API to use, be it DirectShow or MMF (Microsoft Media Foundation). I haven't used any of these before either.

您通常会关心,因为数据可能不同。

有了 Media Foundation,请参阅 How to Set the Video Capture Format

Call IMFMediaTypeHandler::GetMediaTypeCount to get the number of supported formats.

您可能还想看看 Tanta: Windows Media Foundation 示例项目 和那里的示例代码。

使用 DirectShow,请参阅 in addition to links you found; you will have to sort out includes and libraries through, among SDK samples AMCap does some one this and can be built from source without additional external libraries, from original code or from this fork 被最新的 VS 采用。