赞
踩
注意事项:
- 与OpenCV进行相互操作。最好选择OpenCV 3.X到4.1版本,OpenCV 2.X目前可以工作,但其相互操作性支持可能在将来被弃用;
- 如果你打算使用TensorFlow计算器和示例应用程序,gcc和g++的6.3和7.3版本有一个已知的问题。官网上建议安装gcc和g++版本8.x;
- 若要使Mediapipe与TensorFlow一起工作,请将Python 3.7设置为默认Python版本,并通过运行pip3 install --user six安装Python "six"库。
$ pip3 install --user six
$ bazel --help
https://bazel.build/install?hl=zh-cnhttps://bazel.build/install?hl=zh-cn
Bash
zip、unzip
C++ 构建工具链
JDK:必须提供版本 11。
Python。版本 2 和版本 3 受支持,安装其中一个版本就足够了。
https://github.com/bazelbuild/bazel/releaseshttps://github.com/bazelbuild/bazel/releases
$ env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh
- 编译后的输出会被放入
output/bazel
。这是一个独立的 Bazel 二进制文件,没有嵌入式 JDK。您可以将其复制到任何位置或直接使用。为方便起见,请将此二进制文件复制到PATH上的目录中(例如/usr/local/bin
)。- 如需以可重现的方式构建
bazel
二进制文件,还要在“运行编译脚本”步骤中设置 SOURCE_DATE_EPOCH。
- $ cd $HOME
- $ git clone --depth 1 https://github.com/google/mediapipe.git
- # Change directory into MediaPipe root directory
- $ cd mediapipe
https://github.com/google/mediapipe.githttps://github.com/google/mediapipe.git
- $ sudo apt-get install -y \
- libopencv-core-dev \
- libopencv-highgui-dev \
- libopencv-calib3d-dev \
- libopencv-features2d-dev \
- libopencv-imgproc-dev \
- libopencv-video-dev
- 注意:在Debian 11/Ubuntu 21.04上安装OpenCV 4.5时,也应该安装libopencv
$ sudo apt-get install -y libopencv-contrib-dev
MediaPipe的opencv_linux.BUILD和WORKSPACE已经为OpenCV 2/3配置完成,应该可以在任何架构上正确工作:
- # WORKSPACE
- new_local_repository(
- name = "linux_opencv",
- build_file = "@//third_party:opencv_linux.BUILD",
- path = "/usr",
- )
-
- # opencv_linux.BUILD for OpenCV 2/3 installed from Debian package
- cc_library(
- name = "opencv",
- linkopts = [
- "-l:libopencv_core.so",
- "-l:libopencv_calib3d.so",
- "-l:libopencv_features2d.so",
- "-l:libopencv_highgui.so",
- "-l:libopencv_imgcodecs.so",
- "-l:libopencv_imgproc.so",
- "-l:libopencv_video.so",
- "-l:libopencv_videoio.so",
- ],
- )
对于OpenCV 4,考虑当前架构,需要修改opencv_linux.BUILD:
- # WORKSPACE
- new_local_repository(
- name = "linux_opencv",
- build_file = "@//third_party:opencv_linux.BUILD",
- path = "/usr",
- )
-
- # opencv_linux.BUILD for OpenCV 4 installed from Debian package
- cc_library(
- name = "opencv",
- hdrs = glob([
- # Uncomment according to your multiarch value (gcc -print-multiarch):
- # "include/aarch64-linux-gnu/opencv4/opencv2/cvconfig.h",
- # "include/arm-linux-gnueabihf/opencv4/opencv2/cvconfig.h",
- # "include/x86_64-linux-gnu/opencv4/opencv2/cvconfig.h",
- "include/opencv4/opencv2/**/*.h*",
- ]),
- includes = [
- # Uncomment according to your multiarch value (gcc -print-multiarch):
- # "include/aarch64-linux-gnu/opencv4/",
- # "include/arm-linux-gnueabihf/opencv4/",
- # "include/x86_64-linux-gnu/opencv4/",
- "include/opencv4/",
- ],
- linkopts = [
- "-l:libopencv_core.so",
- "-l:libopencv_calib3d.so",
- "-l:libopencv_features2d.so",
- "-l:libopencv_highgui.so",
- "-l:libopencv_imgcodecs.so",
- "-l:libopencv_imgproc.so",
- "-l:libopencv_video.so",
- "-l:libopencv_videoio.so",
- ],
- )
$ ./setup_opencv.sh
- # Requires a GPU with EGL driver support.
- # Can use mesa GPU libraries for desktop, (or Nvidia/AMD equivalent).
- $ sudo apt-get install mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev
--define MEDIAPIPE_DISABLE_GPU=1
替换为:
--copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11
$ export GLOG_logtostderr=1
- $ bazel run --define MEDIAPIPE_DISABLE_GPU=1 \
- mediapipe/examples/desktop/hello_world:hello_world
- $ bazel run --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 \
- mediapipe/examples/desktop/hello_world:hello_world
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
- # Hello World!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。