¿Cómo obtener una lista de NOMBRES de dispositivos de captura de video (cámaras web) usando Qt (plataforma cruzada)? (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...)

también de esta serie:

preguntado el 09 de enero de 11 a las 03:01

I don't think there is a cross-platform way to do it with Qt4 itself. Since video capturing is a work in progress, you'll probably have to write it yourself: doc.trolltech.com/4.7/phonon-overview.html#work-in-progress -

@WoLpH: If you are correct it is very sad=( -

2 Respuestas

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

Respondido 26 Abr '17, 19:04

I've wrote the following code to list all the USB capture devices. Remember to include webcam.h and libwebcam.h and link your code to libwecam using -lwebcam.

bool QextCamera::listAvailableDevices(QStringList * captureDeviceList){
    CResult ret;
    CDevice *devices = NULL;

    quint32 req_size = 0;
    quint32 buffer_size = 0;
    quint32 count = 0;
    QStringList availableDevices;


    do {
        if (devices){

        devices = (CDevice *)malloc(req_size);

        if(devices == NULL){
                // LOG ERROR...
        return false;

        buffer_size = req_size;

   // Try to enumerate. If the buffer is not large enough, the required size is returned.
   ret = c_enum_devices(devices, &req_size, &count);

   if(ret != C_SUCCESS && ret != C_BUFFER_TOO_SMALL){
       // LOG ERROR...
       return false;

    } while(buffer_size < req_size);

    if(count == 0) {
        // LOG ERROR...
    return false;

    for(quint32 i = 0; i < count; i++) {
        CDevice *device = &devices[i];
    availableDevices << QString("%1 : %2 : %3").arg(device->shortName).arg(device->driver).arg(device->location);



    *captureDeviceList = availableDevices;

    return true;

Respondido 15 Jul 11, 17:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.