問題描述
所以我需要的很簡(jiǎn)單 - 當(dāng)前可用的視頻捕獲設(shè)備(網(wǎng)絡(luò)攝像機(jī))的列表.我在簡(jiǎn)單的 C++ Qt 控制臺(tái)應(yīng)用程序中需要它.通過列表,我的意思是類似這樣的控制臺(tái)輸出:
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++ 計(jì)算出這樣的列表?(如果可能的話,我很想看看如何在純 Qt 中做到這一點(diǎn)——沒有額外的庫......)
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...)
也來自這個(gè)系列:
- 如何在 Linux 上獲取視頻捕獲設(shè)備列表? 和 有關(guān)獲取相機(jī)名稱的特殊詳細(xì)信息 并提供正確的、經(jīng)過測(cè)試的答案
- 如何在 Mac OS 上獲取視頻捕獲設(shè)備的列表?正確的,尚未經(jīng)過我的回答測(cè)試
- 如何獲取 Windows 上的視頻捕獲設(shè)備列表? 提供正確的、經(jīng)過測(cè)試的答案
- 如何使用 Qt(跨平臺(tái))獲取視頻捕獲設(shè)備名稱列表?
- 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)?
推薦答案
我使用此示例代碼列出了攝像機(jī)并獲取了有關(guān)它們的一些信息.
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
這篇關(guān)于如何使用 Qt(跨平臺(tái))獲取列表視頻捕獲設(shè)備名稱(網(wǎng)絡(luò)攝像機(jī))?(C++)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!