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



  • @
    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
    @


  • Lifetime Qt Champion

    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 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
    }
    }
    @


  • Lifetime Qt Champion

    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 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


  • Lifetime Qt Champion



  • [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.


  • Lifetime Qt Champion

    What link error ?



  • [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{
    }


  • Lifetime Qt Champion

    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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.