1. Overview of MediaPipe
MediaPipe provides a cross-platform application framework that provides customized machine learning solutions for real-time streaming media. The main features of MediaPipe:
(1) End-to-end acceleration: Built-in fast machine learning inference and processing enables accelerated use in ordinary hardware.
(2) Build once, deploy anywhere. A unified solution that can be deployed and run on Android, iOS, desktop, cloud, Web and IoT.
(3) Ready-to-use solutions. Ready-to-use solutions: Cutting-edge ML solutions that showcase the full capabilities of the framework
(4) Free and open source. The framework and solutions meet Apache2.0 and can be extended and customized.
MediaPipe provides machine learning solutions including
(1) Face Detection
(2) Face Mesh
(3) Iris recognition
(4) Hands recognition
(5) Pose recognition
(6) Holistic recognition
(7) Hair Segmentation
( 8) 3D object recognition Object Detection
(9) Target tracking Box Tracking
(10) Instant Motion Tracking
(11) Object detection Objectron
2. Install MediaPipe on Windows
Because building MediaPipe Android mobile apps cannot run in native Windows, you need to install MSYS2
from "https://github.com/msys2/msys2-installer/releases/download/2022-10-28/msys2-x86_64-20221028. exe", download the msys32-x86_64-20221028.exe software, select a customized path: for example: C:\msys64
and then set the path to the PATH path in System/Settings.
1. Install and configure MSYS2
(1)
After installing MSYS2 successfully, it will display
(2) Set the PATH environment variable
If MSYS2 is installed to D:\msys64, add D:\mysys64\usr\bin to the PATH environment variable.
(3).msys2 installs the necessary tool packages
Install
C:> pacman -S git patch unzip
3.Install Python
Omit
and edit the Python executable into the Path environment variable
4. Install Visual C++ Build Tools 2022 tools and WinSDK
The address of the Visual C++ Build Tools 2022 toolkit is: https://aka.ms/vs/17/release/vs_BuildTools.exe
When installing the Visual C++ Build Tools 2022 toolkit, you can also directly select the WinSDK toolkit, which can be found in Visual Select Windows 11 SDK in the Studio Install optional tool package (you can also set it according to your own operating system), as shown in the figure below: You
can also install the WinSDK tool package separately. The address of WinSDK is:
https://go.microsoft. com/fwlink/p/?linkid=2196241
5. Install Bazel or Bazelis, and set the location of Bazel installation to the Path environment variable. Various versions of Bazel can be selected
through: https://github.com/bazelbuild/bazel/releases . Because the download speed of the official website is relatively slow, you can use the domestic mirror source Huawei Cloud website https://mirrors.huaweicloud.com/bazel/ to select the corresponding version for download. This article has selected: https://mirrors.huaweicloud.com/bazel/5.3.2/
Download location of Bazelis: https://docs.bazel.build/versions/master/install-bazelisk.html
After successfully installing Bazel, set Bazel to the Path environment variable.
# Please find the exact paths and version numbers from your local version.
C:\> set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
C:\> set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC
C:\> set BAZEL_VC_FULL_VERSION=<Your local VC version>
C:\> set BAZEL_WINSDK_FULL_VERSION=<Your local WinSDK version>
The version of Visual C++ Build Tools 2022 installed by the author is 14.33.31629 and
the version of Windows SDK is 10.0.22621.0,
as shown in the following code:
C:\>set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
C:\>set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC
C:\>set BAZEL_VC_FULL_VERSION=14.33.31629
C:\>set BAZEL_WINSDK_FULL_VERSION=10.0.22621.0
5. Set up JDK
JDK needs to install and configure OpenJDK, the process is omitted
6.Install MediaPipe
(1) Copy MediaPipe from git to local
and execute directly: git clone https://github.com/google/mediapipe.git
will appear fatal: unable to access 'https://github.com/google/mediapipe.git/ ': OpenSSL SSL_read: Connection reset by peer, errno 104 problem.
This is because the server's SSL certificate has not been signed by a third-party organization, so the error is reported.
Therefore, by lifting SSL security verification, as follows:
git config --global http.sslVerify "false"
and then execute the git copy command to obtain mediapipe
git clone https://github.com/google/mediapipe.git
The execution process is as follows :
7. Install OpenCV and modify OpenCV settings in MediaPipe
Download and install OpenCV at: https://opencv.org/releases/
The version of OpenCV currently used is OpenCV 4.6.
Edit the OpenCV build directory in the WORKSPACE file in MediaPipe and modify it to:
new_local_repository(
name = “windows_opencv ",
build_file = "@//third_party:opencv_windows.BUILD",
path = "C:\
)
8. Test bazel to build MediaPipe application
Then test whether bazel builds MediaPipe successfully.
Download the hello_world.cc file from the website as follows: https://github.com/google/mediapipe/blob/master/mediapipe/examples/desktop/hello_world/hello_world.cc
Copy the hello_world.cc file to mediapipe's example directory, as shown below:
Enter the installation directory of mediapipe, and then execute
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D://anaconda3//python.exe" mediapipe/examples/desktop/hello_world:hello_world --sandbox_debug
As shown in the figure below:
Here – action_env PYTHON_BIN_PATH needs to be modified to the location of python.exe on your own machine.
When executing the bazel build command, some dependencies on tensorflow may not be found on the website, resulting in a 404 error. Something like this:
WARNING: Download from http://mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/cf1e44edb908e9616030cc83d085989b8e6cd6df.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/runtime/archive/8700849191dea2ca9c12a3d26ec41fac0814671b.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
If such a problem occurs, you can add a VPN or proxy according to official recommendations to solve the problem. According to reference 4:
bazel --host_jvm_args "-DsocksProxyHost=192.168.0.112 -DsocksProxyPort=1080" run --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/hello_world:hello_world
After successful construction, the hello_world.exe file is generated, as shown in the figure below Display:
To run hello_world.exe you need to execute:
set set GLOG_logtostderr=1
hello_world.exe
The running results are shown in the figure below:
references
1.MediaPipe https://google.github.io/mediapipe/
2.MSYS2 Software Distribution and Building Platform for Windows https://www.msys2.org/
3. Bazel of Tool: Detailed guide to the introduction, installation and usage of Bazel https://bbs.huaweicloud.com/blogs/detail/255296
4.Error encountered during installation https://github.com/google/mediapipe/issues/581#issuecomment-610356857