Any example to use libcamera for Qt5 desktop application?
-
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.
-
@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)
-
Have a look for why you had to disable the dng_writer part ?
-
@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 -
It's a define that you can add to the DEFINES variable. The meson project defines it if memory serves well.