how to install and use mediapipe on Raspberry Pi 4?
Asked Answered
R

3

6

I followed the official mediapipe page but without any result so can someone help to install mediapipe in raspberry pi 4 in windows it is easy to install it and use it but in arm device like raspberry pi i did not find any resources.

Rebellion answered 6/5, 2021 at 0:44 Comment(0)
R
6

a useful package to install mediapipe fastly in raspberry
for raspberry pi 3 and raspberry pi 4

//FFmpeg and OpenCV

sudo apt install ffmpeg python-opencv

// dependency packages

sudo apt install libxcb-shm0 libcdio-paranoia-dev libsdl2-2.0-0 libxv1  libtheora0 libva-drm2 libva-x11-2 libvdpau1 libharfbuzz0b libbluray2 libatlas-base-dev libhdf5-103 libgtk-3-0 libdc1394-22 libopenexr23

finally for raspberry pi 3 use :

sudo pip install mediapipe-rpi3

or for raspberry pi 4 use :

sudo pip install mediapipe-rpi4

the commands were taken from :

for raspberrypi 3: https://pypi.org/project/mediapipe-rpi3/

for raspberry pi 4: https://pypi.org/project/mediapipe-rpi4/

Rebellion answered 11/9, 2021 at 15:14 Comment(3)
It is not working on Raspi 3 model b. I solve the problem with just this line sudo pip3 install pathlib. And I run the code again with pip3: sudo pip install mediapipe-rpi3. ThanksColan
just using 'sudo pip install mediapipe-rpi4' works for me :) tnxAsphyxiate
How do you import it then? Just as "mediapipe"? This isnt working for me.Kovach
A
3

if you use python3 you can try sudo pip3 install mediapipe-rpi4

Asphyxiate answered 16/1, 2022 at 11:34 Comment(0)
A
0

I can run Hello world cpu/gpu on Raspberry Pi 4 (2gb) with Ubuntu 21.04. 64 bit. I'm still messing with hand tracking but I will share the my steps.

Install pip3: sudo apt install python3-pip Install Python six library: pip3 install --user six Install Go: sudo apt install golang-go Install Bazelisk: go get github.com/bazelbuild/bazelisk Copy it to bin: sudo mv ./go/bin/bazelisk /usr/bin/bazel Download Mediapipe: git clone https://github.com/google/mediapipe.git Install OpenCv: sudo bash ./mediapipe/setup_opencv.sh

In the next step you have to set the path correctly in WORKSPACE, opencv_linux.BUILD, ffmpeg_linux.BUILD.

Like this:

mediapipe/WORKSPACE

new_local_repository(
    name = "linux_opencv",
    build_file = "@//third_party:opencv_linux.BUILD",
    path = "/usr/local",
)

new_local_repository(
    name = "linux_ffmpeg",
    build_file = "@//third_party:ffmpeg_linux.BUILD",
    path = "/usr"
)

mediapipe/third_party/opencv_linux.BUILD

cc_library(
    name = "opencv",
    srcs = glob(
        [
            "lib/aarch64-linux-gnu/libopencv_core.so",
            "lib/aarch64-linux-gnu/libopencv_calib3d.so",
            "lib/aarch64-linux-gnu/libopencv_features2d.so",
            "lib/aarch64-linux-gnu/libopencv_highgui.so",
            "lib/aarch64-linux-gnu/libopencv_imgcodecs.so",
            "lib/aarch64-linux-gnu/libopencv_imgproc.so",
            "lib/aarch64-linux-gnu/libopencv_video.so",
            "lib/aarch64-linux-gnu/libopencv_videoio.so",
        ],
    ),
    hdrs = glob([
        # For OpenCV 3.x
        #"include/opencv2/**/*.h*",
        # For OpenCV 4.x
         "include/opencv4/opencv2/**/*.h*",
    ]),
    includes = [
        # For OpenCV 3.x
        #"include/",
        # For OpenCV 4.x
         "include/opencv4/",
    ],
    linkstatic = 1,
    visibility = ["//visibility:public"],
)

mediapipe/third_party/ffmpeg_linux.BUILD

cc_library(
    name = "libffmpeg",
    srcs = glob(
        [
            "lib/aarch64-linux-gnu/libav*.so",
        ],
    ),
    hdrs = glob(["include/aarch64-linux-gnu/libav*/*.h"]),
    includes = ["include"],
    linkopts = [
        "-lavcodec",
        "-lavformat",
        "-lavutil",
    ],
    linkstatic = 1,
    visibility = ["//visibility:public"],
)

After this you can build and then run Hello world application.

Appointed answered 10/5, 2021 at 16:13 Comment(1)
i tried this solution in raspberry pi 4 (raspbian os) but it's not working maybe works only for UbuntuRebellion

© 2022 - 2025 — McMap. All rights reserved.