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

后端 未结 2 2078
误落风尘
误落风尘 2020-12-05 21:45

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 conso

2条回答
  •  半阙折子戏
    2020-12-05 22:33

    I used this example code to list the cameras and get some info about them.

    #include 
    
    QList 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
    

提交回复
热议问题