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. Any example to use libcamera for Qt5 desktop application?
QtWS25 Last Chance

Any example to use libcamera for Qt5 desktop application?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
29 Posts 7 Posters 5.3k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 6 Jul 2022, 19:50 last edited by
    #8

    Which version of Qt are you using on your Pi ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    R 1 Reply Last reply 6 Jul 2022, 22:00
    0
    • S SGaist
      6 Jul 2022, 19:50

      Which version of Qt are you using on your Pi ?

      R Offline
      R Offline
      rollyng
      wrote on 6 Jul 2022, 22:00 last edited by
      #9

      @SGaist said in Any example to use libcamera for Qt5 desktop application?:

      Which version of Qt are you using on your Pi ?

      2022-07-07-055749_1920x1080_scrot.png

      J J 2 Replies Last reply 6 Jul 2022, 22:28
      0
      • R rollyng
        6 Jul 2022, 22:00

        @SGaist said in Any example to use libcamera for Qt5 desktop application?:

        Which version of Qt are you using on your Pi ?

        2022-07-07-055749_1920x1080_scrot.png

        J Offline
        J Offline
        JonB
        wrote on 6 Jul 2022, 22:28 last edited by
        #10

        @rollyng
        Which version of Qt have you installed, not which version of Qt Creator?

        1 Reply Last reply
        0
        • R rollyng
          6 Jul 2022, 22:00

          @SGaist said in Any example to use libcamera for Qt5 desktop application?:

          Which version of Qt are you using on your Pi ?

          2022-07-07-055749_1920x1080_scrot.png

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 7 Jul 2022, 07:11 last edited by
          #11

          @rollyng Please, the Qt version mentioned in "About Qt Creator" dialog only tells what Qt version was used to build QtCreator, not what Qt version you're using to build your app!

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rollyng
            wrote on 7 Jul 2022, 15:40 last edited by
            #12

            2022-07-07-233556_1920x1080_scrot.png

            Sorry folks, please take a look. Thanks

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 7 Jul 2022, 17:49 last edited by
              #13

              Depending on your application goal, you can use a custom GStreamer pipeline.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              R 1 Reply Last reply 8 Jul 2022, 00:46
              0
              • S SGaist
                7 Jul 2022, 17:49

                Depending on your application goal, you can use a custom GStreamer pipeline.

                R Offline
                R Offline
                rollyng
                wrote on 8 Jul 2022, 00:46 last edited by
                #14

                @SGaist said in Any example to use libcamera for Qt5 desktop application?:

                Depending on your application goal, you can use a custom GStreamer pipeline.

                Hi SGaist, I would like to show the real-time image in a Qt application for preview. May I know how can I modify the camera example to do that? How can I add the GStreamer pipeline to the camera example? Thank you.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rollyng
                  wrote on 8 Jul 2022, 06:42 last edited by
                  #15

                  Hi SGaist,
                  I have also take a look at the libcamera examples. There is the "qcam" code which made use of Qt but it is not a GUI application from my understanding.
                  link text
                  Do you suggest that I can implement the "qcam" example into Qt Creator for my application? How can I start with such?
                  Thanks,
                  rolly

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JoeCFD
                    wrote on 8 Jul 2022, 13:42 last edited by JoeCFD 7 Aug 2022, 13:44
                    #16

                    You can try to use qt gstreamer to add your pipeline. Gstreamer with lower versions has pretty large memory leaks when camera is switched. If you do not switch camera often, it is ok. But it is better to install 1.20 or above in your machine. Build Qt Gstreamer with Qt 5.15.2 and higher version of gstreamer. Qt gstreamer has some examples for how to make pipelines. If you have any issues in build, post them here.

                    https://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/annotated.html

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 8 Jul 2022, 18:22 last edited by
                      #17

                      If memory serves well, Qt Creator has support for meson however yours might be too old.

                      Otherwise you can generate a minimal .pro file using qmake -project.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      R 1 Reply Last reply 9 Jul 2022, 18:03
                      0
                      • S SGaist
                        8 Jul 2022, 18:22

                        If memory serves well, Qt Creator has support for meson however yours might be too old.

                        Otherwise you can generate a minimal .pro file using qmake -project.

                        R Offline
                        R Offline
                        rollyng
                        wrote on 9 Jul 2022, 18:03 last edited by
                        #18

                        @SGaist said in Any example to use libcamera for Qt5 desktop application?:

                        If memory serves well, Qt Creator has support for meson however yours might be too old.

                        Otherwise you can generate a minimal .pro file using qmake -project.

                        Hi SGaist, thank you and I did that. Now I can open the libcamera project in Qt Creator. But some of the Qt include definitions are missing? Please take a look.
                        #include <QComboBox> for example?

                        By the way, How can I build and run qcam in Qt Creator? Simple compilation failed at once.

                        02:00:30: Running steps for project libcamera...
                        02:00:30: Starting: "/usr/lib/qt5/bin/qmake" /home/pi/code/libcamera/libcamera.pro -spec linux-g++ CONFIG+=qtquickcompiler
                        Info: creating stash file /home/pi/code/build-libcamera-Desktop-Release/.qmake.stash
                        02:00:31: The process "/usr/lib/qt5/bin/qmake" exited normally.
                        02:00:31: Starting: "/usr/bin/make" -f /home/pi/code/build-libcamera-Desktop-Release/Makefile qmake_all
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1750: warning: overriding recipe for target 'main.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1674: warning: ignoring old recipe for target 'main.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1793: warning: overriding recipe for target 'delayed_controls.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1476: warning: ignoring old recipe for target 'delayed_controls.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1805: warning: overriding recipe for target 'fence.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1488: warning: ignoring old recipe for target 'fence.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1817: warning: overriding recipe for target 'geometry.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1497: warning: ignoring old recipe for target 'geometry.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1912: warning: overriding recipe for target 'main.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1750: warning: ignoring old recipe for target 'main.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2078: warning: overriding recipe for target 'controls.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1790: warning: ignoring old recipe for target 'controls.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2087: warning: overriding recipe for target 'formats.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1808: warning: ignoring old recipe for target 'formats.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2106: warning: overriding recipe for target 'camera3_hal.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1563: warning: ignoring old recipe for target 'camera3_hal.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2133: warning: overriding recipe for target 'camera_metadata.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1597: warning: ignoring old recipe for target 'camera_metadata.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2270: warning: overriding recipe for target 'ipa_context.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2171: warning: ignoring old recipe for target 'ipa_context.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2301: warning: overriding recipe for target 'file.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1491: warning: ignoring old recipe for target 'file.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2304: warning: overriding recipe for target 'flags.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1494: warning: ignoring old recipe for target 'flags.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2310: warning: overriding recipe for target 'message.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1506: warning: ignoring old recipe for target 'message.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2316: warning: overriding recipe for target 'object.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1515: warning: ignoring old recipe for target 'object.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2325: warning: overriding recipe for target 'signal.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1530: warning: ignoring old recipe for target 'signal.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2331: warning: overriding recipe for target 'timer.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1542: warning: ignoring old recipe for target 'timer.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2337: warning: overriding recipe for target 'utils.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:1548: warning: ignoring old recipe for target 'utils.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2382: warning: overriding recipe for target 'algorithm.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2182: warning: ignoring old recipe for target 'algorithm.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2395: warning: overriding recipe for target 'histogram.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2188: warning: ignoring old recipe for target 'histogram.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2402: warning: overriding recipe for target 'agc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2363: warning: ignoring old recipe for target 'agc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2406: warning: overriding recipe for target 'awb.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2367: warning: ignoring old recipe for target 'awb.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2410: warning: overriding recipe for target 'blc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2371: warning: ignoring old recipe for target 'blc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2424: warning: overriding recipe for target 'ipu3.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2179: warning: ignoring old recipe for target 'ipu3.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2431: warning: overriding recipe for target 'raspberrypi.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2267: warning: ignoring old recipe for target 'raspberrypi.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2437: warning: overriding recipe for target 'rkisp1.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2277: warning: ignoring old recipe for target 'rkisp1.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2452: warning: overriding recipe for target 'vimc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2280: warning: ignoring old recipe for target 'vimc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2466: warning: overriding recipe for target 'agc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2402: warning: ignoring old recipe for target 'agc.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2488: warning: overriding recipe for target 'awb.o'
                        /home/pi/code/build-libcamera-Desktop-Release/Makefile:2406: warning: ignoring old recipe for target 'awb.o'
                        make: Nothing to be done for 'qmake_all'.
                        02:00:31: The process "/usr/bin/make" exited normally.
                        02:00:31: Starting: "/usr/bin/make" -j4
                        Makefile:1750: warning: overriding recipe for target 'main.o'
                        Makefile:1674: warning: ignoring old recipe for target 'main.o'
                        Makefile:1793: warning: overriding recipe for target 'delayed_controls.o'
                        Makefile:1476: warning: ignoring old recipe for target 'delayed_controls.o'
                        Makefile:1805: warning: overriding recipe for target 'fence.o'
                        Makefile:1488: warning: ignoring old recipe for target 'fence.o'
                        Makefile:1817: warning: overriding recipe for target 'geometry.o'
                        Makefile:1497: warning: ignoring old recipe for target 'geometry.o'
                        Makefile:1912: warning: overriding recipe for target 'main.o'
                        Makefile:1750: warning: ignoring old recipe for target 'main.o'
                        Makefile:2078: warning: overriding recipe for target 'controls.o'
                        Makefile:1790: warning: ignoring old recipe for target 'controls.o'
                        Makefile:2087: warning: overriding recipe for target 'formats.o'
                        Makefile:1808: warning: ignoring old recipe for target 'formats.o'
                        Makefile:2106: warning: overriding recipe for target 'camera3_hal.o'
                        Makefile:1563: warning: ignoring old recipe for target 'camera3_hal.o'
                        Makefile:2133: warning: overriding recipe for target 'camera_metadata.o'
                        Makefile:1597: warning: ignoring old recipe for target 'camera_metadata.o'
                        Makefile:2270: warning: overriding recipe for target 'ipa_context.o'
                        Makefile:2171: warning: ignoring old recipe for target 'ipa_context.o'
                        Makefile:2301: warning: overriding recipe for target 'file.o'
                        Makefile:1491: warning: ignoring old recipe for target 'file.o'
                        Makefile:2304: warning: overriding recipe for target 'flags.o'
                        Makefile:1494: warning: ignoring old recipe for target 'flags.o'
                        Makefile:2310: warning: overriding recipe for target 'message.o'
                        Makefile:1506: warning: ignoring old recipe for target 'message.o'
                        Makefile:2316: warning: overriding recipe for target 'object.o'
                        Makefile:1515: warning: ignoring old recipe for target 'object.o'
                        Makefile:2325: warning: overriding recipe for target 'signal.o'
                        Makefile:1530: warning: ignoring old recipe for target 'signal.o'
                        Makefile:2331: warning: overriding recipe for target 'timer.o'
                        Makefile:1542: warning: ignoring old recipe for target 'timer.o'
                        Makefile:2337: warning: overriding recipe for target 'utils.o'
                        Makefile:1548: warning: ignoring old recipe for target 'utils.o'
                        Makefile:2382: warning: overriding recipe for target 'algorithm.o'
                        Makefile:2182: warning: ignoring old recipe for target 'algorithm.o'
                        Makefile:2395: warning: overriding recipe for target 'histogram.o'
                        Makefile:2188: warning: ignoring old recipe for target 'histogram.o'
                        Makefile:2402: warning: overriding recipe for target 'agc.o'
                        Makefile:2363: warning: ignoring old recipe for target 'agc.o'
                        Makefile:2406: warning: overriding recipe for target 'awb.o'
                        Makefile:2367: warning: ignoring old recipe for target 'awb.o'
                        Makefile:2410: warning: overriding recipe for target 'blc.o'
                        Makefile:2371: warning: ignoring old recipe for target 'blc.o'
                        Makefile:2424: warning: overriding recipe for target 'ipu3.o'
                        Makefile:2179: warning: ignoring old recipe for target 'ipu3.o'
                        Makefile:2431: warning: overriding recipe for target 'raspberrypi.o'
                        Makefile:2267: warning: ignoring old recipe for target 'raspberrypi.o'
                        Makefile:2437: warning: overriding recipe for target 'rkisp1.o'
                        Makefile:2277: warning: ignoring old recipe for target 'rkisp1.o'
                        Makefile:2452: warning: overriding recipe for target 'vimc.o'
                        Makefile:2280: warning: ignoring old recipe for target 'vimc.o'
                        Makefile:2466: warning: overriding recipe for target 'agc.o'
                        Makefile:2402: warning: ignoring old recipe for target 'agc.o'
                        Makefile:2488: warning: overriding recipe for target 'awb.o'
                        Makefile:2406: warning: ignoring old recipe for target 'awb.o'
                        g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../libcamera -I. -I../libcamera -I/usr/include/aarch64-linux-gnu/qt5 -I/usr/include/aarch64-linux-gnu/qt5/QtGui -I/usr/include/aarch64-linux-gnu/qt5/QtCore -I. -I/usr/lib/aarch64-linux-gnu/qt5/mkspecs/linux-g++ -o bayer-format.o ../libcamera/test/bayer-format.cpp
                        g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../libcamera -I. -I../libcamera -I/usr/include/aarch64-linux-gnu/qt5 -I/usr/include/aarch64-linux-gnu/qt5/QtGui -I/usr/include/aarch64-linux-gnu/qt5/QtCore -I. -I/usr/lib/aarch64-linux-gnu/qt5/mkspecs/linux-g++ -o byte-stream-buffer.o ../libcamera/test/byte-stream-buffer.cpp
                        g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../libcamera -I. -I../libcamera -I/usr/include/aarch64-linux-gnu/qt5 -I/usr/include/aarch64-linux-gnu/qt5/QtGui -I/usr/include/aarch64-linux-gnu/qt5/QtCore -I. -I/usr/lib/aarch64-linux-gnu/qt5/mkspecs/linux-g++ -o camera-sensor.o ../libcamera/test/camera-sensor.cpp
                        g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../libcamera -I. -I../libcamera -I/usr/include/aarch64-linux-gnu/qt5 -I/usr/include/aarch64-linux-gnu/qt5/QtGui -I/usr/include/aarch64-linux-gnu/qt5/QtCore -I. -I/usr/lib/aarch64-linux-gnu/qt5/mkspecs/linux-g++ -o delayed_controls.o ../libcamera/src/libcamera/delayed_controls.cpp
                        ../libcamera/src/libcamera/delayed_controls.cpp:8:10: fatal error: libcamera/internal/delayed_controls.h: No such file or directory
                        8 | #include "libcamera/internal/delayed_controls.h"
                        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        compilation terminated.
                        make: *** [Makefile:1793: delayed_controls.o] Error 1
                        make: *** Waiting for unfinished jobs....
                        ../libcamera/test/bayer-format.cpp:10:10: fatal error: libcamera/transform.h: No such file or directory
                        10 | #include <libcamera/transform.h>
                        | ^~~~~~~~~~~~~~~~~~~~~~~
                        compilation terminated.
                        make: *** [Makefile:1467: bayer-format.o] Error 1
                        ../libcamera/test/camera-sensor.cpp:13:10: fatal error: libcamera/base/utils.h: No such file or directory
                        13 | #include <libcamera/base/utils.h>
                        | ^~~~~~~~~~~~~~~~~~~~~~~~
                        compilation terminated.
                        make: *** [Makefile:1473: camera-sensor.o] Error 1
                        ../libcamera/test/byte-stream-buffer.cpp:11:10: fatal error: libcamera/internal/byte_stream_buffer.h: No such file or directory
                        11 | #include "libcamera/internal/byte_stream_buffer.h"
                        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        compilation terminated.
                        make: *** [Makefile:1470: byte-stream-buffer.o] Error 1
                        02:00:32: The process "/usr/bin/make" exited with code 2.
                        Error while building/deploying project libcamera (kit: Desktop)
                        When executing step "Make"
                        02:00:32: Elapsed time: 00:02.

                        2022-07-10-015613_2560x1440_scrot.png

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 9 Jul 2022, 18:37 last edited by
                          #19

                          The -project options does not do deep dependencies inspection. You need to add the modules your project uses. In your case, the widgets module.

                          As for the rest, check the meson project and pick there the paths you need for the includes, librairies, etc.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1
                          • R Offline
                            R Offline
                            rollyng
                            wrote on 10 Jul 2022, 04:43 last edited by rollyng 7 Oct 2022, 12:28
                            #20

                            @SGaist said in Any example to use libcamera for Qt5 desktop application?:

                            widgets module

                            Hi SGaist, Thank you and I add the widgets and include path to the libcamera.pro file. I can see the missing header files are now found. But I have the private header error, and I have no idea how to resolve these. Please take a look. Thank you!2022-07-10-123925_2560x1440_scrot.png

                            I believe it only necessary to build the "qcam" example in Qt Creator for my purpose, so I copy "qcam" and did some modification to the qcam.pro file. But it seems unable to resolve the declaration in its own folder? as it failed to find DNGWriter which is declared in the dng_writer.h? 2022-07-10-202425_2560x1440_scrot.png

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 10 Jul 2022, 18:47 last edited by
                              #21

                              You need to read the meson file to see what additional defines and paths/options they use.

                              Just in case, even if your Qt Creator does not support meson, nothing stops you from using from the command line to build the projet.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              R 1 Reply Last reply 10 Jul 2022, 23:17
                              0
                              • S SGaist
                                10 Jul 2022, 18:47

                                You need to read the meson file to see what additional defines and paths/options they use.

                                Just in case, even if your Qt Creator does not support meson, nothing stops you from using from the command line to build the projet.

                                R Offline
                                R Offline
                                rollyng
                                wrote on 10 Jul 2022, 23:17 last edited by rollyng 7 Oct 2022, 23:22
                                #22

                                @SGaist May I ask what are these requirements in the meson file? It is strange to me that Qt Creator complains that DNGWriter is not declared despite the dng_writer.h file is already in the same directory as shown above. Besides, how should I modify the qcam.pro as the following meson file? Thank you.

                                # SPDX-License-Identifier: CC0-1.0
                                
                                qt5 = import('qt5')
                                qt5_dep = dependency('qt5',
                                                     method : 'pkg-config',
                                                     modules : ['Core', 'Gui', 'Widgets'],
                                                     required : get_option('qcam'),
                                                     version : '>=5.4')
                                
                                if not qt5_dep.found()
                                    qcam_enabled = false
                                    subdir_done()
                                endif
                                
                                qcam_enabled = true
                                
                                qcam_sources = files([
                                    '../cam/image.cpp',
                                    '../cam/options.cpp',
                                    '../cam/stream_options.cpp',
                                    'format_converter.cpp',
                                    'main.cpp',
                                    'main_window.cpp',
                                    'message_handler.cpp',
                                    'viewfinder_qt.cpp',
                                ])
                                
                                qcam_moc_headers = files([
                                    'main_window.h',
                                    'viewfinder_qt.h',
                                ])
                                
                                qcam_resources = files([
                                    'assets/feathericons/feathericons.qrc',
                                ])
                                
                                qcam_deps = [
                                    libatomic,
                                    libcamera_public,
                                    qt5_dep,
                                ]
                                
                                qt5_cpp_args = ['-DQT_NO_KEYWORDS']
                                
                                tiff_dep = dependency('libtiff-4', required : false)
                                if tiff_dep.found()
                                    qt5_cpp_args += ['-DHAVE_TIFF']
                                    qcam_deps += [tiff_dep]
                                    qcam_sources += files([
                                        'dng_writer.cpp',
                                    ])
                                endif
                                
                                if cxx.has_header_symbol('QOpenGLWidget', 'QOpenGLWidget',
                                                         dependencies : qt5_dep, args : '-fPIC')
                                    qcam_sources += files([
                                        'viewfinder_gl.cpp',
                                    ])
                                    qcam_moc_headers += files([
                                        'viewfinder_gl.h',
                                    ])
                                    qcam_resources += files([
                                        'assets/shader/shaders.qrc'
                                    ])
                                endif
                                
                                # gcc 9 introduced a deprecated-copy warning that is triggered by Qt until
                                # Qt 5.13. clang 10 introduced the same warning, but detects more issues
                                # that are not fixed in Qt yet. Disable the warning manually in both cases.
                                if ((cc.get_id() == 'gcc' and cc.version().version_compare('>=9.0') and
                                     qt5_dep.version().version_compare('<5.13')) or
                                    (cc.get_id() == 'clang' and cc.version().version_compare('>=10.0')))
                                    qt5_cpp_args += ['-Wno-deprecated-copy']
                                endif
                                
                                resources = qt5.preprocess(moc_headers: qcam_moc_headers,
                                                           qresources : qcam_resources,
                                                           dependencies: qt5_dep)
                                
                                qcam  = executable('qcam', qcam_sources, resources,
                                                   install : true,
                                                   dependencies : qcam_deps,
                                                   cpp_args : qt5_cpp_args)
                                
                                
                                1 Reply Last reply
                                0
                                • R Offline
                                  R Offline
                                  rollyng
                                  wrote on 11 Jul 2022, 03:46 last edited by
                                  #23

                                  @SGaist Hi, I have finally successful to compile qcam as my first Qt GUI code. What I did is removing the dng_writer.h and dng_writer.cpp from the project. Plz have a look, thank you!
                                  2022-07-11-114052_2560x1440_scrot.png

                                  A 1 Reply Last reply 5 Sept 2022, 07:54
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 11 Jul 2022, 20:31 last edited by
                                    #24

                                    Have a look for why you had to disable the dng_writer part ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    R 1 Reply Last reply 12 Jul 2022, 02:43
                                    0
                                    • S SGaist
                                      11 Jul 2022, 20:31

                                      Have a look for why you had to disable the dng_writer part ?

                                      R Offline
                                      R Offline
                                      rollyng
                                      wrote on 12 Jul 2022, 02:43 last edited by rollyng 7 Dec 2022, 09:22
                                      #25

                                      @SGaist said in Any example to use libcamera for Qt5 desktop application?:

                                      Have a look for why you had to disable the dng_writer part ?

                                      Qt Creator seems unable to pickup dng_writer.h although it is included in the project.

                                      This is due to a special definition in the dng_writer.h and I am including the file here for your quick look.

                                      /* SPDX-License-Identifier: LGPL-2.1-or-later */
                                      /*
                                       * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
                                       *
                                       * dng_writer.h - DNG writer
                                       */
                                      
                                      #pragma once
                                      
                                      #ifdef HAVE_TIFF /* what is this for? */
                                      #define HAVE_DNG
                                      
                                      #undef signals
                                      #undef slots
                                      #undef emit
                                      #undef foreach
                                      
                                      #include <libcamera/camera.h>
                                      #include <libcamera/controls.h>
                                      #include <libcamera/framebuffer.h>
                                      #include <libcamera/stream.h>
                                      
                                      class DNGWriter
                                      {
                                      public:
                                          static int write(const char *filename, const libcamera::Camera *camera,
                                                           const libcamera::StreamConfiguration &config,
                                                           const libcamera::ControlList &metadata,
                                                           const libcamera::FrameBuffer *buffer,
                                                           const void *data);
                                      };
                                      
                                      #endif /* HAVE_TIFF, this is going to break the definition for DNGWriter above*/
                                      

                                      This is very strange to me whether to include the HAVE_TIFF option or not?
                                      Thanks,
                                      rolly

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 12 Jul 2022, 19:33 last edited by
                                        #26

                                        It's a define that you can add to the DEFINES variable. The meson project defines it if memory serves well.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        R 1 Reply Last reply 14 Jul 2022, 10:47
                                        0
                                        • S SGaist
                                          12 Jul 2022, 19:33

                                          It's a define that you can add to the DEFINES variable. The meson project defines it if memory serves well.

                                          R Offline
                                          R Offline
                                          rollyng
                                          wrote on 14 Jul 2022, 10:47 last edited by
                                          #27

                                          @SGaist Thank you and I have decided not to include the dng_writer function as it is not my concern. Best, rolly

                                          1 Reply Last reply
                                          0

                                          17/29

                                          8 Jul 2022, 18:22

                                          • Login

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