我正在尝试在 Linux ubuntu 22.04 上使用 Bazel 从源代码构建 MediaPipe。以下是我迄今为止完成的完整步骤:
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
但它总是失败并出现以下错误:
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
我尝试使用 cmake 从源代码构建 opencv 并且成功了,它的绝对路径是
/usr/local/include/opencv4/opencv2
但由于某种原因,尽管我尝试在 WORKSPACE、BUILD.bazel 文件中手动添加完整路径,但 Bazel 仍无法找到它。
我已经被这个错误困扰了大约一个星期,有没有人有稳定的解决方案?
答案1
它实际上是通过以下方式解决的本指南,但对于 opencv 设置,我选择了选项 2 (setup_opencv.sh)