Search code examples
linuxubuntubazelmediapipe

Build mediapipe on Linux (Ubuntu 22.04)


I'm trying to build MediaPipe from source with Bazel on Linux ubuntu 22.04. here are the full steps ive done so far:

git clone https://github.com/google/mediapipe.git
cd mediapipe
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1   mediapipe/examples/desktop/desktop/holistic_tracking:holistic_tracking_cpu

but it's always failing with the following error:

In file included from ./mediapipe/util/annotation_renderer.h:20,
                 from mediapipe/util/annotation_renderer.cc:15:
./mediapipe/framework/port/opencv_core_inc.h:18:10: fatal error: opencv2/core/version.hpp: No such file or directory
   18 | #include <opencv2/core/version.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Target //mediapipe/examples/desktop/holistic_tracking:holistic_tracking_cpu failed to build
INFO: Elapsed time: 1.284s, Critical Path: 0.88s
INFO: 110 processes: 101 internal, 9 linux-sandbox.
FAILED: Build did NOT complete successfully

I tried to build opencv from source with cmake and it worked, the absolute path for it is usr/local/include/opencv4/opencv2 but for some reason, Bazel is unable to find it even though I tried to manually add the full path in WORKSPACE, BUILD.bazel files.

I have been stuck with this error for about a week now, does anyone have a stable solution for this?


Solution

  • It was actually solved by following this guide, but for opencv setup I went with option 2 (setup_opencv.sh)