SamanthaBowen / mediapipe-solutions-cpp

Unofficial C++ APIs for MediaPipe solutions based on MediaPipe's official Python APIs.
Apache License 2.0
5 stars 0 forks source link

Can't run the hand solution after build #1

Open AriouatI opened 2 years ago

AriouatI commented 2 years ago

Hello, thanks for sharing your work. i've tried to use it in my own project but after succesfully building the repo : INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured). INFO: Found 2 targets... INFO: Elapsed time: 0.123s, Critical Path: 0.00s INFO: 1 process: 1 internal. INFO: Build completed successfully, 1 total action we tried running it using this line : bazel run -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe-solutions:hands-test

but we get this error: terminate called after throwing an instance of 'std::invalid_argument' what(): Graph has errors: Calculator::Open() for node "handlandmarktrackingcpu__palmdetectioncpu__inferencecalculator__handlandmarktrackingcpu__palmdetectioncpu__InferenceCalculator" failed: ; Can't find file: mediapipe/modules/palm_detection/palm_detection.tflite Do you have any idea on how to solve this issue ?

Thanks you.

SamanthaBowen commented 2 years ago

Hello,

It has been a while since I last used this project, but I'll try to help.

The error is that it can't find the MediaPipe data files. In the directory where you built mediapipe-solutions-cpp, the necessary files (or more accurately soft links to them) can be found in bazel-bin/mediapipe-solutions/libmediapipe_solutions.so.runfiles/com_google_mediapipe/mediapipe/.

If you are testing your program on Linux, you can make a soft link in your program's working directory called mediapipe that links to the bazel-bin/mediapipe-solutions/libmediapipe_solutions.so.runfiles/com_google_mediapipe/mediapipe/ directory. That should fix the error.

A long term solution may involve writing a build script to copy the actual files and setting the resource_root_dir flag in your code as needed.

Hope that helps.

AriouatI commented 2 years ago

Hello,

Thank you for your answer. Following your instructions, it finally worked, we had to put the soft link in a weird place though ( the path was ~/.cache/bazel/_bazel_moka/fbbd73e9bb842007954f40bc34b7a22c/execroot/mediapipe-solutions/bazel-out/k8-opt/bin/mediapipe-solutions. )

Thanks for your help :)

SamanthaBowen commented 2 years ago

Ah. I assume you were running the hands-test program, which would explain that path. That's the Bazel build system for you.

Ideally, the hands-test would work out of the box with Bazel putting the required data files where they need to be for the test programs but, unfortunately, it does not seem to do that.