Libcamera_cpp_demo-master

Trying to compile: libcamera_cpp_demo-master
Looking for suggestions.
Getting the following:

 make -j4
[ 66%] Building CXX object CMakeFiles/libcamera-demo.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/libcamera-demo.dir/LibCamera.cpp.o
In file included from /usr/include/libcamera/libcamera/stream.h:15,
                 from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.cpp:1:
/usr/include/libcamera/libcamera/color_space.h:61:41: error: ‘optional’ in namespace ‘std’ does not name a template type
   61 |  static std::string toString(const std::optional<ColorSpace> &colorSpace);
      |                                         ^~~~~~~~
/usr/include/libcamera/libcamera/color_space.h:61:36: note: ‘std::optional’ is only available from C++17 onwards
   61 |  static std::string toString(const std::optional<ColorSpace> &colorSpace);
      |                                    ^~~
/usr/include/libcamera/libcamera/color_space.h:61:49: error: expected ‘,’ or ‘...’ before ‘<’ token
   61 |  static std::string toString(const std::optional<ColorSpace> &colorSpace);
      |                                                 ^
In file included from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.cpp:1:
/usr/include/libcamera/libcamera/stream.h:51:7: error: ‘optional’ in namespace ‘std’ does not name a template type
   51 |  std::optional<ColorSpace> colorSpace;
      |       ^~~~~~~~
/usr/include/libcamera/libcamera/stream.h:51:2: note: ‘std::optional’ is only available from C++17 onwards
   51 |  std::optional<ColorSpace> colorSpace;
      |  ^~~
/home/pi/libcamera_cpp_demo-master/LibCamera.cpp: In member function ‘int LibCamera::startCapture()’:
/home/pi/libcamera_cpp_demo-master/LibCamera.cpp:109:38: error: ‘const class libcamera::SharedFD’ has no member named ‘fd’; did you mean ‘std::shared_ptr<libcamera::SharedFD::Descriptor> libcamera::SharedFD::fd_’? (not accessible from this context)
  109 |                             plane.fd.fd(), 0);
      |                                      ^~
In file included from /usr/include/libcamera/libcamera/framebuffer.h:17,
                 from /usr/include/libcamera/libcamera/stream.h:16,
                 from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.cpp:1:
/usr/include/libcamera/libcamera/base/shared_fd.h:46:30: note: declared private here
   46 |  std::shared_ptr<Descriptor> fd_;
      |                              ^~~
/home/pi/libcamera_cpp_demo-master/LibCamera.cpp:110:41: error: ‘const class libcamera::SharedFD’ has no member named ‘fd’; did you mean ‘std::shared_ptr<libcamera::SharedFD::Descriptor> libcamera::SharedFD::fd_’? (not accessible from this context)
  110 |                 mappedBuffers_[plane.fd.fd()] =
      |                                         ^~
In file included from /usr/include/libcamera/libcamera/framebuffer.h:17,
                 from /usr/include/libcamera/libcamera/stream.h:16,
                 from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.cpp:1:
/usr/include/libcamera/libcamera/base/shared_fd.h:46:30: note: declared private here
   46 |  std::shared_ptr<Descriptor> fd_;
      |                              ^~~
/home/pi/libcamera_cpp_demo-master/LibCamera.cpp: In member function ‘bool LibCamera::readFrame(LibcameraOutData*)’:
/home/pi/libcamera_cpp_demo-master/LibCamera.cpp:178:54: error: ‘const class libcamera::SharedFD’ has no member named ‘fd’; did you mean ‘std::shared_ptr<libcamera::SharedFD::Descriptor> libcamera::SharedFD::fd_’? (not accessible from this context)
  178 |                 void *data = mappedBuffers_[plane.fd.fd()].first;
      |                                                      ^~
In file included from /usr/include/libcamera/libcamera/framebuffer.h:17,
                 from /usr/include/libcamera/libcamera/stream.h:16,
                 from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.cpp:1:
/usr/include/libcamera/libcamera/base/shared_fd.h:46:30: note: declared private here
   46 |  std::shared_ptr<Descriptor> fd_;
      |                              ^~~
make[2]: *** [CMakeFiles/libcamera-demo.dir/build.make:95: CMakeFiles/libcamera-demo.dir/LibCamera.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /usr/include/libcamera/libcamera/stream.h:15,
                 from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/main.cpp:6:
/usr/include/libcamera/libcamera/color_space.h:61:41: error: ‘optional’ in namespace ‘std’ does not name a template type
   61 |  static std::string toString(const std::optional<ColorSpace> &colorSpace);
      |                                         ^~~~~~~~
/usr/include/libcamera/libcamera/color_space.h:61:36: note: ‘std::optional’ is only available from C++17 onwards
   61 |  static std::string toString(const std::optional<ColorSpace> &colorSpace);
      |                                    ^~~
/usr/include/libcamera/libcamera/color_space.h:61:49: error: expected ‘,’ or ‘...’ before ‘<’ token
   61 |  static std::string toString(const std::optional<ColorSpace> &colorSpace);
      |                                                 ^
In file included from /usr/include/libcamera/libcamera/camera.h:22,
                 from /usr/include/libcamera/libcamera/libcamera.h:11,
                 from /home/pi/libcamera_cpp_demo-master/LibCamera.h:21,
                 from /home/pi/libcamera_cpp_demo-master/main.cpp:6:
/usr/include/libcamera/libcamera/stream.h:51:7: error: ‘optional’ in namespace ‘std’ does not name a template type
   51 |  std::optional<ColorSpace> colorSpace;
      |       ^~~~~~~~
/usr/include/libcamera/libcamera/stream.h:51:2: note: ‘std::optional’ is only available from C++17 onwards
   51 |  std::optional<ColorSpace> colorSpace;
      |  ^~~
make[2]: *** [CMakeFiles/libcamera-demo.dir/build.make:82: CMakeFiles/libcamera-demo.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/libcamera-demo.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

In CMakeLists.txt the following sb added:

# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

In LibCamera.cpp
plane.fd.fd() should be replaced with plane.fd.get()

It should now compile but will yield the following error at runtime:

[20:19:27.955246663] [30733]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3416-179ef58c
[20:19:27.972776273] [30734]  WARN CameraSensorProperties camera_sensor_properties.cpp:141 No static properties available for 'arducam-pivariety'
[20:19:27.972825087] [30734]  WARN CameraSensorProperties camera_sensor_properties.cpp:143 Please consider updating the camera sensor properties database
[20:19:27.972852401] [30734] ERROR CameraSensor camera_sensor.cpp:551 'arducam-pivariety 10-000c': Camera sensor does not support test pattern modes.
[20:19:27.989996703] [30734] ERROR IPAProxy ipa_proxy.cpp:149 Configuration file 'arducam-pivariety.json' not found for IPA module 'raspberrypi'
[20:19:28.345539571] [30734]  WARN RPI raspberrypi.cpp:1233 Mismatch between Unicam and CamHelper for embedded data usage!
[20:19:28.346032284] [30734] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[20:19:28.346184985] [30734]  INFO RPI raspberrypi.cpp:1356 Registered camera /base/soc/i2c0mux/[email protected]/[email protected] to Unicam device /dev/media0 and ISP device /dev/media3
[20:19:28.346875714] [30733]  INFO Camera camera.cpp:1028 configuring streams: (0) 640x480-RGB888
[20:19:28.376368534] [30734]  INFO RPI raspberrypi.cpp:751 Sensor: /base/soc/i2c0mux/[email protected]/[email protected] - Selected sensor format: 1920x1080-SRGGB10_1X10 - Selected unicam format: 1920x1080-pRAA
[20:19:28.397386118] [30737]  INFO IPARPI raspberrypi.cpp:666 Request ctrl: FrameDurationLimits = [ 33333, 33333 ]
Unable to init server: Could not connect: Connection refused
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.5) /home/pi/opencv/modules/highgui/src/window_gtk.cpp:635: error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem'

Aborted

Thanks for your information,
We will conduct further testing, and can you provide information about the system version?

Note: This will run if you have the python loopback app running and you have a full GUI (no headless).

A helpful demo app would have no loopback dependencies and would run headless.
Something like libcamera-hello pared down to the minimum.