Mediapipe在安卓上运行

一、安装Linux虚拟机,选择Ubuntu版本

二、在Ubuntu 上安装Mediapipe

1.安装编译环境Bazel,我选择的是二进制文件安装,查看Bazel文档:使用 Bazelisk 安装 / 更新 Bazel

  1)安装需要的软件包:

     Bazel需要C++的编译器,进行解压缩,压缩,才可以工作

sudo apt install g++ unzip zip

    如果要使用 Bazel 构建 Java 代码,请安装 JDK:

# Ubuntu 16.04 (LTS) uses OpenJDK 8 by default:
sudo apt-get install openjdk-8-jdk
# Ubuntu 18.04 (LTS) uses OpenJDK 11 by default:
sudo apt-get install openjdk-11-jdk

 2)运行安装程序

     下载Bazel,注意这里安装的是5.2.0版本,之前安装过其余的版本,但是后面程序报错,显示找不到5.2.0版本,所以下载的5.2.0版本的Bazel

 BAZEL_VERSION="5.2.0"     # insert your desired version here, for example 5.2.0
 wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh   # if not on x86_64, change that too

  安装Bazel

chmod +x bazel-version-installer-linux-x86_64.sh
./bazel-version-installer-linux-x86_64.sh --user

 3)设置环境

export PATH="$PATH:$HOME/bin"

2.安装Opencv与FFmpeg,这里写的是官网的第一种方法;最简单的是第二种,但是我忘记命令是什么了,这里先用第一种代替

进入mediapipe目录下

 cd mediapipe
$ sudo apt-get install -y \
    libopencv-core-dev \
    libopencv-highgui-dev \
    libopencv-calib3d-dev \
    libopencv-features2d-dev \
    libopencv-imgproc-dev \
    libopencv-video-dev

 3.运行下列代码,只要控制台输出hello world 就说明安装成功; 

$ export GLOG_logtostderr=1

# if you are running on Linux desktop with CPU only
$ bazel run --define MEDIAPIPE_DISABLE_GPU=1 \
    mediapipe/examples/desktop/hello_world:hello_world

四、遇到的问题

 在运行hello world 时,报错:

ERROR: An error occurred during the fetch of repository 'local_execution_config_python':
  Traceback (most recent call last):
       File "/sandbox_path/external/org_tensorflow/third_party/py/python_configure.bzl", line 208
               get_python_bin(repository_ctx)
    ...
Repository command failed

 解决办法:

sudo apt-get install python3-numpy

  

posted @ 2022-11-07 17:39  无敌小金刚  阅读(699)  评论(0编辑  收藏  举报