superuser789 / MediaPipe-on-RaspberryPi

MediaPipe on Raspberry Pi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build errors rpi3

johncblacker opened this issue · comments

I tried a build and got errors:
cannot find -lImath
cannot find -lIlmImf
cannot find -lIex
cannot find -lHalf
cannot find -lIlmThread
cannot find -ldc1394

Installed dependencies noted in other build error issue, installed ffmpeg and opencv from this repository.

Went back and install some of the dependencies and it built. Now, where is the .whl file located? I did
python setup.py bdist_whl
which was supposed to put the .whl file in the same directory as the setup.py file...but I can't find it...

So, build did not produce a .whl output file and no "dist" directory. So, I decided to start from scratch. I deleted the mediapipe-0.8.4 directory entirely, unzipped the .tar.gz again and tried to build using:
python setup.py bdist_wheel --universal (read --universal was needed to create wheel file) but now I'm encountering problems during the build where at various places init.py file is missing. I looked through the raw source and the file is indeed missing in the places the build is complaining about. Went to the google directory for the latest mediapipe master and there are no init.py files there either. What in the heck is going on? Did I miss a step somewhere? My recollection is that the init.py is needed in packages; but I'm not sure about the requirement in package sub-directories. HELP! The first place I encountered the error was in the mediapipe/calculators directory - so I added a init.py there and also to mediapipe/modules but after I tried the build it complained about another sub-directory AND the init.py I put in mediapipe/calculators was GONE! I'm really frustrated now and apparently don't know how to proceed.

Thank you for trying it out.
I'll build mediapipe from the latest sources to see if there is any new change and will get back to you.

OK, thanks. I'm specifically interested in the ability to change models. For tflite there's "front" or "back" I believe for use with android or ios phones. There used to be "full_range" and "short_range" models for face detection but as I look at the actual source out on github for google mediapipe, I don't see a way to change the model anymore - I see reference to "model_selection" but that doesn't appear in the 0.8.4 source. I'd be interested in knowing how you're able to build this given I'm having such a devil of a time doing so.

ok. I'll look into it.
I have a rooted android phone with snapdragon 855 processor (8 cores), 6GB LPDDR4X ram & storage 128GB UFS. I have mounted raspbian filesystem image and run it in chroot environment. Just replaced the uname binary with uname script to show the uname cmd output same as visible on rpi. I first build in chroot environment, make any changes if needed for building it successfully (takes about 50 minutes which includes building opencv & mediapipe). Finally after successful build, I build on rpi system (though, I have not seen much difference in the performance between the built mediapipe ) .

Decided to give a rebuild from the mediapipe sources and followed the directions in your README.md. Tried running a simple face detection app and got a failure with "import mediapipe as mp" statement. The output is:
******************************* output starts next line ******************************
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/ml-projects/ex-mediapipe/mymedpipeEnv/lib/python3.7/site-packages/mediapipe/init.py", line 16, in
from mediapipe.python import *
File "/home/pi/ml-projects/ex-mediapipe/mymedpipeEnv/lib/python3.7/site-packages/mediapipe/python/init.py", line 17, in
from mediapipe.python._framework_bindings import resource_util
ImportError: /home/pi/ml-projects/ex-mediapipe/mymedpipeEnv/lib/python3.7/site-packages/mediapipe/python/_framework_bindings.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: _ZN3ruy28Pack8bitColMajorForNeon2ColsERKNS_14PackParams8bitE
********************* end of output ******************************************
Don't know where to go from here, perhaps something I did or didn't do in the build? Do you have any ideas?
Thanks.

Still trying...found a post that suggested modifying the third_party BUILD with NEON off. Rebuilt and still got same error. I'm going to uninstall the repo I built, re-install from the original mediapipe-rpi3 that I have and give my example a try. If it works, then my build is the problem; if it doesn't work, then my environment must be the issue. Will let you know.

The result of my experiment are: your original build works, my build does not. So, I guess I made some kind of mistake somewhere in the build. Before I undertake another build (which on my RPi takes several hours) I'd like to find out definitively what my error is (or I could just run your latest build presuming you're using the latest mediapipe sources. The latest sources support the use of the "model_selection=" parameter on the init of the FaceDetection class as documented on the mediapipe web page.

Tried copying the _framework...so file from your distro to my site-packages just to see if that'd make a difference and it did not.
So, now I'm re-doing the build but following the instructions from one of the mediapipe support folks. This'll take a long time...hours...be done this evening sometime.

I give up! I've tried everything I could think of to build the mediapipe from latest sources; I even had problems that were generally diagnosed as bazel problems and had to go back and try to find and build a version of bazel that'd work. All I ended up doing was going down more and more rabbit holes and burning up time and getting frustrated at the lack of general support for both mediapipe and bazel - especially on the RPi. So, I'll fall back to your current build and move on. If you ever get the latest sources to build, let me know.

Well, I haven't given up - yet. I used nm -A to list the symbols in the _framework_bindings.cpython-37m-arm-linux-gnueabihf.so file in the mediapipe-rpi3 version (0.8.4) and in the version I built from current sources and the symbol that appears in the error as being undefined is the same in both of the files so I can't explain why it would be reported as an undefined symbol - IT'S THERE!
Have you made any progress building from current sources?

Decided to give a rebuild from the mediapipe sources and followed the directions in your README.md. Tried running a simple face detection app and got a failure with "import mediapipe as mp" statement. The output is:
******************************* output starts next line ******************************
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/ml-projects/ex-mediapipe/mymedpipeEnv/lib/python3.7/site-packages/mediapipe/init.py", line 16, in
from mediapipe.python import *
File "/home/pi/ml-projects/ex-mediapipe/mymedpipeEnv/lib/python3.7/site-packages/mediapipe/python/init.py", line 17, in
from mediapipe.python._framework_bindings import resource_util
ImportError: /home/pi/ml-projects/ex-mediapipe/mymedpipeEnv/lib/python3.7/site-packages/mediapipe/python/_framework_bindings.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: _ZN3ruy28Pack8bitColMajorForNeon2ColsERKNS_14PackParams8bitE
********************* end of output ******************************************
Don't know where to go from here, perhaps something I did or didn't do in the build? Do you have any ideas?
Thanks.

The solution was posted by arron2003 here. Add those flags & rebuild it again.
I also noticed that there was some vagueness in Step 8 as there are two lines with '--compilation_mode=opt'. Those flags are needed to be added in function bazel_build inside class BuildBazelExtension after '--compilation_mode=opt'. Sorry for that. I have made the changes needed for building mediapipe 0.8.7 here.

Well, I haven't given up - yet. I used nm -A to list the symbols in the _framework_bindings.cpython-37m-arm-linux-gnueabihf.so file in the mediapipe-rpi3 version (0.8.4) and in the version I built from current sources and the symbol that appears in the error as being undefined is the same in both of the files so I can't explain why it would be reported as an undefined symbol - IT'S THERE!
Have you made any progress building from current sources?

Apologies. I was caught up with some work.
I built the latest mediapipe release 0.8.7 & ran it successfully. You may test the latest package for RPi 3 from here.

Not a problem, I was busy with other projects as well. Thanks for the re-build. I'm building with a change suggested by mediapipe support. Unfortunately, it's 4-5hr build. After that build completes I'm going to give it a shot and if it fails I'll load your build and give it a shot. I'm still curious how you can build successfully, while I can't. Are you building on a pi? or are you building on a rooted phone? If a phone, which one and how did you set it up - just curious.

Not a problem, I was busy with other projects as well. Thanks for the re-build. I'm building with a change suggested by mediapipe support. Unfortunately, it's 4-5hr build. After that build completes I'm going to give it a shot and if it fails I'll load your build and give it a shot. I'm still curious how you can build successfully, while I can't. Are you building on a pi? or are you building on a rooted phone? If a phone, which one and how did you set it up - just curious.

I first build on a rooted LG G8X having snapdragon 855 processor (8 cores) & 6GB LPDDR4X ram. I have mounted Raspbian system img and run in chroot environment using chroot script available for android.

I have more questions in my effort to understand why your builds work and mine don't. If you could please help?
1.) are you running a raspbian lite or desktop and is it basically a minimal install?
2.) what version of bazel are you running?
3.) what version (if any) of opencv did you install via apt (if any);
4.) are you performing the build under root?
5.) are you following the "recipe" posted in the readme for rPi 3?
6.) when you test, do you create a "new" environment (presuming you're using one at all) or are you using the global one?
7.) what's in your environment when you install the mediapipe wheel; or are you letting pip load the dependencies?
8.) what version of opencv-contrib is in the python site-packages?

Thanks for your help. I'm planning on grabbing a new sd card, reinstalling raspbian and trying the build with a minimal install because I think there just has to be something in my environment that is messing up the mediapipe build. Your help has been much appreciated and answers to the above questions would go a long way towards helping me out. BTW, your build worked on my machine (0.8.7 version) and it supports the use of "model_selection=0 (or 1)" depending on whether you want to use the short-range or long-range model. THANKS!

No problem.

  1. raspbian lite
  2. bazel 4.0.0
  3. OpenCV 4.5.2 (Not official ; built using guide )
  4. As user Pi
  5. Yes, I build them using guides.
  6. Just the global one
  7. First I install the required dependency packages using pip. Then install the mediapipe package
  8. Same version as that of OpenCV i.e. 4.5.2

Could you describe the problem you are facing while building ?

I was reading the requirements for the ffmpeg install tutorial and he specifically mentions using "stretch" - is that what you're using or have you found that you can safely use the latest "buster?"
I'm going to give the build another shot. If need be I can pull out another sd card and load an earlier image to it.

I am building on the latest Raspbian buster (10). All the packages are updated.

I tried building ffmpeg using the vidware script and ran into an error:
dpkg: error processing archive /home/pi/Vidware_Build/x264/x264_0.155-1_armhf.deb (--install):
trying to overwrite '/usr/include/x264.h', which is also in package libx264_dev:armhf 2:0.155.2917+git0a84d98-rpi1. I'm wondering if this might have to do with the fact that I already had libx264-dev/oldstable,now 2:0.155.29+git0a84d98-2+rpi1 armhf installed? I believe I already had a ffmpeg and it's pre-req's installed; but I don't remember if it was via your repo or just simply by using apt. I'm going to try again from a fresh buster img instead of the one I've been mucking with. BTW, when you build on your LG PHONE are you using vnc from a p/c or mac?

You can try this guide. Make sure that the packages fdk-aac, mp3lame, libass, x264 are already installed and remove any pre installed x264 package.
I run ssh server (in chroot raspbian) on my LG phone and run commands over ssh using putty ssh client on windows.

I'm a little confused. Your comment says to ensure the 4 packages listed are already installed, but then you say remove any pre-installed x264 package. So, removed the x264 but leave the others installed? BTW, I've tried with a vanilla raspbian-lite Buster image, but not everything completed successfully and the ffmpeg .deb package wasn't built nor did the "mpv" command test work either. Don't know if there's any support on github for this, but there's the caveat about test with "stretch" only so I don't expect the developer to support on Buster.

I'm a little confused. Your comment says to ensure the 4 packages listed are already installed, but then you say remove any pre-installed x264 package. So, removed the x264 but leave the others installed? BTW, I've tried with a vanilla raspbian-lite Buster image, but not everything completed successfully and the ffmpeg .deb package wasn't built nor did the "mpv" command test work either. Don't know if there's any support on github for this, but there's the caveat about test with "stretch" only so I don't expect the developer to support on Buster.

A particular ffmpeg is built on specific versions of fdk-aac, mp3lame, libass, x264.

First remove the pre installed fdk-aac, mp3lame, libass, x264, ffmpeg packages & these also :
sudo apt remove libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavutil56

Then either install from official repository : sudo apt install ffmpeg
or build all the packages using guide.

I read the guide and copied the script – that’s what I was using to build; however, I keep getting errors near the end, beginning with the build of ffmpeg and onward. I think I’m about done trying to build mediapipe – I’ve spent way too much time on it and have other things to do. I even read most of the dialog following the tutorial looking for an answer, but didn’t find one from RPi-Mike the producer of the script to build ffmpeg, etc. While I can understand he put a lot of work into it, I also believe that it’s going to become “stale” unless a solution for Buster and beyond becomes available. Thanks for your help. Your build of mediapipe works well and I was able to switch the model to the longer-range one in order to detect faces at a greater distance – which is exactly what I needed from the latest release – THANKS AGAIN! John

Thanks for trying out the mediapipe package.
I had successfully built the latest ffmpeg & mpv on raspbian buster.
Could you share the error logs you are getting while building ffmpeg, mpv and mediapipe ?

Finally was able to build mediapipe on my rPi. The short version...installed a clean raspbian stretch and used that to build ffmpeg, but opencv wouldn't build there because of cmake version; upgraded from stretch to buster; built opencv; built mediapipe. Of course along the way there were dependencies that were missing that I had to resolve, but I didn't want to just install a whole bunch of packages without their being necessary. Also found a helpful tip on mediapipe github: here's the link to that post: https://github.com/jiuqiant/mediapipe_python_aarch64/blob/main/README.md
The key part of that post to me was the two "sed" commands. The fact that it was for aarch64/ rpi4 doesn't matter. After I was done with the build, I tried it out and had a problem imorting cv2! Turns out that earlier on in the whole build chain there was a "sudo apt-get install python3-numpy" which was too old, not to mention it took some time before I found out how to get rid of it. Finally, I got "import cv2" to work and "import mediapipe as mp" to work. I didn't have time to give it a shot with a real facedection.py script; that's left for today when I get time. Thanks for your help along the way. I'm really curious whether I could successfully build a different version of mediapipe with this sd card setup...

Finally able to successfully build ffmpeg, opencv and mediapipe from sources. I did have to rely on a binary distro of Bazel 3.7.2.