Score:0

Build mediapipe on Linux (Ubuntu 22.04)

md flag

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

1. git clone https://github.com/google/mediapipe.git
2. cd mediapipe
3. 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?

za flag
Does `locate version.hpp` find the file? What does a `ls -l opencv2/core/version.hpp`, issued from the build directory, reveal?
Elias Tommeh avatar
md flag
**localte version.hpp:** `/usr/include/opencv4/opencv2/core/version.hpp /usr/include/opencv4/opencv2/dnn/version.hpp /usr/local/include/opencv4/opencv2/core/version.hpp /usr/local/include/opencv4/opencv2/dnn/version.hpp` **ls -l opencv2/core/version.hpp:** `ls: cannot access 'opencv2/core/version.hpp': No such file or directory`
za flag
So are you issuing the command from the wrong directory? What does `pwd` reveal?
Elias Tommeh avatar
md flag
no, my issue is that bazel is unable to find opencv2 directory that is found in /usr/local/include/opencv4, which is required to build Mediapipe. I don't know why or I don't know where to edit if I have to (absolute/relative path) and that is my problem.
cn flag
does your workspace file not contain a tag to the location of opencv2?
Elias Tommeh avatar
md flag
it does have the following: `http_archive( name = "opencv", build_file_content = all_content, strip_prefix = "opencv-3.4.10", urls = ["https://github.com/opencv/opencv/archive/3.4.10.tar.gz"], ) new_local_repository( name = "linux_opencv", build_file = "@//third_party:opencv_linux.BUILD", path = "/usr", )`
Score:0
md flag

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

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.