How to get a list video capture devices NAMES (web cameras) using Qt (crossplatform)? (C++)(如何使用 Qt(跨平台)获取列表视频捕获设备名称(网络摄像机)?(C++))
问题描述
所以我需要的很简单 - 当前可用的视频捕获设备(网络摄像机)的列表.我在简单的 C++ Qt 控制台应用程序中需要它.通过列表,我的意思是类似这样的控制台输出:
So all I need is simple - a list of currently avaliable video capture devices (web cameras). I need it in simple C++ Qt console app. By list I mean something like such console output:
1) Asus Web Camera
2) Sony Web Camera
所以我的问题是如何使用 Qt C++ 计算出这样的列表?(如果可能的话,我很想看看如何在纯 Qt 中做到这一点——没有额外的库......)
So my question is how to cout such list using Qt C++? (if it is possible I'd love to see how to do it in pure Qt - no extra libs...)
也来自这个系列:
- 如何在 Linux 上获取视频捕获设备列表? 和 有关获取相机名称的特殊详细信息 并提供正确的、经过测试的答案
- 如何在 Mac OS 上获取视频捕获设备的列表?正确的,尚未经过我的回答测试
- 如何获取 Windows 上的视频捕获设备列表? 提供正确的、经过测试的答案
- 如何使用 Qt(跨平台)获取视频捕获设备名称列表?
- How to get a list of video capture devices on linux? and special details on getting cameras NAMES with correct, tested answers
- How to get a list of video capture devices on Mac OS? with correct, not yet tested by my answers
- How to get a list of video capture devices on windows? with correct, tested answers
- How to get a list video capture devices NAMES using Qt (crossplatform)?
推荐答案
我使用此示例代码列出了摄像机并获取了有关它们的一些信息.
I used this example code to list the cameras and get some info about them.
#include <QtMultimedia/QCameraInfo>
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras) {
qDebug() << "Name: " << cameraInfo.deviceName();
qDebug() << "Position: " << cameraInfo.position();
qDebug() << "Orientation: " << cameraInfo.orientation();
}
记得包含在 pro 文件中:
remember to include in pro file:
QT += multimedia
这篇关于如何使用 Qt(跨平台)获取列表视频捕获设备名称(网络摄像机)?(C++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Qt(跨平台)获取列表视频捕获设备名称


基础教程推荐
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01