QCamera 似乎坏了
Posted
技术标签:
【中文标题】QCamera 似乎坏了【英文标题】:QCamera seems broken 【发布时间】:2014-06-02 10:45:08 【问题描述】:为了使用我的手机摄像头(在 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】:我认为您的问题的答案包含在这里;
https://bugreports.qt-project.org/browse/QTBUG-38233?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
基本上 - 它不起作用。
我可以确认相机永远不会在 QT 的 5.3 分支下进入模式 8。 5.2.1 允许拍摄图像,但取景器不工作。
我不确定发生了什么,或者他们为什么会停止支持此代码。
【讨论】:
以上是关于QCamera 似乎坏了的主要内容,如果未能解决你的问题,请参考以下文章
Meego 1.2 Harmattan 和 QCamera 应用程序