Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Capturing Image via CaptureToBuffer not works on Android
Forum Updated to NodeBB v4.3 + New Features

Capturing Image via CaptureToBuffer not works on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 4 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PowerNowP Offline
    PowerNowP Offline
    PowerNow
    wrote on last edited by
    #1

    Hi,
    I just tried to capture an image from the camera directly from the buffer. No matter what I try nothing works unfortunatley.

    1.) Via QCameraImageCapture:

    void Qml::iniObjects()
    {
    m_pRootObj = m_pEngine->rootObjects().first();
    QObject *qmlCamera = m_pRootObj->findChild<QObject*>("oCamera");
    m_pCamera = qvariant_cast<QCamera *>(qmlCamera->property("mediaObject"));
    m_pCamera->setCaptureMode(QCamera::CaptureStillImage);
    m_pImgCapt = new QCameraImageCapture(m_pCamera);
    m_pImgCapt->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
    connect(m_pImgCapt,SIGNAL(imageAvailable(int,const QVideoFrame&)), this, SLOT(updImageAvailable(int,const QVideoFrame&)));
    bool dest = m_pImgCapt->isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer);
    qDebug() << dest; **-> true**
    QList<QVideoFrame::PixelFormat> format = m_pImgCapt->supportedBufferFormats();
    qDebug() << format; **-> (Format_Jpeg)**
    }
    
    void Qml::updImageAvailable(int id, const QVideoFrame &buffer) {
        qDebug() << "Image";
    }
    

    Result: No error, no signal

    2.) Via QMediaService: Same code as before, excepted the following.

    QMediaService *service = m_pCamera->service();
    QMediaControl *control = service->requestControl(QCameraImageCaptureControl_iid);
    QCameraImageCaptureControl *captureControl = qobject_cast<QCameraImageCaptureControl*>(control);
    connect(captureControl,SIGNAL(imageAvailable(int,const QVideoFrame&)), this, SLOT(updImageAvailable(int,const QVideoFra@me&)));
    

    Result: No error, no signal

    Anyone an idea?

    Thanks in advance...

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by mrjj
      #2

      connect(captureControl,SIGNAL(imageAvailable(int,const QVideoFrame&)), this, SLOT(updImageAvailable(int,const QVideoFra@me&))); has a @ in it...

      could you use the new connect syntax:connect(m_pImgCapt,&QCameraImageCapture::imageAvailable, this, &Qml::updImageAvailable); and connect(captureControl,&QCameraImageCaptureControl::imageAvailable, this, &Qml::updImageAvailable);

      P.S.
      did you name your class Qml? I see a huge potential for naming clashes...

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      PowerNowP 1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        @PowerNow Check if the signal and slot connection was successful. connect returns the status.

        157

        1 Reply Last reply
        1
        • VRoninV VRonin

          connect(captureControl,SIGNAL(imageAvailable(int,const QVideoFrame&)), this, SLOT(updImageAvailable(int,const QVideoFra@me&))); has a @ in it...

          could you use the new connect syntax:connect(m_pImgCapt,&QCameraImageCapture::imageAvailable, this, &Qml::updImageAvailable); and connect(captureControl,&QCameraImageCaptureControl::imageAvailable, this, &Qml::updImageAvailable);

          P.S.
          did you name your class Qml? I see a huge potential for naming clashes...

          PowerNowP Offline
          PowerNowP Offline
          PowerNow
          wrote on last edited by PowerNow
          #4

          @p3c0 and @VRonin : Thxs for your fast response!
          I checked all your proposals but no difference. Regarding @ this was a inexplicable copy paste failure. But fortunately I found the reason. Maybe others are interessted:

          As I read the official docu for "QCameraImageCapture::capture" I found no hint regarding the signal "QCameraImageCapture::imageAvailable()". So I thought falsely that this signal is automatically created everytime a QVideoFrame is ready. But obviously also this signal is created only after calling "QCameraImageCapture::capture()". As my understanding this case is not considered in the docu.
          This also means if you set QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureToBuffer) there is no picture saved properly, independed if the passed QString to "::capture(""filename") is empty or not.

          1 Reply Last reply
          1
          • Julian GuarinJ Offline
            Julian GuarinJ Offline
            Julian Guarin
            wrote on last edited by
            #5

            @PowerNow Hello r u using QML? I capture images using QCamera. Check this thread from yesterday :)

            https://forum.qt.io/topic/71920/qimage-manipulation-crashes-on-android

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved