Webcam preview with Qt Quick



  • I am planning to embed a webcam view in my application. In order to understand how that works I tried running the declerative camera sample project. It builds and runs, however I do not see any video from camera -- the view is just black. In the application output inside Qt Creator, I see the following errors:

    Starting /home/aras/Qt5.7.0/Examples/Qt-5.7/multimedia/build-declarative-camera-Desktop_Qt_5_7_0_GCC_64bit-Debug/declarative-camera...
    QML debugging is enabled. Only use this in a safe environment.
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera"
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
    qrc:///VideoCaptureControls.qml:110: Error: Cannot assign [undefined] to QString
    qrc:///CameraListButton.qml:65:5: QML CameraListPopup: Binding loop detected for property "currentValue"
    qrc:///PhotoCaptureControls.qml:135: Error: Cannot assign [undefined] to QString
    qrc:///CameraListButton.qml:65:5: QML CameraListPopup: Binding loop detected for property "currentValue"
    /home/aras/Qt5.7.0/Examples/Qt-5.7/multimedia/build-declarative-camera-Desktop_Qt_5_7_0_GCC_64bit-Debug/declarative-camera exited with code 0
    

    Why do you think the sample program is not working? Am I missing some libraries?



  • Hi Aras,
    Did you include multimedia (for QML) and/or multimediawidgets (for C++ QWidget code) in your .pro project file ?
    Could you paste your code (you can use service paste from gist github maybe... this can be able to add many different files) ?
    Or maybe if you have a public test-case application on git or bitbucket something like that, i would be happy to contribute.
    Also, could you tell us wich environment you are running on ? (linux, Osx, Windows)


  • Lifetime Qt Champion

    Hi,

    Do you have GStreamer installed ? If so which version ?



  • @jerome_isAviable I am using the declarative camera sample app that comes with Qt installation without any modification, so I assume this is not an error in the code, but something with my environment.

    I am using Ubuntu Linux 16.06 64bit. Here is are my gstreamer packages:

    $ sudo dpkg -l |grep gstreamer
    ii  gir1.2-gstreamer-1.0                            1.8.2-1~ubuntu1                                             amd64        GObject introspection data for the GStreamer library
    ii  gstreamer-qapt                                  3.0.2-0ubuntu1.1                                            amd64        GStreamer plugin to install codecs using QApt
    ii  gstreamer1.0-alsa:amd64                         1.8.2-1ubuntu0.1                                            amd64        GStreamer plugin for ALSA
    ii  gstreamer1.0-clutter-3.0                        3.0.18-1                                                    amd64        Clutter PLugin for GStreamer 1.0
    ii  gstreamer1.0-fluendo-mp3:amd64                  0.10.32.debian-1                                            amd64        Fluendo mp3 decoder GStreamer 1.0 plugin
    ii  gstreamer1.0-libav:amd64                        1.8.2-1~ubuntu1                                             amd64        libav plugin for GStreamer
    ii  gstreamer1.0-plugins-bad:amd64                  1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "bad" set
    ii  gstreamer1.0-plugins-bad-faad:amd64             1.8.2-1ubuntu0.1                                            amd64        GStreamer faad plugin from the "bad" set
    ii  gstreamer1.0-plugins-bad-videoparsers:amd64     1.8.2-1ubuntu0.1                                            amd64        GStreamer videoparsers plugin from the "bad" set
    ii  gstreamer1.0-plugins-base:amd64                 1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "base" set
    ii  gstreamer1.0-plugins-base-apps                  1.8.2-1ubuntu0.1                                            amd64        GStreamer helper programs from the "base" set
    ii  gstreamer1.0-plugins-good:amd64                 1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "good" set
    ii  gstreamer1.0-plugins-ugly:amd64                 1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "ugly" set
    ii  gstreamer1.0-plugins-ugly-amr:amd64             1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "ugly" set
    ii  gstreamer1.0-pulseaudio:amd64                   1.8.2-1ubuntu0.1                                            amd64        GStreamer plugin for PulseAudio
    ii  gstreamer1.0-tools                              1.8.2-1~ubuntu1                                             amd64        Tools for use with GStreamer
    ii  gstreamer1.0-x:amd64                            1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins for X11 and Pango
    ii  libgstreamer-plugins-bad1.0-0:amd64             1.8.2-1ubuntu0.1                                            amd64        GStreamer development files for libraries from the "bad" set
    ii  libgstreamer-plugins-base1.0-0:amd64            1.8.2-1ubuntu0.1                                            amd64        GStreamer libraries from the "base" set
    ii  libgstreamer-plugins-good1.0-0:amd64            1.8.2-1ubuntu0.1                                            amd64        GStreamer development files for libraries from the "good" set
    ii  libgstreamer1.0-0:amd64                         1.8.2-1~ubuntu1                                             amd64        Core GStreamer libraries and elements
    ii  libreoffice-avmedia-backend-gstreamer           1:5.1.4-0ubuntu1                                            amd64        GStreamer backend for LibreOffice
    ii  phonon-backend-gstreamer:amd64                  4:4.8.2-0ubuntu2                                            amd64        Phonon GStreamer 1.0 backend
    ii  phonon-backend-gstreamer-common:amd64           4:4.8.2-0ubuntu2                                            amd64        Phonon GStreamer 1.0.x backend icons
    ii  phonon4qt5-backend-gstreamer:amd64              4:4.8.2-0ubuntu2                                            amd64        Phonon Qt5 GStreamer 1.0 backend
    
    

    Sorry for the late reply guys! I did not realize you had replied. I just enabled email notification in my profile for this forum (they were disabled by default). I appreciate your help!



  • Here is the application output in Qt Creator:

    Starting /home/aras/Qt5.7.0/Examples/Qt-5.7/multimedia/build-declarative-camera-Desktop_Qt_5_7_0_GCC_64bit-Debug/declarative-camera...
    QML debugging is enabled. Only use this in a safe environment.
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera"
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
    qrc:///VideoCaptureControls.qml:110: Error: Cannot assign [undefined] to QString
    qrc:///CameraListButton.qml:65:5: QML CameraListPopup: Binding loop detected for property "currentValue"
    qrc:///PhotoCaptureControls.qml:135: Error: Cannot assign [undefined] to QString
    qrc:///CameraListButton.qml:65:5: QML CameraListPopup: Binding loop detected for property "currentValue"
    /home/aras/Qt5.7.0/Examples/Qt-5.7/multimedia/build-declarative-camera-Desktop_Qt_5_7_0_GCC_64bit-Debug/declarative-camera exited with code 0
    

  • Lifetime Qt Champion

    IIRC, the gstreamer backend is built against 0.1 so one thing you could do is re-build the plugin against 1.0.



  • @SGaist can you elaborate how I could do that? It there a Qt module that I need to rebuild and reinstall?


  • Lifetime Qt Champion

    The QtMultimedia module provides the backends. You don't need to rebuild the whole module, just the gstreamer backend.

    You can grab the sources from the installer to get you started.



  • I went into software repository and installed anything matching gstreamer1.0* and then tried running the sample app again. Now the video is working. So it was a dependancy on one of the gstreamer1.0 packages. Unfortunately I dont know which one.

    Thank you for your help @SGaist and @jerome_isAviable !



  • I am now having this exact problem on a second machine. Searching through repository for any packages related to gstreamer and installing them -- it seems so ad hoc!

    Is there any way to see in Qt Creator or in the application output what library should be providing the camera service? That way I can just install that library instead of the other 200 and be sure I got it right. Any suggestions?


  • Lifetime Qt Champion

    I'm not 100% sure but I think it's the gst-plugins-good package.



  • Thanks for the hint @SGaist ! On this new install it was the gstreamer0.10-plugins-good set that I was missing. I had the version 1.0 installed instead of 0.1.

    I am going to mark this thread as resolved, but I still would like to know if there is a better way to figure out what library is missing. So if you know, please chime in! Thanks!


  • Lifetime Qt Champion

    You're welcome !

    If you would like to use the latest version of gstreamer, you'll likely have to re-build the QtMultimedia backend.


Log in to reply
 

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