QCamera Android Crash

  • @ QCameraViewfinder * viewFinder;
    QCamera * camera;
    QAbstractVideoSurface * surface;

    QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
    foreach (const QCameraInfo &cameraInfo, cameras) {
            camera = new QCamera(cameraInfo);
            qDebug() << "found cam";
        viewFinder = new QCameraViewfinder;

    It does not matter if I use the QCameraViewfinder or QAbstractVideoSurface, once the camera is started, the application crashes. Any ideas are welcome :)

    (void MainWindow::openScanner()): found cam
    Fatal signal 11 (SIGSEGV) at 0x00000005 (code=1), thread 15692

  • just tested, it crashes @ camera->setViewfinder(viewFinder);

  • Lifetime Qt Champion


    So it's not when the camera starts, right ?

    Are you sure that camera is really valid at this time ?

  • It was a problem with the viewfinder/surface attached. Anyway now it crashes when the camera starts. I'm now trying to port the C++ version of the camera example to properly work on android, since I do not care about a live preview I'll try to re-render images as they come to the surface. If anyone already got a working example it would be much appreciated :)

  • Lifetime Qt Champion

    Just thought about something, IIRC you would need to use QML to have a preview on Android

  • using QML is not an option right now, this should be purely C++/Qt. Grabbing single images from the surface and displaying them in a Label should do the trick :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.