本文介紹了如何使用 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++)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!