Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. Integrating Raspberry Pi Camera with Qt application
Forum Update on Monday, May 27th 2025

Integrating Raspberry Pi Camera with Qt application

Scheduled Pinned Locked Moved QtonPi
9 Posts 7 Posters 15.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    harshshah5789
    wrote on 16 Sept 2013, 05:36 last edited by
    #1

    I am making a hobby project of digital still camera based on Raspberry Pi using Qt.

    I have cross compiled Qt on Pi and able to successfully run a normal test Qt application on Pi.
    Also the raspistill and raspivid utilities are running successfully.

    The issue is with integrating the Rasp Pi camera. Before buying it I din't knew that it does not support v4l2.

    I want to show a live view of camera in the Qt application and capture the image when a Button is clicked.

    What are the options except v4l2, for getting the live feed from camera in Qt.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blueshift
      wrote on 21 Sept 2013, 19:07 last edited by
      #2

      "OpenCV":http://opencv.org/about.html is popular for accessing webcam/camera with Qt.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        m_rx
        wrote on 30 Oct 2013, 12:57 last edited by
        #3

        there is a driver in uv4l http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14 which i get half-working.
        but, when starting an application employing a qml-camera "hangs" the ui - meaning that the ui is never visible.
        if i leave preview enabled in uv4l, the camera preview is visible and running.
        no matter if preview is visible or not, the ui never shows up.

        i also get the following output when running via "GST_DEBUG="*:3" ./<app>":
        @0:00:08.941350183 3460 0xe03a00 INFO GST_STATES gstelement.c:2460:gst_element_continue_state:<camera_source> completed state change to READY
        0:00:08.944484126 3460 0xe03a00 INFO GST_STATES gstelement.c:2365:_priv_gst_element_state_changed:<camera_source> notifying about state-changed NULL to READY (VOID_PENDING pending)
        0:00:08.951060008 3460 0xe03a00 INFO default camerabingeneral.c:136:gst_camerabin_try_add_element:<camera_source> no unlinked source pad in bin
        0:00:08.953317968 3460 0xe03a00 INFO GST_ELEMENT_PADS gstelement.c:975:gst_element_get_static_pad: found pad camera_source:src
        0:00:08.955501928 3460 0xe03a00 INFO GST_ELEMENT_FACTORY gstelementfactory.c:374:gst_element_factory_create: creating element "ffmpegcolorspace" named "src-colorspace"
        0:00:08.958525875 3460 0xe03a00 INFO GST_ELEMENT_PADS gstelement.c:728:gst_element_add_pad:GstBaseTransform@0x11a6f38 adding pad 'sink'
        0:00:08.961976813 3460 0xe03a00 INFO GST_ELEMENT_PADS gstelement.c:728:gst_element_add_pad:GstBaseTransform@0x11a6f38 adding pad 'src'
        0:00:08.965648747 3460 0xe03a00 INFO GST_ELEMENT_PADS gstutils.c:1698:gst_element_link_pads_full: trying to link element camera_source:(any) to element src-colorspace:(any)
        0:00:08.968530695 3460 0xe03a00 INFO GST_PADS gstutils.c:1032:gst_pad_check_link: trying to link camera_source:src and src-colorspace:sink
        0:00:08.973310609 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1105:gst_v4l2_object_fill_format_list:<camera_source> got 7 format(s):
        0:00:08.976061559 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> YU12
        0:00:08.979186503 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> JPEG
        0:00:08.982253448 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> MJPG
        0:00:08.984377409 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> YV12 (emulated)
        0:00:08.986682369 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> BGR3 (emulated)
        0:00:08.988741331 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> RGB3 (emulated)
        0:00:08.990976291 3460 0xe03a00 INFO v4l2 gstv4l2object.c:1111:gst_v4l2_object_fill_format_list:<camera_source> H264
        @
        after that the program stops, no ui shown, camera light is on.
        looks as if driver and qt can't find a common format ...

        any ideas?

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xvause
          wrote on 7 Apr 2015, 06:10 last edited by
          #4

          Hello,

          Have you found a solution ?
          I'm trying the same, but I can't integrate my Pi Camera in a simple Qt Project...

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrdebug
            wrote on 10 Apr 2015, 09:09 last edited by
            #5

            You can use raspican, a library written in C to manage raspberry pi webcam. In the past I tryed it but I had a problem with the red light. Now I use the executable directly.

            Need programmers to hire?
            www.labcsp.com
            www.denisgottardello.it
            GMT+1
            Skype: mrdebug

            S 1 Reply Last reply 28 Jan 2016, 09:47
            0
            • S Offline
              S Offline
              Soppe
              wrote on 21 Sept 2015, 07:27 last edited by Soppe
              #6

              This is old, but in case someone else encounters this error, the fix should be the following:

              sudo rpi-update (once)
              modprobe bcm2835-v4l2 gst_v4l2src_is_broken=1 (every reboot).

              First part of modprobe is to enable the /dev/video0 stream and v4l2, the latter is to prevent camera from hanging application.

              Solution taken from here

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sandip
                wrote on 28 Jan 2016, 09:00 last edited by
                #7

                Try using https://github.com/cedricve/raspicam raspicam to capture camera image. Not sure how to display image on QOpenGLWidget. it works good to capture image from camera but OpenGL scene render not works. Anyone able to render scene using QOpenGLWidget

                1 Reply Last reply
                0
                • M mrdebug
                  10 Apr 2015, 09:09

                  You can use raspican, a library written in C to manage raspberry pi webcam. In the past I tryed it but I had a problem with the red light. Now I use the executable directly.

                  S Offline
                  S Offline
                  Sandip
                  wrote on 28 Jan 2016, 09:47 last edited by
                  #8

                  @mrdebug How did you mange to render the camera frame to QT widget? Would you please help me to render scene and display frame on QOpenGLWidget?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mrdebug
                    wrote on 30 Jan 2016, 15:11 last edited by
                    #9

                    Hi. Now I'm using the raspicam library to get images and if you want you can use QLabel to display it on a raspberry pi display. OpenGL in not mandatory.

                    Need programmers to hire?
                    www.labcsp.com
                    www.denisgottardello.it
                    GMT+1
                    Skype: mrdebug

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved