Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Camera Example not working on Raspberry Pi



  • Hi!
    First of all let me say that I'm a beginner with programming and I'm developing a master thesis in a different engineering area so don't take it badly if I miss any detail I should be adding.

    At the moment i'm developing software through cross-compiling from a Ubuntu Virtual Machine to a Raspberry Pi 3+. The cross-compiling works and I had no trouble to run my app in the Pi, I followed this amazing guide.

    However, part of the app is based on obtaining image from a camera and showing it just like it happens with the camera example. Running my code I get this error:

    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera"
    ()
    Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created.

    Running the Qt camera example I obtain the same mistake (expected), but I know that the camera works since I've installed Cheese on the raspberry pi and it identifies the camera automatically without need of any input.
    I've been obsessing with this problem for a long time now and can't seem to find a solution that works or that I understand. Please help I'm desperate.

    Thanks!


  • Moderators

    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera"

    Do you have gstreamer installed?

    Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created.

    Call this before you instantiate Q*Application:

    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
    


  • @sierdzio

    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera"

    Do you have gstreamer installed?

    Yes, version 1.14.5 on VM and version 1.10.4 on Pi.

    Call this before you instantiate Q*Application:

    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
    

    This is error doesn't show but the other one remains. I really have no clue on how to proceed.
    Thanks so much for the quick answer


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Please start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show information about what is happening.



  • @SGaist

    Hi, thanks for answering.

    I've noticed a warning saying " Cannot read .../multimedia/shared/shared.pri". I don't think this is related but it may be worth mentioning.

    About the DEBUG_PLUGINS, I added "qputenv("QT_DEBUG_PLUGINS",QByteArray("1"));" in main.cpp right before QApplication.

    The output was really long but it repeats this :
    Got keys from plugin meta data ("svg", "svgz")
    QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/imageformats/libqtga.so"
    Found metadata in lib /usr/local/qt5pi/plugins/imageformats/libqtga.so, metadata=
    { .....

    For a lot of plugins.
    It ends like this:

    Got keys from plugin meta data ("audiocapture")
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/examples/multimediawidgets/camera/mediaservice" ...
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera"
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/examples/multimediawidgets/camera/accessible" ...
    Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created.

    It looks like it doesn't find nothing when checking path "usr/local/qt5pi/examples/multimediawidgets/camera/mediaservice", But then again I'm a complete noob and don't really know what I should be looking for.
    If you think is worth it I can try to post the complete output.

    Thanks so much again for your valuable help!


  • Lifetime Qt Champion

    Do you have the multimedia plugins in that folder ?
    How did you install Qt on the device ?



  • @SGaist

    I installed through this tutorial : https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/

    I have a lot of folders related to Qt and I think that may be one of my problems.

    On the pi I have a that folder "qt5pi" and a qt5pi/plugins, however there doesn't exist a qt5pi/plugins/multimedia or a qt5pi/plugins/accessible. However if I try to install qtmultimedia (apt-get install qtmultimedia5-dev) on the Pi it says it already has the newest version.
    If I go to usr/local/qt5pi/include/.. I can find there QtMultimedia and QtMultimediaWidgets... Should there be similar pastes in plugins? Thanks!


  • Lifetime Qt Champion

    Then from the looks of it, the guide does not suggests the Qt multimedia dependencies hence your build is "incomplete" in that regard. Add the GStreamer development packages along the other you installed and rebuild the QtMultimedia module.



  • @SGaist

    Sorry for the delay, I tried yesterday but I'm not sure how to proceed to get the module rebuilt. Do you have any suggestion? Thanks!


  • Lifetime Qt Champion

    Delete the folder and use the classic qmake/make. Use the full path to the qmake you want to use.


Log in to reply