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. QCameraImageCapture get QImage without saving
Forum Updated to NodeBB v4.3 + New Features

QCameraImageCapture get QImage without saving

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 6 Posters 13.2k 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,
    I'm on N9.
    I can show camera in a viewfinder.

    Now I need to get a QImage from camera to manipulate it without saving a file in my phone.

    is It possible?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      Maybe this will help http://harmattan-dev.nokia.com/docs/library/html/fcam/main.html?tab=1

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        Thanks,
        I try to explain me better.
        In my application I need to get a QImage from phone camera.
        This is my code:
        @
        {
        ...
        ...
        m_camera = new QCamera("primary");
        m_camera->setViewfinder(ui->viewFinder);
        m_imageCapture = new QCameraImageCapture(m_camera);
        QImageEncoderSettings encoder_setting = m_imageCapture->encodingSettings();
        encoder_setting.setCodec("image/jpeg");
        encoder_setting.setQuality(QtMultimediaKit::NormalQuality);
        encoder_setting.setResolution(800,600);
        m_imageCapture->setEncodingSettings(encoder_setting);
        connect(m_imageCapture, SIGNAL(imageSaved(int,QString)), this, SLOT(processSavedImage(int,QString)));
        ...
        m_imageCapture->capture();
        ....
        }

        void MainWindow::processSavedImage(int requestId, QString str)
        {
        QImage my_image(str);
        ...
        }
        @

        This way I get a QImage reading it from phone memory while I'd like to get the QImage without saving to disk before.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          luca
          wrote on last edited by
          #4

          I have the same problem using QML and Camera Element.

          When I call Camera.captureImage() it capture a jpg image and save it.

          Is there a way to avoid to save the image?
          If not, is there a way to specify a path of the saved image?

          1 Reply Last reply
          0
          • P Offline
            P Offline
            puksec
            wrote on last edited by
            #5

            Hi, I had this problem a while ago. This is my fix:

            @void init_WebCam()
            {
            cam = new QCamera(0);
            connect(&captureTimer, SIGNAL(timeout()),
            this, SLOT (frameUpdated()));
            videoWidget = new QVideoWidget();
            videoWidget->setFixedSize(640,480);
            cam->setViewfinder(videoWidget);
            }

            void MainWindow::frameUpdated()
            {
            videoWidget->grab().toImage(); // this is your QImage
            }@

            Note that this is not QML, but c++ gui.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leon.anavi
              wrote on last edited by
              #6

              [quote author="puksec" date="1378901986"]Hi, I had this problem a while ago. This is my fix:[/quote]

              Thank you for sharing this solution but please wrap the source code with @ to make it easier for reading.

              http://anavi.org/

              1 Reply Last reply
              0
              • P Offline
                P Offline
                puksec
                wrote on last edited by
                #7

                Hm "@". So that's how you all are doing it :). Thanks for the tip.

                1 Reply Last reply
                0
                • ylopesY Offline
                  ylopesY Offline
                  ylopes
                  wrote on last edited by
                  #8

                  QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureToBuffer) is what you need.

                  Then listen to the QCameraImageCapture::imageAvailable() signal to get notified whenever the buffer is available.
                  You'll notice that what you get is a QVideoFrame, and you'll have to convert it to a QImage if that's what you need.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    puksec
                    wrote on last edited by
                    #9

                    I agree that that would be the first choice, but I had a situation where QCameraImageCapture::CaptureToBuffer was not supported on my system (for some unknown reason).

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      cnc-bert
                      wrote on last edited by
                      #10

                      Hi, I am having similar problem and I am quit new to qt programing.
                      Do you have an example of how to use the CaputureToBuffer ?
                      I do not know how to listen to QCameraImageCapture::imageAvailable() signal.
                      Thanks.

                      [quote author="Yoann Lopes" date="1383734227"]QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureToBuffer) is what you need.

                      Then listen to the QCameraImageCapture::imageAvailable() signal to get notified whenever the buffer is available.
                      You'll notice that what you get is a QVideoFrame, and you'll have to convert it to a QImage if that's what you need.[/quote]

                      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