Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]How could I get the image buffer of QCamera?
QtWS25 Last Chance

[Solved]How could I get the image buffer of QCamera?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 6.4k Views
  • 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.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    @
    QByteArray device = QCamera::availableDevices()[0];
    QCamera camera(device);
    QVideoWidget surface;
    surface.resize(320, 240);
    camera.setViewfinder(&surface);
    @

    How could I get the image capture by QCamera?
    I want to do some post-processing on the camera video
    QCameraImageCapture is too slow for real time

    Anything similar to following codes?
    @
    QCamera camera(device);
    QImage img = camera.getQImage(); //take the image buffer of camera
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you want to do some post processing before rendering, you could create your own QAbstractVideoSurface so you have directly access to the data.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stereomatching
        wrote on last edited by
        #3

        [quote author="SGaist" date="1385921233"]Hi,

        If you want to do some post processing before rendering, you could create your own QAbstractVideoSurface so you have directly access to the data.

        Hope it helps[/quote]

        Thanks, but this solution is pretty verbose(no offense)
        Too much codes to get an image.

        Why no provide api like opencv2 do?
        @
        cv::VideoCapture cap(0);
        if(cap.isOpened()){

        cv::Mat current_frame;

        while(cap.read(current_frame)){
        //....process current_frame
        }
        }
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          None taken.

          QCamera and friends are designed to be smoothly integrated in any application without the need for the programmer to write the "low level handling" like you would need with OpenCV.

          In between, if OpenCV provides the handling you need, nothing forbids you to use it along Qt

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stereomatching
            wrote on last edited by
            #5

            [quote author="SGaist" date="1386018714"]None taken.

            QCamera and friends are designed to be smoothly integrated in any application without the need for the programmer to write the "low level handling" like you would need with OpenCV.

            In between, if OpenCV provides the handling you need, nothing forbids you to use it along Qt
            [/quote]
            I would like to use the cv::VideoCapture of openCV too
            but have no idea how to make it work with Qt5 on android
            that is why I want to give QCamera a try

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Maybe "this":http://opencv.org/platforms/android/opencv4android-samples.html will help you get started

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                stereomatching
                wrote on last edited by
                #7

                [quote author="SGaist" date="1386110722"]Maybe "this":http://opencv.org/platforms/android/opencv4android-samples.html will help you get started[/quote]

                Thanks, I give it a try, but how no clues how to solve the link error of cameras.Other modules link fine and run well.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What link error ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    stereomatching
                    wrote on last edited by
                    #9

                    [quote author="SGaist" date="1386972721"]What link error ?[/quote]

                    "error messages":http://pastebin.com/7JC4V5ub

                    main.cpp
                    @
                    #include "mainwindow.h"
                    #include <QApplication>

                    #include <opencv2/core/core.hpp>
                    #include <opencv2/highgui/highgui.hpp>

                    int main(int argc, char *argv[])
                    {
                    QApplication a(argc, argv);
                    MainWindow w;
                    w.show();

                    //this work
                    cv::Mat_<int> A(3, 3);
                    A.at<int>(0, 0) = 9;
                    
                    //after adding this line, link erros pop out
                    cv::VideoCapture cap;
                    
                    return a.exec&#40;&#41;;
                    

                    }

                    @

                    .pro
                    @
                    #-------------------------------------------------

                    Project created by QtCreator 2013-12-14T06:46:23

                    #-------------------------------------------------

                    QT += core gui
                    CONFIG += c++11

                    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                    TARGET = androidCamera
                    TEMPLATE = app

                    INCLUDEPATH += /Users/Qt/program/3rdLibs/OpenCV-2.4.7-android-sdk/sdk/native/jni/include

                    CV_LIBS = /Users/Qt/program/3rdLibs/OpenCV-2.4.7-android-sdk/sdk/native/libs/armeabi
                    CV_3LIBS = /Users/Qt/program/3rdLibs/OpenCV-2.4.7-android-sdk/sdk/native/3rdparty/libs/armeabi
                    CV_LIBS_POST =

                    LIBS += -L $$CV_LIBS -lopencv_core$$CV_LIBS_POST
                    LIBS += -L $$CV_LIBS -lopencv_highgui$$CV_LIBS_POST
                    LIBS += -L $$CV_LIBS -lopencv_imgproc$$CV_LIBS_POST

                    LIBS += $$CV_3LIBS/libIlmImf.a
                    $$CV_3LIBS/liblibjasper.a
                    $$CV_3LIBS/liblibjpeg.a
                    $$CV_3LIBS/liblibpng.a
                    $$CV_3LIBS/liblibtiff.a \

                    SOURCES += main.cpp
                    mainwindow.cpp

                    HEADERS += mainwindow.h

                    FORMS += mainwindow.ui

                    CONFIG += mobility
                    MOBILITY =
                    @

                    ps : any plan to support something like
                    android_armeabi{
                    }
                    android_armeabi_v7a{
                    }

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      There might be an android library missing when compiling, you can try asking on the OpenCV forum also.

                      As for your ps, I don't know, that would be a question for the interest mailing list

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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