• DepthAI-v2
  • Problem with Depthai-core installation with OpenCV support

OS: Ubuntu 24.04

CMake Version: 3.27.4

DepthAI Version: Cloned the latest depthai-core repository from GitHub.

OpenCV: Installed via libopencv-dev (version 4.6.0+dfsg).

OpenCV CMake files are located at: **/usr/lib/x86_64-linux-gnu/cmake/opencv4
**
Hello,
I’m facing a persistent issue with OpenCV integration while building depthai-core on my Ubuntu system. Despite multiple attempts, the getCvFrame() function isn’t available in libdepthai-core.so, and the library doesn’t link against OpenCV, as verified by ldd.

I built depthai-core with the following CMake command:
cmake -S. -Bbuild \ -D BUILD_SHARED_LIBS=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OpenCV_DIR=/usr/lib/x86_64-linux-gnu/cmake/opencv4

However, after the rebuild, libdepthai-core.so still didn’t link against OpenCV libraries (as verified by ldd).

I ran this to confirm OpenCV detection:

cmake --find-package -DNAME=OpenCV -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST

output :
OpenCV found.

In build/CMakeCache.txt, I also confirmed:

DEPTHAI_OPENCV_SUPPORT:BOOL=ON

OpenCV_DIR:UNINITIALIZED=/usr/lib/x86_64-linux-gnu/cmake/opencv4

However:

grep -i opencv build/CMakeFiles/depthai-core.dir/link.txt

returned nothing, suggesting OpenCV is not being linked.

Each time, I cleaned the build directory and CMake cache with:

rm -rf build

rm -rf ~/.hunter

find . -name "CMakeCache.txt" -delete

Despite these efforts, the getCvFrame() function remains unavailable.

installed OpenCV using sudo apt install libopencv-dev. The relevant CMake files are located at /usr/lib/x86_64-linux-gnu/cmake/opencv4, which I set in OpenCV_DIR. OpenCV is otherwise functional on my system.

I verified the built libdepthai-core.so:

ldd /usr/local/lib/libdepthai-core.so | grep opencv

This returns nothing, indicating OpenCV isn’t being linked.

I suspect the issue might be related to how CMake is handling the OpenCV configuration.

How can I ensure that getCvFrame() is included in the compiled libdepthai-core.so?

Is there an additional step required to explicitly include OpenCV during the build process?

Could this issue be related to a cached or incorrect dependency ?

Any guidance or suggestions would be greatly appreciated. Please let me know if more details are needed to debug the problem.

Thank you!

  • jakaskerl replied to this.
  • S777
    Build against depthai-opencv.so. Then it should work.

    Thanks,
    Jaka

    S777
    Build against depthai-opencv.so. Then it should work.

    Thanks,
    Jaka