1

I would like to get the resolution of the selected camera and also get the raw frame in the videocapture but I have not found clearly at all how to do it. Could you help me!? Thanks in advance.

    // Open camera for reading
    cameraQt = new QCamera(cameras.at(cameraIdSelected));
    if(!cameraQt->isAvailable())
          ui->statusBar->showMessage(tr("Impossible to open camera...."));

    cameraQt->setViewfinder(ui->centralWidget);

like : cameraQt->getResolution ?

Thanks.

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
Arritmic
  • 474
  • 2
  • 12
  • Studying this would help https://doc.qt.io/qt-5.10/qtmultimedia-multimediawidgets-camera-example.html – zeFrenchy Feb 21 '18 at 16:46
  • Oh thanks! I was reading it previously, but I have not found how to get the "default" resolution of the "default" camera. But I will take a loot more deeply. – Arritmic Feb 21 '18 at 16:56

1 Answers1

2

I think you 1) Should load the cam 2) get imageCapture (raw) from the loaded cam. There is no direct simple type of a resolution, because camera will have a list of supported resolutions, you can set your device to one of those.

Try this to get the list of resolutions for a device:

QList<QByteArray> cameraDevices = QCamera::availableDevices();
QByteArray cameraDevice = cameraDevices[0];
QCamera *camera = new QCamera(cameraDevice);
camera->load();
qDebug() << "Camera status: " << camera->status();
QCameraImageCapture *imageCapture = new QCameraImageCapture(camera);
QList<QSize> resolutions = imageCapture->supportedResolutions();
QListIterator<QSize> it(resolutions);
while (it.hasNext()) {
    qDebug() << "Resoution: " << it.next();
}
Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
  • 1
    Thanks so much. I think I was missing the load() method. :) – Arritmic Feb 21 '18 at 18:23
  • Hello! Sorry for answering still now. It did not work, but I think it is due to other things. I had having this error ( I copied the error from other post), but like this: https://forum.qt.io/topic/78433/qt-multimeia-gstreamer-critical-error/2 But I do not know if it was a conflict with the opencv camera or some problem in my OS. Because I have all gstreamer plugins installed...Tomorrow I will continue with that project. Thanks so much anyway. :) – Arritmic Feb 22 '18 at 09:06