Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Qt + Android + OpenCV is possible?

Hello, I'm trying to build simple android application, what just take photo from camera using opencv.

Application was built succesfull, but show me error when i try to run it on emulator or my phone. And no debug messages! I don't know what going wrong!

Is this real to use opencv in qt android app? What i need to do? Where i can read example? Sorry for bad english, not enought practics.

.pro contents:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = opencv_android
TEMPLATE = app

LIBS += H:\OpenCV-2.4.7.1-android-sdk\sdk\native\libs\armeabi-v7a\\\*
INCLUDEPATH += H:\OpenCV-2.4.7.1-android-sdk\sdk\native\jni\include\

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

CONFIG += mobility
MOBILITY = 

ANDROID_EXTRA_LIBS = 

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android

OTHER_FILES += \
        android/AndroidManifest.xml

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    cap = new cv::VideoCapture(0);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pbdo_clicked()
{
    cv::Mat pic, color;
    cap->operator >>(pic);
    cv::cvtColor(pic, color, CV_BGR2RGB);
    QImage img((uchar*) pic.data, pic.rows, pic.cols, pic.step, QImage::Format_RGB888);
    ui->lbimg->setPixmap(QPixmap::fromImage(img));
}

Qt + Android + OpenCV is possible?

Hello, I'm trying to build simple android application, what just take photo from camera using opencv.

Application was built succesfull, but show me error when i try to run it on emulator or my phone. And no debug messages! I don't know what going wrong!

Is this real to use opencv in qt android app? What i need to do? Where i can read example? Sorry for bad english, not enought practics.

System is Windows 7 x86_64, Qt 5.2

.pro contents:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = opencv_android
TEMPLATE = app

LIBS += H:\OpenCV-2.4.7.1-android-sdk\sdk\native\libs\armeabi-v7a\\\*
INCLUDEPATH += H:\OpenCV-2.4.7.1-android-sdk\sdk\native\jni\include\

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

CONFIG += mobility
MOBILITY = 

ANDROID_EXTRA_LIBS = 

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android

OTHER_FILES += \
        android/AndroidManifest.xml

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    cap = new cv::VideoCapture(0);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pbdo_clicked()
{
    cv::Mat pic, color;
    cap->operator >>(pic);
    cv::cvtColor(pic, color, CV_BGR2RGB);
    QImage img((uchar*) pic.data, pic.rows, pic.cols, pic.step, QImage::Format_RGB888);
    ui->lbimg->setPixmap(QPixmap::fromImage(img));
}