Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Getting info of camera devices.



  • Hello all,
    I tried to get the name of camera devices in Qt referring the sample camera example.
    Their i can see the names of camera with their names in readable form but when i
    use the same code in my program i get a long value with the names how can i separate the info to get the short names.
    Sample code:

    std::cout<<"Entering camera function \n";
        QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
        foreach (const QCameraInfo &cameraInfo, cameras)
           // QVariant::fromValue(cameraInfo.deviceName());
            qDebug()<< "device:"<< QVariant::fromValue(cameraInfo.deviceName());
        std::cout<<"Exiting camera function \n";
    

    Output:
    device: QVariant(QString, "@device:pnp:\\?\usb#vid_04f2&pid_b5a7&mi_00#6&fea6f4d&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global")
    device: QVariant(QString, "@device:sw:{860BB310-5D01-11D0-BD3B-00A0C911CE86}\Basler GenICam Source")
    device: QVariant(QString, "@device:sw:{860BB310-5D01-11D0-BD3B-00A0C911CE86}\Basler GenICam Source 2")
    device: QVariant(QString, "@device:sw:{860BB310-5D01-11D0-BD3B-00A0C911CE86}\Basler GenICam Source 3")
    device: QVariant(QString, "@device:sw:{860BB310-5D01-11D0-BD3B-00A0C911CE86}\Basler GenICam Source 4")

    Also, i have only 2 cameras connected. But in the output i can see multiple cameras.


  • Lifetime Qt Champion

    Hi,

    That because your camera is seen through different interfaces. The GenICam standard does offer different ways to access your camera which might not correspond to the number of device.



  • @SGaist : Thanks.
    Is there any way to get the names of camera like:
    webcam
    Basler GenICam Source
    Basler GenICam Source1
    From the list given above.


  • Qt Champions 2019

    @Kira You can extract the name from the strings



  • Sure thanks.


Log in to reply