Ask Your Question
1

Qt + Android + OpenCV is possible?

asked 2013-12-26 12:11:33 -0600

Nepherpitou gravatar image

updated 2013-12-26 12:29:47 -0600

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));
}
edit retag flag offensive close merge delete

Comments

I can use other openCV(imgproc, core)modules with Qt on android, but not the camera module of openCV.(Qt5.2.1 would allow us to capture the image buffer from QCamera).

stereoMatching gravatar imagestereoMatching ( 2013-12-27 05:41:48 -0600 )edit

http://answers.opencv.org/question/18376/cannot-use-camera-on-android-412-with-opencv-246/ I gave an answer on how to use it on old Qt 5, but also worked on Qt5.1. I havent tested 5.2 yet though

Moster gravatar imageMoster ( 2013-12-28 02:35:08 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-12-27 00:02:45 -0600

May be you need to add camera permissions in your application's manifest. See NativeActivity example in OpenCV4Android SDK as an example of cv::VideoCapture usage in native code.

edit flag offensive delete link more

Comments

"add camera permissions"do not work.

jsxyhelu gravatar imagejsxyhelu ( 2018-01-17 05:41:41 -0600 )edit
0

answered 2015-10-19 06:18:32 -0600

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-12-26 12:11:33 -0600

Seen: 6,158 times

Last updated: Oct 19 '15