如何使用 Qt(跨平台)获取列表视频捕获设备名称(网络摄像机)?(C++) [英] How to get a list video capture devices NAMES (web cameras) using Qt (crossplatform)? (C++)

查看:62
本文介绍了如何使用 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...)

也来自这个系列:

  • 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++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆