QCamera好像坏了

时间:2014-06-02 10:45:08

标签: android c++ qt camera

为了使用我的手机相机(在Nexus 5上),我使用以下代码:

camera = new QCamera;
camera->setViewfinder(ui->viewFinder);
ui->viewFinder->show();

ui->stackedWidget->setGeometry(0,0, 1000, 1700);
ui->viewFinder->setGeometry(0, 0, 1000, 1700);

camera->start(); // to start the viewfinder
qDebug() << camera->error() << camera->errorString();
qDebug() << camera->state() << camera->status();

来自Qt doc,但它没有做任何事情。我在头文件中添加了正确的包含,在.pro文件中添加了QT += multimedia multimediawidgets

输出结果为:

QCamera::NoError ""
QCamera::UnloadedState QCamera::UnloadedStatus

这有点奇怪,因为如果start()函数失败,它应该抛出一个错误:

  

void QCamera :: start()[slot]启动相机。

     

如果启动了摄像头,状态将更改为QCamera :: ActiveState   成功,否则发出error()信号。

     

当相机状态更改为QCamera :: ActiveState时,启动   摄像头服务可以与报告的实际状态异步   使用QCamera :: status属性。

修改

QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras) {
qDebug() << cameraInfo.deviceName();
}

输出:

  

“后退”

     

“前”

因此QT会检测设备。

编辑2

这里有一些似乎包含一些错误的日志,但因为它是我的第一个Android应用程序,我不完全清楚发生了什么:

D/dalvikvm(21060): GC_CONCURRENT freed 172K, 2% free 17025K/17228K, paused 5ms+1ms, total 22ms
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libgnustl_shared.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libgnustl_shared.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libgnustl_shared.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5Core.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5Core.so 0x42cb2588
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5Gui.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5Gui.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libQt5Gui.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5Network.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5Network.so 0x42cb2588
I/Qt      (21060): Network start
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5Multimedia.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5Multimedia.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libQt5Multimedia.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5Widgets.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5Widgets.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libQt5Widgets.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5OpenGL.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5OpenGL.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libQt5OpenGL.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5MultimediaWidgets.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5MultimediaWidgets.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libQt5MultimediaWidgets.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/lib/libQt5Positioning.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/lib/libQt5Positioning.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/data/org.qtproject.example.HUD/lib/libQt5Positioning.so 0x42cb2588, skipping init
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/qt-reserved-files/plugins/platforms/android/libqtforandroid.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/qt-reserved-files/plugins/platforms/android/libqtforandroid.so 0x42cb2588
I/Qt      (21060): qt start
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/qt-reserved-files/plugins/mediaservice/libqtmedia_android.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/qt-reserved-files/plugins/mediaservice/libqtmedia_android.so 0x42cb2588
D/dalvikvm(21060): Trying to load lib /data/data/org.qtproject.example.HUD/qt-reserved-files/plugins/position/libqtposition_android.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/data/org.qtproject.example.HUD/qt-reserved-files/plugins/position/libqtposition_android.so 0x42cb2588
I/QtPositioning(21060): Positioning start
D/dalvikvm(21060): Trying to load lib /data/app-lib/org.qtproject.example.HUD-1/libHUD.so 0x42cb2588
D/dalvikvm(21060): Added shared lib /data/app-lib/org.qtproject.example.HUD-1/libHUD.so 0x42cb2588
D/dalvikvm(21060): No JNI_OnLoad found in /data/app-lib/org.qtproject.example.HUD-1/libHUD.so 0x42cb2588, skipping init
I/Adreno-EGL(21060): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
D/OpenGLRenderer(21060): Enabling debug mode 0

1 个答案:

答案 0 :(得分:2)

我认为你的问题的答案包含在这里;

https://bugreports.qt-project.org/browse/QTBUG-38233?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

基本上 - 它不起作用。

我可以确认相机在QT的5.3分支下从未进入模式8。 5.2.1允许捕获图像,但取景器不起作用。

我不确定发生了什么,或者为什么他们会停止支持此代码。