Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. CameraBin error: "Failed to allocate required memory." with QCamera
Forum Updated to NodeBB v4.3 + New Features

CameraBin error: "Failed to allocate required memory." with QCamera

Scheduled Pinned Locked Moved Solved Mobile and Embedded
18 Posts 3 Posters 4.1k Views 2 Watching
  • 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.
  • P p1ng

    @SGaist I see. Yes i just checked dependencies
    henri@henri-MS-7A72:~$ apt-cache depends libqt5multimedia5-plugins
    libqt5multimedia5-plugins
    Depends: libqt5multimedia5
    Depends: libasound2
    Depends: libc6
    Depends: libglib2.0-0
    Depends: libgstreamer-plugins-base1.0-0
    Depends: libgstreamer1.0-0
    Depends: libpulse0
    Depends: libqt5core5a
    |Depends: libqt5gui5
    Depends: libqt5gui5-gles
    Depends: libqt5multimediagsttools5
    Depends: libqt5network5
    Depends: libstdc++6

    This means i have to

    1. Remove libraries
      sudo apt-get remove libqt5multimedia5-plugins
      sudo apt-get remove libgstreamer1.0 libgstreamer-plugins-base1.0 libgstreamermm-1.0
      just in case
      sudo apt-get remove libgstreamer1.0 libgstreamer-plugins-base1.0-dev libgstreamermm-1.0

    2. Build and install gstreamer 1.22.1 from source following this guide in README:
      https://gitlab.freedesktop.org/gstreamer/gstreamer/-/tree/1.22.1

    3. Install the libq5multimedia5-plugins again
      sudo apt-get install libqt5multimedia5-plugins

    4. Cross my fingers and pray

    Is this correct?

    P Offline
    P Offline
    p1ng
    wrote on last edited by
    #9

    So this is where im at right now

    sudo apt-get remove libqt5multimedia5-plugins
    sudo apt-get remove libgstreamer1.0 libgstreamer-plugins-base1.0 libgstreamermm-1.0

    Just in case

    sudo apt-get remove libgstreamer*

    VERY IMPORTNANT TO INSTALL meson as root otherwise will get build issue

    $sudo pip3 install meson
    $sudo pip3 install markdow typogrify
    $sudo apt-get update
    $sudo apt-get install ninja-build
    $sudo apt install -y build-essential autotools-dev automake autoconf
    libtool autopoint libxml2-dev zlib1g-dev libglib2.0-dev
    pkg-config bison flex python3 git gtk-doc-tools libasound2-dev
    libgudev-1.0-dev libxt-dev libvorbis-dev libcdparanoia-dev
    libpango1.0-dev libtheora-dev libvisual-0.4-dev iso-codes
    libgtk-3-dev libraw1394-dev libiec61883-dev libavc1394-dev
    libv4l-dev libcairo2-dev libcaca-dev libspeex-dev libpng-dev
    libshout3-dev libjpeg-dev libaa1-dev libflac-dev libdv4-dev
    libtag1-dev libwavpack-dev libpulse-dev libsoup2.4-dev libbz2-dev
    libcdaudio-dev libdc1394-22-dev ladspa-sdk libass-dev
    libcurl4-gnutls-dev libdca-dev libdvdnav-dev \

    Make sure to get the tarball because checkout out 1.22.1 tag from git gave me problems i could not resolve.

    $wget https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/1.21.1/gstreamer-1.21.1.tar.gz
    $tar -xf gstreamer-1.21.1.tar.gz
    $cd gstreamer-1.21.1.tar.gz

    FFmpeg didnt compile on my RPI4 (32-it OS), so to disable it cause got some ARMv proessor arhcitecture errors.

    $meson builddir -Dgst-plugins-base:gl_winsys=egl -Dlibav=disabled
    $ninja -C builddir
    $meson setup builddir
    $meson compile -C buildir

    $sudo meson install -C builddir$ gst-launch-1.0 --version
    gst-launch-1.0: error while loading shared libraries: libgstreamer-1.0.so.0: cannot open shared object file: No such file or directory

    $sudo gedit /etc/ld.so.conf.d/randomLibs.conf
    #add this line to the file or if the ibgstreamer-1.0.so.0 was installed somewhere else add that path
    /usr/local/lib/arm-linux-gnueabihf
    sudo ldconfig

    $gst-launch-1.0 --version
    gst-launch-1.0 version 1.21.1
    GStreamer 1.21.1
    Unknown package origin

    When i try to run my app that uses QCamera this is the error i get:

    Error: cannot create camera service, the 'camerabin' plugin is missing for GStreamer 1.18.
    Please install the 'bad' GStreamer plugin package.

    I will now try to compile and install the bad plugin package with -Dbad=enabled. But im not sure if it will fix this because it seems to me that when i install sudo apt-get install qtmultimedia5-dev this will automatically install and try to use the 1.18 gstreamer - this is what i conclude from that error message.

    P 1 Reply Last reply
    0
    • P p1ng

      So this is where im at right now

      sudo apt-get remove libqt5multimedia5-plugins
      sudo apt-get remove libgstreamer1.0 libgstreamer-plugins-base1.0 libgstreamermm-1.0

      Just in case

      sudo apt-get remove libgstreamer*

      VERY IMPORTNANT TO INSTALL meson as root otherwise will get build issue

      $sudo pip3 install meson
      $sudo pip3 install markdow typogrify
      $sudo apt-get update
      $sudo apt-get install ninja-build
      $sudo apt install -y build-essential autotools-dev automake autoconf
      libtool autopoint libxml2-dev zlib1g-dev libglib2.0-dev
      pkg-config bison flex python3 git gtk-doc-tools libasound2-dev
      libgudev-1.0-dev libxt-dev libvorbis-dev libcdparanoia-dev
      libpango1.0-dev libtheora-dev libvisual-0.4-dev iso-codes
      libgtk-3-dev libraw1394-dev libiec61883-dev libavc1394-dev
      libv4l-dev libcairo2-dev libcaca-dev libspeex-dev libpng-dev
      libshout3-dev libjpeg-dev libaa1-dev libflac-dev libdv4-dev
      libtag1-dev libwavpack-dev libpulse-dev libsoup2.4-dev libbz2-dev
      libcdaudio-dev libdc1394-22-dev ladspa-sdk libass-dev
      libcurl4-gnutls-dev libdca-dev libdvdnav-dev \

      Make sure to get the tarball because checkout out 1.22.1 tag from git gave me problems i could not resolve.

      $wget https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/1.21.1/gstreamer-1.21.1.tar.gz
      $tar -xf gstreamer-1.21.1.tar.gz
      $cd gstreamer-1.21.1.tar.gz

      FFmpeg didnt compile on my RPI4 (32-it OS), so to disable it cause got some ARMv proessor arhcitecture errors.

      $meson builddir -Dgst-plugins-base:gl_winsys=egl -Dlibav=disabled
      $ninja -C builddir
      $meson setup builddir
      $meson compile -C buildir

      $sudo meson install -C builddir$ gst-launch-1.0 --version
      gst-launch-1.0: error while loading shared libraries: libgstreamer-1.0.so.0: cannot open shared object file: No such file or directory

      $sudo gedit /etc/ld.so.conf.d/randomLibs.conf
      #add this line to the file or if the ibgstreamer-1.0.so.0 was installed somewhere else add that path
      /usr/local/lib/arm-linux-gnueabihf
      sudo ldconfig

      $gst-launch-1.0 --version
      gst-launch-1.0 version 1.21.1
      GStreamer 1.21.1
      Unknown package origin

      When i try to run my app that uses QCamera this is the error i get:

      Error: cannot create camera service, the 'camerabin' plugin is missing for GStreamer 1.18.
      Please install the 'bad' GStreamer plugin package.

      I will now try to compile and install the bad plugin package with -Dbad=enabled. But im not sure if it will fix this because it seems to me that when i install sudo apt-get install qtmultimedia5-dev this will automatically install and try to use the 1.18 gstreamer - this is what i conclude from that error message.

      P Offline
      P Offline
      p1ng
      wrote on last edited by
      #10

      $meson builddir --reconfigure -Dbad=enabled -Dgst-plugins-base:gl_winsys=egl,wayland -Dlibav=disabled -Dgst-plugins-bad:camerabin2=enabled
      $meson compile -C builddir
      $meson install -C builddir

      And now my QCamera cant even detect the camera....

      Can you reccommend me some other class I could use for this camera? I see some people have used the qcam code from lib-camera. Anybody have a working project setup with that code?

      All i need is to have the cameras to be able to capture pictures and control zoom from my Qt application.

      P 1 Reply Last reply
      0
      • P p1ng

        $meson builddir --reconfigure -Dbad=enabled -Dgst-plugins-base:gl_winsys=egl,wayland -Dlibav=disabled -Dgst-plugins-bad:camerabin2=enabled
        $meson compile -C builddir
        $meson install -C builddir

        And now my QCamera cant even detect the camera....

        Can you reccommend me some other class I could use for this camera? I see some people have used the qcam code from lib-camera. Anybody have a working project setup with that code?

        All i need is to have the cameras to be able to capture pictures and control zoom from my Qt application.

        P Offline
        P Offline
        p1ng
        wrote on last edited by
        #11

        @p1ng
        So I just found out that the fix in gstreamer 1.22.1 that makes camera work with Qt is just one line in gstreamer source code. What i will try next is to check out gstreamer 1.18 source code, put that fix in it, compile and install since my qt app was able to reqonize camera when gstreamer 1.18 was installed. This is the fix if im not mistaken: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/67df248270491116af6099bf3bec5c740dfe3042
        67df2482
        v4l2h264dec: Fix Raspberry Pi4 will not play video in application

        and if that doesent work ill probably try to use qcam source from libcamera examples instead of QCamera

        P 1 Reply Last reply
        0
        • P p1ng

          @p1ng
          So I just found out that the fix in gstreamer 1.22.1 that makes camera work with Qt is just one line in gstreamer source code. What i will try next is to check out gstreamer 1.18 source code, put that fix in it, compile and install since my qt app was able to reqonize camera when gstreamer 1.18 was installed. This is the fix if im not mistaken: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/67df248270491116af6099bf3bec5c740dfe3042
          67df2482
          v4l2h264dec: Fix Raspberry Pi4 will not play video in application

          and if that doesent work ill probably try to use qcam source from libcamera examples instead of QCamera

          P Offline
          P Offline
          p1ng
          wrote on last edited by p1ng
          #12

          That didnt work out.

          # On my Ubuntu 22.04 PC
          wget https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf.zip
          git clone https://github.com/raspberrypi/usbboot.git
          cd usbboot
          # Flip the BOOT switch on RPI to ON
          sudo ./rpiboot
          wget https://github.com/balena-io/etcher/releases/download/v1.18.4/balenaEtcher-1.18.4-x64.AppImage
          chmod +x balenaEtcher-1.18.4-x64.AppImage
          ./balenaEtcher-1.18.4-x64.AppImage
          # Flashed to my RPi4 CM4
          
          
          # On my RPI4 CM4
          wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
          chmod +x install_pivariety_pkgs.sh
          2. Install libcamra-dev
          ./install_pivariety_pkgs.sh -p libcamera_dev
          3. Install libcamera-apps
          ./install_pivariety_pkgs.sh -p libcamera_apps
          4. Install the kernel driver
          ./install_pivariety_pkgs.sh -p 64mp_pi_hawk_eye_kernel_driver
          5. Configuration
          Open /boot/config.txt, under [all], add the following line:
          dtoverlay=vc4-kms-v3d,cma-512
          Example:
          [all]
          # Run as fast as firmware / board allows
          arm_boost=1
          dtoverlay=vc4-kms-v3d,cma-512
          # Enabled i2c under interfaces
          sudo raspi-config
          reboot
          
          # Compiling gstreamer 1.18
          sudo pip3 install meson
          sudo apt-get update
          # have to use gst-build for v<19 https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-meson.html?gi-language=c
          git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git
          cd gst-build
          $sudo apt install -y  build-essential autotools-dev automake autoconf \
                                              libtool autopoint libxml2-dev zlib1g-dev libglib2.0-dev \
                                              pkg-config bison flex python3 git gtk-doc-tools libasound2-dev \
                                              libgudev-1.0-dev libxt-dev libvorbis-dev libcdparanoia-dev \
                                              libpango1.0-dev libtheora-dev libvisual-0.4-dev iso-codes \
                                              libgtk-3-dev libraw1394-dev libiec61883-dev libavc1394-dev \
          									libv4l-dev libcairo2-dev libcaca-dev libspeex-dev libpng-dev \
                                              libshout3-dev libjpeg-dev libaa1-dev libflac-dev libdv4-dev \
                                              libtag1-dev libwavpack-dev libpulse-dev libsoup2.4-dev libbz2-dev \
                                              libcdaudio-dev libdc1394-22-dev ladspa-sdk libass-dev \
                                              libcurl4-gnutls-dev libdca-dev libdvdnav-dev \
          meson build --buildtype=release -Dgst-plugins-good:qt5=disabled -Dbad=enabled -Dgst-plugins-base:gl_winsys=egl -Dlibav=disabled -Dgst-plugins-bad:camerabin2=enabled
          
          # At this point i installed gstreamer tools to see if standalone gstreamer tools will play my cameras
          # install a missing dependency
          $ sudo apt-get install libx264-dev libjpeg-dev
          # install the remaining plugins
          $ sudo apt-get install libgstreamer1.0-dev \
               libgstreamer-plugins-base1.0-dev \
               libgstreamer-plugins-bad1.0-dev \
               gstreamer1.0-plugins-ugly \
               gstreamer1.0-tools \
               gstreamer1.0-gl \
               gstreamer1.0-gtk3 
          
          # Confirmed that current standalone gsteamer plays video. 
          gst-launch-1.0 libcamerasrc ! video/x-raw, width=640, height=480, framerate=30/1 ! videoconvert ! videoscale ! clockoverlay time-format="%D %H:%M:%S" ! autovideosink
          
          # This made me curious to install qt and try to run camera example project to confirm it dosent work before i try to compile & install the 1.18.6 version
          sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools 
          sudo apt-get install cmake
          sudo apt-get install clan
          sudo apt-get install qtmultimedia5-dev 
          sudo apt-get install qtcreator
          ~/Qt/5.14.2/Examples/Qt-5.14.2$ scp -r multimediawidgets pi@192.168.88.249:/home/pi/Desktop/Examples
          ~/Qt/5.14.2/Examples/Qt-5.14.2$ scp -r multimediawidgets pi@192.168.88.249:/home/pi/Desktop/multimedia
          
          # Built and compiled the Examples/camera in qtcreator but got error "CameraService is missing"
          sudo apt-get install libqt5multimedia5-plugins
          
          # Now i get the CameraBin error: "Failed to allocate memory". So proceed with meson compilation
          
          # I also checked the version of different gstreamer libraries/tools i currenlty have installed
          pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ dpkg -l | grep gstream*
          ii  gir1.2-gstreamer-1.0:armhf             1.18.4-2.1                       armhf        GObject introspection data for the GStreamer library
          ii  gstreamer1.0-alsa:armhf                1.18.4-2                         armhf        GStreamer plugin for ALSA
          ii  gstreamer1.0-gl:armhf                  1.18.4-2                         armhf        GStreamer plugins for GL
          ii  gstreamer1.0-gtk3:armhf                1.18.4-2+deb11u1+rpt1            armhf        GStreamer plugin for GTK+3
          ii  gstreamer1.0-libav:armhf               1.18.4-3                         armhf        ffmpeg plugin for GStreamer
          ii  gstreamer1.0-omx                       1.0.0.1-0+rpi12+jessiepmg        armhf        GStreamer OpenMAX plugins
          ii  gstreamer1.0-plugins-bad:armhf         1.18.4-3                         armhf        GStreamer plugins from the "bad" set
          ii  gstreamer1.0-plugins-base:armhf        1.18.4-2                         armhf        GStreamer plugins from the "base" set
          ii  gstreamer1.0-plugins-good:armhf        1.18.4-2                         armhf        GStreamer plugins from the "good" set
          ii  gstreamer1.0-plugins-ugly:armhf        1.18.4-2                         armhf        GStreamer plugins from the "ugly" set
          ii  gstreamer1.0-tools                     1.18.4-2.1                       armhf        Tools for use with GStreamer
          ii  gstreamer1.0-x:armhf                   1.18.4-2                         armhf        GStreamer plugins for X11 and Pango
          ii  libgstreamer-gl1.0-0:armhf             1.18.4-2                         armhf        GStreamer GL libraries
          ii  libgstreamer-opencv1.0-0:armhf         1.18.4-3                         armhf        GStreamer OpenCV libraries
          ii  libgstreamer-plugins-bad1.0-0:armhf    1.18.4-3                         armhf        GStreamer libraries from the "bad" set
          ii  libgstreamer-plugins-bad1.0-dev:armhf  1.18.4-3                         armhf        GStreamer development files for libraries from the "bad" set
          ii  libgstreamer-plugins-base1.0-0:armhf   1.18.4-2                         armhf        GStreamer libraries from the "base" set
          ii  libgstreamer-plugins-base1.0-dev:armhf 1.18.4-2                         armhf        GStreamer development files for libraries from the "base" set
          ii  libgstreamer1.0-0:armhf                1.18.4-2.1                       armhf        Core GStreamer libraries and elements
          ii  libgstreamer1.0-dev:armhf              1.18.4-2.1                       armhf        GStreamer core development files
          ii  libqt5gstreamer-1.0-0:armhf            1.2.0-5.1                        armhf        C++ bindings library for GStreamer with a Qt-style API - Qt 5 build
          
          pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ apt list | grep libqt5multimedia5-plugins
          libqt5multimedia5-plugins/stable,now 5.15.2-3 armhf [installed]
          
          # Compile 
          pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ cp subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c_backup
          pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ nano subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c
          
          #Search for method gst_v4l2_object_stop and replace it with 
          gboolean
          gst_v4l2_object_stop (GstV4l2Object * v4l2object)
          {
            GstBufferPool *pool;
            GST_DEBUG_OBJECT (v4l2object->dbg_obj, "stopping");
          
            if (!GST_V4L2_IS_OPEN (v4l2object))
              goto done;
            if (!GST_V4L2_IS_ACTIVE (v4l2object))
              goto done;
          
            pool = gst_v4l2_object_get_buffer_pool (v4l2object);
            if (pool) {
              if (!gst_v4l2_buffer_pool_orphan (v4l2object)) {
                GST_DEBUG_OBJECT (v4l2object->dbg_obj, "deactivating pool");
                gst_buffer_pool_set_active (pool, FALSE);
          
                {
                  GstBufferPool *old_pool;
                  GST_OBJECT_LOCK (v4l2object->element);
                  old_pool = v4l2object->pool;
                  v4l2object->pool = NULL;
                  GST_OBJECT_UNLOCK (v4l2object->element);
                  if (old_pool)
                    gst_object_unref (old_pool);
                }
              }
              gst_object_unref (pool);
            }
          
            GST_V4L2_SET_INACTIVE (v4l2object);
          
          done:
            return TRUE;
          }
          
          # Add gst_v4l2_object_get_buffer_pool methdo to the end of the file
          
          GstBufferPool *
          gst_v4l2_object_get_buffer_pool (GstV4l2Object * v4l2object)
          {
            GstBufferPool *ret = NULL;
          
            g_return_val_if_fail (v4l2object != NULL, NULL);
          
            GST_OBJECT_LOCK (v4l2object->element);
            if (v4l2object->pool)
              ret = gst_object_ref (v4l2object->pool);
            GST_OBJECT_UNLOCK (v4l2object->element);
          
            return ret;
          }
          
          # Add this line to subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.h at the end of /* probing */ block 
          GstBufferPool * gst_v4l2_object_get_buffer_pool (GstV4l2Object * v4l2object);
          
          # Now compile gstreamer 1.18.6
          ninja -C build
          sudo ninja -C build install
          
          pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $  dpkg -l | grep gstream*
          ii  gir1.2-gstreamer-1.0:armhf             1.18.4-2.1                       armhf        GObject introspection data for the GStreamer library
          ii  gstreamer1.0-alsa:armhf                1.18.4-2                         armhf        GStreamer plugin for ALSA
          ii  gstreamer1.0-gl:armhf                  1.18.4-2                         armhf        GStreamer plugins for GL
          ii  gstreamer1.0-gtk3:armhf                1.18.4-2+deb11u1+rpt1            armhf        GStreamer plugin for GTK+3
          ii  gstreamer1.0-libav:armhf               1.18.4-3                         armhf        ffmpeg plugin for GStreamer
          ii  gstreamer1.0-omx                       1.0.0.1-0+rpi12+jessiepmg        armhf        GStreamer OpenMAX plugins
          ii  gstreamer1.0-plugins-bad:armhf         1.18.4-3                         armhf        GStreamer plugins from the "bad" set
          ii  gstreamer1.0-plugins-base:armhf        1.18.4-2                         armhf        GStreamer plugins from the "base" set
          ii  gstreamer1.0-plugins-good:armhf        1.18.4-2                         armhf        GStreamer plugins from the "good" set
          ii  gstreamer1.0-plugins-ugly:armhf        1.18.4-2                         armhf        GStreamer plugins from the "ugly" set
          ii  gstreamer1.0-tools                     1.18.4-2.1                       armhf        Tools for use with GStreamer
          ii  gstreamer1.0-x:armhf                   1.18.4-2                         armhf        GStreamer plugins for X11 and Pango
          ii  libgstreamer-gl1.0-0:armhf             1.18.4-2                         armhf        GStreamer GL libraries
          ii  libgstreamer-opencv1.0-0:armhf         1.18.4-3                         armhf        GStreamer OpenCV libraries
          ii  libgstreamer-plugins-bad1.0-0:armhf    1.18.4-3                         armhf        GStreamer libraries from the "bad" set
          ii  libgstreamer-plugins-bad1.0-dev:armhf  1.18.4-3                         armhf        GStreamer development files for libraries from the "bad" set
          ii  libgstreamer-plugins-base1.0-0:armhf   1.18.4-2                         armhf        GStreamer libraries from the "base" set
          ii  libgstreamer-plugins-base1.0-dev:armhf 1.18.4-2                         armhf        GStreamer development files for libraries from the "base" set
          ii  libgstreamer1.0-0:armhf                1.18.4-2.1                       armhf        Core GStreamer libraries and elements
          ii  libgstreamer1.0-dev:armhf              1.18.4-2.1                       armhf        GStreamer core development files
          ii  libqt5gstreamer-1.0-0:armhf            1.2.0-5.1                        armhf        C++ bindings library for GStreamer with a Qt-style API - Qt 5 build
          
          # So the packages i compiled were not replace with packages from remote repo i installed with apt-get
          sudo apt-get remove gstreamer1.0-plugins-good
          
          # Now when i do
          pi@raspberrypi:~ $ gst-launch-1.0 --version
          gst-launch-1.0 version 1.18.6
          GStreamer 1.18.6
          Unknown package origin
          
          # But after that removal the gst-launch-1.0 cant play back camera anymore. Maybe it was my "fix" in code that broke it. Ill roll that back and rebuild
          # So what i did now is that i uninstalled everything related to gstreamer
          sudo apt-get remove libgstreamer* libqt5gstreamer* gstreamer1.0*
          
          
          

          at this point i give up and work on some other stuff. maybe over time somebody will fix it for qt5 or ill try to use libcamera https://git.libcamera.org/libcamera/libcamera.git/tree/src/apps/qcam instead of QCamera or ill see if my camera works in qt6.

          P 1 Reply Last reply
          0
          • P p1ng

            That didnt work out.

            # On my Ubuntu 22.04 PC
            wget https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf.zip
            git clone https://github.com/raspberrypi/usbboot.git
            cd usbboot
            # Flip the BOOT switch on RPI to ON
            sudo ./rpiboot
            wget https://github.com/balena-io/etcher/releases/download/v1.18.4/balenaEtcher-1.18.4-x64.AppImage
            chmod +x balenaEtcher-1.18.4-x64.AppImage
            ./balenaEtcher-1.18.4-x64.AppImage
            # Flashed to my RPi4 CM4
            
            
            # On my RPI4 CM4
            wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
            chmod +x install_pivariety_pkgs.sh
            2. Install libcamra-dev
            ./install_pivariety_pkgs.sh -p libcamera_dev
            3. Install libcamera-apps
            ./install_pivariety_pkgs.sh -p libcamera_apps
            4. Install the kernel driver
            ./install_pivariety_pkgs.sh -p 64mp_pi_hawk_eye_kernel_driver
            5. Configuration
            Open /boot/config.txt, under [all], add the following line:
            dtoverlay=vc4-kms-v3d,cma-512
            Example:
            [all]
            # Run as fast as firmware / board allows
            arm_boost=1
            dtoverlay=vc4-kms-v3d,cma-512
            # Enabled i2c under interfaces
            sudo raspi-config
            reboot
            
            # Compiling gstreamer 1.18
            sudo pip3 install meson
            sudo apt-get update
            # have to use gst-build for v<19 https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-meson.html?gi-language=c
            git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git
            cd gst-build
            $sudo apt install -y  build-essential autotools-dev automake autoconf \
                                                libtool autopoint libxml2-dev zlib1g-dev libglib2.0-dev \
                                                pkg-config bison flex python3 git gtk-doc-tools libasound2-dev \
                                                libgudev-1.0-dev libxt-dev libvorbis-dev libcdparanoia-dev \
                                                libpango1.0-dev libtheora-dev libvisual-0.4-dev iso-codes \
                                                libgtk-3-dev libraw1394-dev libiec61883-dev libavc1394-dev \
            									libv4l-dev libcairo2-dev libcaca-dev libspeex-dev libpng-dev \
                                                libshout3-dev libjpeg-dev libaa1-dev libflac-dev libdv4-dev \
                                                libtag1-dev libwavpack-dev libpulse-dev libsoup2.4-dev libbz2-dev \
                                                libcdaudio-dev libdc1394-22-dev ladspa-sdk libass-dev \
                                                libcurl4-gnutls-dev libdca-dev libdvdnav-dev \
            meson build --buildtype=release -Dgst-plugins-good:qt5=disabled -Dbad=enabled -Dgst-plugins-base:gl_winsys=egl -Dlibav=disabled -Dgst-plugins-bad:camerabin2=enabled
            
            # At this point i installed gstreamer tools to see if standalone gstreamer tools will play my cameras
            # install a missing dependency
            $ sudo apt-get install libx264-dev libjpeg-dev
            # install the remaining plugins
            $ sudo apt-get install libgstreamer1.0-dev \
                 libgstreamer-plugins-base1.0-dev \
                 libgstreamer-plugins-bad1.0-dev \
                 gstreamer1.0-plugins-ugly \
                 gstreamer1.0-tools \
                 gstreamer1.0-gl \
                 gstreamer1.0-gtk3 
            
            # Confirmed that current standalone gsteamer plays video. 
            gst-launch-1.0 libcamerasrc ! video/x-raw, width=640, height=480, framerate=30/1 ! videoconvert ! videoscale ! clockoverlay time-format="%D %H:%M:%S" ! autovideosink
            
            # This made me curious to install qt and try to run camera example project to confirm it dosent work before i try to compile & install the 1.18.6 version
            sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools 
            sudo apt-get install cmake
            sudo apt-get install clan
            sudo apt-get install qtmultimedia5-dev 
            sudo apt-get install qtcreator
            ~/Qt/5.14.2/Examples/Qt-5.14.2$ scp -r multimediawidgets pi@192.168.88.249:/home/pi/Desktop/Examples
            ~/Qt/5.14.2/Examples/Qt-5.14.2$ scp -r multimediawidgets pi@192.168.88.249:/home/pi/Desktop/multimedia
            
            # Built and compiled the Examples/camera in qtcreator but got error "CameraService is missing"
            sudo apt-get install libqt5multimedia5-plugins
            
            # Now i get the CameraBin error: "Failed to allocate memory". So proceed with meson compilation
            
            # I also checked the version of different gstreamer libraries/tools i currenlty have installed
            pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ dpkg -l | grep gstream*
            ii  gir1.2-gstreamer-1.0:armhf             1.18.4-2.1                       armhf        GObject introspection data for the GStreamer library
            ii  gstreamer1.0-alsa:armhf                1.18.4-2                         armhf        GStreamer plugin for ALSA
            ii  gstreamer1.0-gl:armhf                  1.18.4-2                         armhf        GStreamer plugins for GL
            ii  gstreamer1.0-gtk3:armhf                1.18.4-2+deb11u1+rpt1            armhf        GStreamer plugin for GTK+3
            ii  gstreamer1.0-libav:armhf               1.18.4-3                         armhf        ffmpeg plugin for GStreamer
            ii  gstreamer1.0-omx                       1.0.0.1-0+rpi12+jessiepmg        armhf        GStreamer OpenMAX plugins
            ii  gstreamer1.0-plugins-bad:armhf         1.18.4-3                         armhf        GStreamer plugins from the "bad" set
            ii  gstreamer1.0-plugins-base:armhf        1.18.4-2                         armhf        GStreamer plugins from the "base" set
            ii  gstreamer1.0-plugins-good:armhf        1.18.4-2                         armhf        GStreamer plugins from the "good" set
            ii  gstreamer1.0-plugins-ugly:armhf        1.18.4-2                         armhf        GStreamer plugins from the "ugly" set
            ii  gstreamer1.0-tools                     1.18.4-2.1                       armhf        Tools for use with GStreamer
            ii  gstreamer1.0-x:armhf                   1.18.4-2                         armhf        GStreamer plugins for X11 and Pango
            ii  libgstreamer-gl1.0-0:armhf             1.18.4-2                         armhf        GStreamer GL libraries
            ii  libgstreamer-opencv1.0-0:armhf         1.18.4-3                         armhf        GStreamer OpenCV libraries
            ii  libgstreamer-plugins-bad1.0-0:armhf    1.18.4-3                         armhf        GStreamer libraries from the "bad" set
            ii  libgstreamer-plugins-bad1.0-dev:armhf  1.18.4-3                         armhf        GStreamer development files for libraries from the "bad" set
            ii  libgstreamer-plugins-base1.0-0:armhf   1.18.4-2                         armhf        GStreamer libraries from the "base" set
            ii  libgstreamer-plugins-base1.0-dev:armhf 1.18.4-2                         armhf        GStreamer development files for libraries from the "base" set
            ii  libgstreamer1.0-0:armhf                1.18.4-2.1                       armhf        Core GStreamer libraries and elements
            ii  libgstreamer1.0-dev:armhf              1.18.4-2.1                       armhf        GStreamer core development files
            ii  libqt5gstreamer-1.0-0:armhf            1.2.0-5.1                        armhf        C++ bindings library for GStreamer with a Qt-style API - Qt 5 build
            
            pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ apt list | grep libqt5multimedia5-plugins
            libqt5multimedia5-plugins/stable,now 5.15.2-3 armhf [installed]
            
            # Compile 
            pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ cp subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c_backup
            pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $ nano subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c
            
            #Search for method gst_v4l2_object_stop and replace it with 
            gboolean
            gst_v4l2_object_stop (GstV4l2Object * v4l2object)
            {
              GstBufferPool *pool;
              GST_DEBUG_OBJECT (v4l2object->dbg_obj, "stopping");
            
              if (!GST_V4L2_IS_OPEN (v4l2object))
                goto done;
              if (!GST_V4L2_IS_ACTIVE (v4l2object))
                goto done;
            
              pool = gst_v4l2_object_get_buffer_pool (v4l2object);
              if (pool) {
                if (!gst_v4l2_buffer_pool_orphan (v4l2object)) {
                  GST_DEBUG_OBJECT (v4l2object->dbg_obj, "deactivating pool");
                  gst_buffer_pool_set_active (pool, FALSE);
            
                  {
                    GstBufferPool *old_pool;
                    GST_OBJECT_LOCK (v4l2object->element);
                    old_pool = v4l2object->pool;
                    v4l2object->pool = NULL;
                    GST_OBJECT_UNLOCK (v4l2object->element);
                    if (old_pool)
                      gst_object_unref (old_pool);
                  }
                }
                gst_object_unref (pool);
              }
            
              GST_V4L2_SET_INACTIVE (v4l2object);
            
            done:
              return TRUE;
            }
            
            # Add gst_v4l2_object_get_buffer_pool methdo to the end of the file
            
            GstBufferPool *
            gst_v4l2_object_get_buffer_pool (GstV4l2Object * v4l2object)
            {
              GstBufferPool *ret = NULL;
            
              g_return_val_if_fail (v4l2object != NULL, NULL);
            
              GST_OBJECT_LOCK (v4l2object->element);
              if (v4l2object->pool)
                ret = gst_object_ref (v4l2object->pool);
              GST_OBJECT_UNLOCK (v4l2object->element);
            
              return ret;
            }
            
            # Add this line to subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.h at the end of /* probing */ block 
            GstBufferPool * gst_v4l2_object_get_buffer_pool (GstV4l2Object * v4l2object);
            
            # Now compile gstreamer 1.18.6
            ninja -C build
            sudo ninja -C build install
            
            pi@raspberrypi:~/devdirs/gst-1.18.6/gst-build $  dpkg -l | grep gstream*
            ii  gir1.2-gstreamer-1.0:armhf             1.18.4-2.1                       armhf        GObject introspection data for the GStreamer library
            ii  gstreamer1.0-alsa:armhf                1.18.4-2                         armhf        GStreamer plugin for ALSA
            ii  gstreamer1.0-gl:armhf                  1.18.4-2                         armhf        GStreamer plugins for GL
            ii  gstreamer1.0-gtk3:armhf                1.18.4-2+deb11u1+rpt1            armhf        GStreamer plugin for GTK+3
            ii  gstreamer1.0-libav:armhf               1.18.4-3                         armhf        ffmpeg plugin for GStreamer
            ii  gstreamer1.0-omx                       1.0.0.1-0+rpi12+jessiepmg        armhf        GStreamer OpenMAX plugins
            ii  gstreamer1.0-plugins-bad:armhf         1.18.4-3                         armhf        GStreamer plugins from the "bad" set
            ii  gstreamer1.0-plugins-base:armhf        1.18.4-2                         armhf        GStreamer plugins from the "base" set
            ii  gstreamer1.0-plugins-good:armhf        1.18.4-2                         armhf        GStreamer plugins from the "good" set
            ii  gstreamer1.0-plugins-ugly:armhf        1.18.4-2                         armhf        GStreamer plugins from the "ugly" set
            ii  gstreamer1.0-tools                     1.18.4-2.1                       armhf        Tools for use with GStreamer
            ii  gstreamer1.0-x:armhf                   1.18.4-2                         armhf        GStreamer plugins for X11 and Pango
            ii  libgstreamer-gl1.0-0:armhf             1.18.4-2                         armhf        GStreamer GL libraries
            ii  libgstreamer-opencv1.0-0:armhf         1.18.4-3                         armhf        GStreamer OpenCV libraries
            ii  libgstreamer-plugins-bad1.0-0:armhf    1.18.4-3                         armhf        GStreamer libraries from the "bad" set
            ii  libgstreamer-plugins-bad1.0-dev:armhf  1.18.4-3                         armhf        GStreamer development files for libraries from the "bad" set
            ii  libgstreamer-plugins-base1.0-0:armhf   1.18.4-2                         armhf        GStreamer libraries from the "base" set
            ii  libgstreamer-plugins-base1.0-dev:armhf 1.18.4-2                         armhf        GStreamer development files for libraries from the "base" set
            ii  libgstreamer1.0-0:armhf                1.18.4-2.1                       armhf        Core GStreamer libraries and elements
            ii  libgstreamer1.0-dev:armhf              1.18.4-2.1                       armhf        GStreamer core development files
            ii  libqt5gstreamer-1.0-0:armhf            1.2.0-5.1                        armhf        C++ bindings library for GStreamer with a Qt-style API - Qt 5 build
            
            # So the packages i compiled were not replace with packages from remote repo i installed with apt-get
            sudo apt-get remove gstreamer1.0-plugins-good
            
            # Now when i do
            pi@raspberrypi:~ $ gst-launch-1.0 --version
            gst-launch-1.0 version 1.18.6
            GStreamer 1.18.6
            Unknown package origin
            
            # But after that removal the gst-launch-1.0 cant play back camera anymore. Maybe it was my "fix" in code that broke it. Ill roll that back and rebuild
            # So what i did now is that i uninstalled everything related to gstreamer
            sudo apt-get remove libgstreamer* libqt5gstreamer* gstreamer1.0*
            
            
            

            at this point i give up and work on some other stuff. maybe over time somebody will fix it for qt5 or ill try to use libcamera https://git.libcamera.org/libcamera/libcamera.git/tree/src/apps/qcam instead of QCamera or ill see if my camera works in qt6.

            P Offline
            P Offline
            p1ng
            wrote on last edited by
            #13

            @p1ng I gave it one more try. Compiled qt5.15.2 from source, then cross-compiled it for RPI4, 32-bit bullseye 6.1.xx

            Compiled gstreamer 1.22.1 from source that i thought has fix for it.

            Then ran my qt app that uses Camera, i get the same failed to allocate required memory error.

            Running gstreamer from command line gives the same error:
            gst-launch-1.0 -v v4l2src device=/dev/video0 ! fbdevsink

            From this i conclude that the issue has not been fixed in gstreamer and i have to use libcamera qcam example to get qt into my raspberry qt app.

            P 1 Reply Last reply
            0
            • P p1ng

              @p1ng I gave it one more try. Compiled qt5.15.2 from source, then cross-compiled it for RPI4, 32-bit bullseye 6.1.xx

              Compiled gstreamer 1.22.1 from source that i thought has fix for it.

              Then ran my qt app that uses Camera, i get the same failed to allocate required memory error.

              Running gstreamer from command line gives the same error:
              gst-launch-1.0 -v v4l2src device=/dev/video0 ! fbdevsink

              From this i conclude that the issue has not been fixed in gstreamer and i have to use libcamera qcam example to get qt into my raspberry qt app.

              P Offline
              P Offline
              p1ng
              wrote on last edited by
              #14

              @p1ng If i give gstreamer libcamerasrc though then the camera preview works
              gst-launch-1.0 libcamerasrc ! glimagesink

              what would i need to modify in QT source code for it to use libcamerasrc?
              something in gstreamercamerabin?

              1 Reply Last reply
              0
              • P Offline
                P Offline
                p1ng
                wrote on last edited by
                #15

                I managed to convert libcamera simple-cam meson example to QT project. I used chatgpt to convert meson.build to .pro file. For those in the future who are struggling integrating libcamera to qt i have uploaded the project to https://github.com/henrihallik/simple-cam-qt.
                Also chatgpt proved vital working through various linker errors that occured. So if u need more help , just ask OpenAIs chatgpt. https://chat.openai.com/chat

                P 1 Reply Last reply
                0
                • P p1ng

                  I managed to convert libcamera simple-cam meson example to QT project. I used chatgpt to convert meson.build to .pro file. For those in the future who are struggling integrating libcamera to qt i have uploaded the project to https://github.com/henrihallik/simple-cam-qt.
                  Also chatgpt proved vital working through various linker errors that occured. So if u need more help , just ask OpenAIs chatgpt. https://chat.openai.com/chat

                  P Offline
                  P Offline
                  p1ng
                  wrote on last edited by
                  #16

                  @p1ng so the simple-cam-qt was too difficult to figure out how to modify to capture an image with set resoluton. So I converted libcameras qcam project to qt project that already has image capture functionality in it.
                  U can get it here if u want to:

                  https://github.com/henrihallik/myqam

                  P 1 Reply Last reply
                  0
                  • P p1ng

                    @p1ng so the simple-cam-qt was too difficult to figure out how to modify to capture an image with set resoluton. So I converted libcameras qcam project to qt project that already has image capture functionality in it.
                    U can get it here if u want to:

                    https://github.com/henrihallik/myqam

                    P Offline
                    P Offline
                    p1ng
                    wrote on last edited by
                    #17

                    @p1ng The qcam was still too difficult to integrate. I found edwards libcamera-cpp-demo by far the simplest example to integrate libcamera to my own code:
                    https://github.com/edward-ardu/libcamera-cpp-demo

                    My slightly modified version of this that specifies multiple cameras:
                    https://github.com/edward-ardu/libcamera-cpp-demo/tree/7b3f9b97a479fb49beb01db1ddd77f5090fa52dc

                    JoeCFDJ 1 Reply Last reply
                    0
                    • P p1ng has marked this topic as solved on
                    • P p1ng

                      @p1ng The qcam was still too difficult to integrate. I found edwards libcamera-cpp-demo by far the simplest example to integrate libcamera to my own code:
                      https://github.com/edward-ardu/libcamera-cpp-demo

                      My slightly modified version of this that specifies multiple cameras:
                      https://github.com/edward-ardu/libcamera-cpp-demo/tree/7b3f9b97a479fb49beb01db1ddd77f5090fa52dc

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by JoeCFD
                      #18

                      @p1ng Try 1.22.3 and it has more bug fixes.

                      the steps(order) to install the latest gstreamer

                      1. you may need to get the latest libva and build it.
                      2. build gstreamer and make sure all needed plugins are built.
                      3. build the driver of graphics card(for examples: media driver from Intel).
                      4. build camera llib and Qt multimedia plugin
                      5. set lib/bin path for installed gstreamer and export new driver path LIBVA_DRIVERS_PATH

                      Since it is easy to make mistakes in gstreamer build, do not try to install it in default dirs like /usr/lib etc. Instead install all packages under /opt/gstreamer. In case anything goes wrong, you can remove the whole installation and redo it. Otherwise, you may have difficulty to use videos on your machine later on. Some installations can not be removed automatically and you have to remove them manually. Things can get very messy.

                      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