Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list video capture devices NAMES (web cameras) using Qt (crossplatform)? (C++)

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

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...)


also from this series:

  • 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)?
like image 314
Rella Avatar asked Oct 24 '22 22:10

Rella


1 Answers

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();
}

remember to include in pro file:

QT += multimedia
like image 57
Thiago Falcao Avatar answered Nov 01 '22 10:11

Thiago Falcao