Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82572

QCameraImageCapture::CaptureToBuffer has not effect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.0 RC
    • 5.14.1
    • Multimedia
    • None
    • Linux/X11, Windows
    • b8525df9434d34f24c488848e320d1bc77de49cd (qt/qtmultimedia/5.14)

    Description

      Using QCameraImageCapture::CaptureToBuffer has not effect, the captured images saved to the file system, that trashes the disk space.

      The signal CameraImageCapture::imageSaved() does not triggered, so, no any way to remove the saved images.

      Code snippet:

      Camera::Camera(const QString &cameraName, QObject *parent)
          : QObject(parent)
          , m_camera(new QCamera(cameraName.toUtf8(), this))
          , m_capture(new QCameraImageCapture(m_camera, this))
          , m_timer(new QTimer(this))
      {
          qCDebug(SI_CLT_CAM) << "Create";
          const bool canCaptureImage = m_camera->isCaptureModeSupported(QCamera::CaptureStillImage);
          qCDebug(SI_CLT_CAM) << "Capture as image supported:" << canCaptureImage;
          if (canCaptureImage)
              m_camera->setCaptureMode(QCamera::CaptureStillImage);
      
          QImageEncoderSettings es;
          es.setCodec("image/jpeg");
          es.setResolution(1920, 1080);
          m_capture->setEncodingSettings(es);
      
          const bool canCapturToBuffer = m_capture->isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer);
          qCDebug(SI_CLT_CAM) << "Capture to buffer supported:" << canCapturToBuffer;
          if (canCapturToBuffer) {
              m_capture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
              m_capture->setBufferFormat(QVideoFrame::Format_Jpeg);
          }
      
          connect(m_camera, &QCamera::stateChanged, this, [this](QCamera::State state) {
              qCDebug(SI_CLT_CAM) << "Camera state:" << state;
          });
          connect(m_camera, QOverload<QCamera::Error>::of(&QCamera::error), this, [this](QCamera::Error error) {
              if (error != QCamera::NoError)
                  qCWarning(SI_CLT_CAM) << "Camera error:" << error;
          });
      
          connect(m_capture, QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
                  this, [this](int id, QCameraImageCapture::Error error, const QString &errorString) {
              Q_UNUSED(id)
              Q_UNUSED(errorString)
              if (error != QCameraImageCapture::NoError)
                  qCWarning(SI_CLT_CAM) << "Capture error:" << error;
          });
          connect(m_capture, &QCameraImageCapture::imageCaptured, this, [this](int id, const QImage &image) {
              qCDebug(SI_CLT_CAM) << "Image captured, size:" << image.size();
              emit imageCaptured(image);
          });
          connect(m_capture, &QCameraImageCapture::imageSaved, this, [this](int id, const QString &fileName) {
              Q_UNUSED(id)
              //  << DOES NOT CALLED AT ALL
              qCDebug(SI_CLT_CAM) << "Saved image:" << fileName << "removed:" << success;
          });
      
          connect(m_timer, &QTimer::timeout, this, [this]() {
              qCDebug(SI_CLT_CAM) << "Capture image";
              m_capture->capture(); // LEADS TO SAVE THE IMAGE TO THE FILE SYSTEM! WTF?
          });
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            kuzulis Denis Shienkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes