kbarni / LCCV

LibCamera wrapper library for OpenCV
60 stars 30 forks source link

plane.fd.fd() has changed to plane.fd.get() #1

Closed JuergenSmo closed 2 years ago

JuergenSmo commented 2 years ago

Hi depending on the version of libcamera you use the usage of plane() has changed. My libcamera version is: pi@campi:~/LCCV/build $ cmake .. -- Platform: armhf -- libcamera library found: -- version: 1.0 -- libraries: /usr/local/lib/arm-linux-gnueabihf/libcamera.so;/usr/local/lib/arm-linux-gnueabihf/libcamera-base.so -- include path: /usr/local/include/libcamera -- Configuring done -- Generating done -- Build files have been written to: /home/pi/LCCV/build

With this I go a compilation error:

/home/pi/LCCV/src/libcamera_app.cpp: In member function ‘void LibcameraApp::setupCapture()’: /home/pi/LCCV/src/libcamera_app.cpp:556:54: error: ‘const class libcamera::SharedFD’ has no member named ‘fd’; did you mean ‘std::sharedptr libcamera::SharedFD::fd’? (not accessible from this context) 556 | if (i == buffer->planes().size() - 1 || plane.fd.fd() != buffer->planes()[i + 1].fd.fd()) | ^~ compilation terminated due to -Wfatal-errors. make[2]: [CMakeFiles/liblccv.dir/build.make:95: CMakeFiles/liblccv.dir/src/libcamera_app.cpp.o] Fehler 1 make[1]: [CMakeFiles/Makefile2:95: CMakeFiles/liblccv.dir/all] Fehler 2 make: *** [Makefile:171: all] Fehler 2

So changing following lines in libcamera_apps.cpp from plane().fd.fd() to plane().fd.get() is now working for me:

void LibcameraApp::setupCapture() ... if (i == buffer->planes().size() - 1 || plane.fd.get() != buffer->planes()[i + 1].fd.get()) { void *memory = mmap(NULL, buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, plane.fd.get(), 0); ...

Best Regards and thank's a lot for you work!

kbarni commented 2 years ago

Thanks for reporting! I confirm this. According to the API, plane.fd is from SharedFD class which has the get() method, in my installation plane.fd is FileDescriptor with fd() method. My installation also reports libcamera version 1.0.

Do you use libcamera from the repositories or did you build it yourself? If you use the repo version, what is the result of

apt list libcamera0

(I'm using libcamera0 from the Raspbian repo version 0~git20211020+f4070274-3)

JuergenSmo commented 2 years ago

It report to me the same version as yours: 0~git20211020+f4070274-3 I build it myself using the documentation at [https://www.raspberrypi.com/documentation/accessories/camera.html#building-libcamera-and-libcamera-apps] But I then would expect that it would work directly. As I also had the version from the repository installed before maybe my system need a fresh setup. But first I will go to rebuild it from the newest sources and came back to you with the result.

JuergenSmo commented 2 years ago

Same issue as before after download and re-building libcamera:

pi@campi:~/LCCV/build $ cmake .. -- The C compiler identification is GNU 10.2.1 -- The CXX compiler identification is GNU 10.2.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- No previous build - default to Release build -- Platform: armhf -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") -- Found OpenCV: /usr/local (found version "4.5.4") -- Checking for module 'libcamera' -- Found libcamera, version 1.0 -- libcamera library found: -- version: 1.0 -- libraries: /usr/local/lib/arm-linux-gnueabihf/libcamera.so;/usr/local/lib/arm-linux-gnueabihf/libcamera-base.so -- include path: /usr/local/include/libcamera -- Configuring done -- Generating done -- Build files have been written to: /home/pi/LCCV/build

pi@campi:~/LCCV/build $ make -j4 Scanning dependencies of target liblccv [ 75%] Building CXX object CMakeFiles/liblccv.dir/src/lccv.cpp.o [ 75%] Building CXX object CMakeFiles/liblccv.dir/src/libcamera_app.cpp.o [ 75%] Building CXX object CMakeFiles/liblccv.dir/src/libcamera_app_options.cpp.o /home/pi/LCCV/src/libcamera_app.cpp: In member function ‘void LibcameraApp::setupCapture()’: /home/pi/LCCV/src/libcamera_app.cpp:556:54: error: ‘const class libcamera::SharedFD’ has no member named ‘fd’; did you mean ‘std::sharedptr libcamera::SharedFD::fd’? (not accessible from this context) 556 | if (i == buffer->planes().size() - 1 || plane.fd.fd() != buffer->planes()[i + 1].fd.fd()) | ^~ compilation terminated due to -Wfatal-errors. make[2]: [CMakeFiles/liblccv.dir/build.make:95: CMakeFiles/liblccv.dir/src/libcamera_app.cpp.o] Fehler 1 make[2]: Es wird auf noch nicht beendete Prozesse gewartet.... make[1]: [CMakeFiles/Makefile2:95: CMakeFiles/liblccv.dir/all] Fehler 2 make: [Makefile:171: all] Fehler 2

Same version as before: libcamera0/stable 0~git20211020+f4070274-3 armhf

Do you think that could be related to some old still existing libs on my system? Many thanks.

kbarni commented 2 years ago

The fd.fd() is the "old" way, and fd.get() the "new" way. I checked, it was already corrected in libcamera-apps too. I will correct this in the next release.