Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Camera based QML element
Forum Updated to NodeBB v4.3 + New Features

Camera based QML element

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 747 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.
  • G Offline
    G Offline
    galatea
    wrote on last edited by
    #1

    I am trying to create a configurable system to acquire and process still images of the (main) camera of an android device. The images are never intedended to be visible to the user, that is why I want to create my own QML element for the acquisition of raw data.
    While trying to implement that class (source below) I stumbled across the following problem:

    If I derive my Camera-class that uses an Instance of QCamera and QCameraImageCapture from QQuickItem, everything works fine on my labtop (windows 32bit kit), but it does not work on the android device. The callback that is supposed to process the image is never called und the application output states, that the camera issues error 1001 every few seconds. If I derive the camera-class from QMainWindow and call the show()-method before initialising the camera, it works fine. Right now I fail to see, why I would need a certain kind of user interface to be present in order to work the camera of the device. I would be grateful for any kind of advise.

    File camera.h
    @
    class Camera2:public QMainWindow//public QQuickItem
    {
    Q_OBJECT

    public:
    Camera2();

    public slots:
    void test();
    void imageCaptured(int id, QImage img);

    private:
    QCamera* pCamera;
    QCameraImageCapture* pCapture;
    };
    @

    File camera.cpp
    @
    void Camera2::test()
    {
    pCamera=new QCamera();
    pCapture=new QCameraImageCapture(pCamera);
    pCamera->setViewfinder(new QCameraViewfinder());
    connect(pCapture,SIGNAL(imageCaptured(int,QImage)),this,SLOT(imageCaptured(int,QImage)));
    pCamera->setCaptureMode(QCamera::CaptureStillImage);
    pCamera->load();
    pCamera->start();
    QTimer::singleShot(10000,pCapture,SLOT(capture()));
    }

    void Camera2::imageCaptured(int id, QImage img)
    {
    QMessageBox::information(dynamic_cast<QWidget*>(this),"test",QString::number(img.height())+" x "+QString::number(img.width()), QMessageBox::Ok);
    }
    @

    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