Qt对我来说是新的。 我按照他们的示例Camera Example和QML Camera Example来构建我自己的应用程序。我使用纯C ++语言而不是QML。该应用程序能够在桌面版本的屏幕上显示取景器,但在Android中无法显示。一切(OSX,NDK,Android SDK,QT)都是最新版本
widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QVideoWidget>
#include <QCamera>
#include <QCameraViewfinder>
namespace Ui {
class Widget;
}
class Widget : public QVideoWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
QCamera *camera;
};
#endif // WIDGET_H
widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QVideoWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
camera = new QCamera(this);
camera->setCaptureMode(QCamera::CaptureStillImage);
camera->setViewfinder(this);
camera->start();
}
Widget::~Widget()
{
delete ui;
}
my.pro
QT += core gui widgets multimedia multimediawidgets
TARGET = opencv
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
CONFIG += mobility console
MOBILITY =