Closed VieiraJardel closed 1 year ago
I'm attempting to build MediaPipe from source using Bazel on the Jetson Nano, and I'm following the tutorial provided by @AndreV84 (https://github.com/AndreV84/mediapipe).
here are the full steps I've done so far:
editing file WORKSPACES in the mediapipe folder: new_local_repository( name = "linux_opencv", build_file = "@//third_party:opencv_linux.BUILD", path = "/usr", )
editing opencv_linux.BUILD file in the third_party folder in the mediapipe folder: cc_library( name = "opencv", hdrs = glob([ "include/opencv2/*/.h*", ]), includes = [ "include", ], linkopts = [ "/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", ], visibility = ["//visibility:public"], )
I've built OpenCV 4.5.0 following this tutorial: https://qengineering.eu/install-opencv-on-jetson-nano.html.
I'm encountering an issue identifying "version.hpp". I found this file in two locations: /home/jv/opencv/modules/core/include/opencv2 and /home/jv/opencv/modules/dnn/include/opencv2.
The folder containing opencv.hpp is /home/jv/opencv/include/opencv2, and the path to the ".so" libraries is /usr/lib/aarch64-linux-gnu.
I've reviewed issues #603, #656, #666, and #764 on the MediaPipe repository, but I haven't been able to resolve my problem.
Do you know why the headers aren't located in /usr/include/
somewhere? The locations you list (/home/jv/opencv
etc) look more like the repository for opencv rather than where opencv was installed. On my system opencv2/core/version.hpp
is located in /usr/include/opencv4/opencv2/core/version.hpp
. But I'm obviously on a slightly different platform and I installed opencv via APT rather than build.
What was the output of:
cd /home/jv/opencv
sudo make install
?
You may also want to look through the build instructions here: https://docs.opencv.org/4.7.0/d6/d15/tutorial_building_tegra_cuda.html
Hi @stephematician! Thanks for your quick reply. I'm sorry for any mistakes; I'm just starting programming now. After reading your message, I think I might have taken the wrong location. I searched for /usr/include/opencv4/opencv2/core/version.hpp and found it on my Jetson Nano.
Hi @stephematician! ...I'm sorry for any mistakes; I'm just starting programming now.
@VieiraJardel No worries. I'm a mathematician, not a programmer (I'm not even a googler), learning this stuff is hard work! Good luck with the nano
It is better to use installation method using Dockerfile. To fix the issue, complete these steps before make a build:
add to the end of Dockerfile line:
RUN ln -s /usr/include/opencv4/opencv2/ /usr/include/opencv2 && apt-get update && apt-get install -y libopencv-contrib-dev
uncomment opencv2 in hdrs and includes section in file "mediapipe/third_party/opencv_linux.BUILD" like this:
hdrs = glob([
"include/opencv4/opencv2/**/*.h*",
]),
includes = [
"include/opencv4/",
"include/opencv2/",
],
OS Platform and Distribution
Linux4Tegra, based on Ubuntu 18.04
Compiler version
gcc / g++ 8
Programming Language and version
Python 3.6.9
Installed using virtualenv? pip? Conda?(if python)
No response
MediaPipe version
0.8.9
Bazel version
4.2.1
XCode and Tulsi versions (if iOS)
No response
Android SDK and NDK versions (if android)
No response
Android AAR (if android)
None
OpenCV version (if running on desktop)
4.5.0 - Build
Describe the problem
I'm trying to build MediaPipe frombazel build -c opt --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 mediapipe/examples/desktop/hand_tracking:hand_tracking_gpu
Complete Logs
jv@jv-desktop:~/mediapipe-0.8.9$ bazel build -c opt --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 mediapipe/examples/desktop/hand_tracking:hand_tracking_gpu DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'com_google_absl' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'com_google_benchmark' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'pybind11_bazel' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'com_google_protobuf' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'com_google_googletest' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'com_github_gflags_gflags' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'build_bazel_rules_apple' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'build_bazel_rules_swift' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'build_bazel_apple_support' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'xctestrunner' because it already exists. DEBUG: /home/jv/.cache/bazel/_bazel_jv/60c21662ba14e54423ed5cde1c698284/external/org_tensorflow/third_party/repo.bzl:122:14: Warning: skipping import of repository 'pybind11' because it already exists. WARNING: /home/jv/mediapipe-0.8.9/mediapipe/framework/tool/BUILD:182:24: in cc_library rule //mediapipe/framework/tool:field_data_cc_proto: target '//mediapipe/framework/tool:field_data_cc_proto' depends on deprecated target '@com_google_protobuf//:cc_wkt_protos': Only for backward compatibility. Do not use. WARNING: /home/jv/mediapipe-0.8.9/mediapipe/framework/BUILD:54:24: in cc_library rule //mediapipe/framework:calculator_cc_proto: target '//mediapipe/framework:calculator_cc_proto' depends on deprecated target '@com_google_protobuf//:cc_wkt_protos': Only for backward compatibility. Do not use. INFO: Analyzed target //mediapipe/examples/desktop/hand_tracking:hand_tracking_gpu (70 packages loaded, 5287 targets configured). INFO: Found 1 target... ERROR: /home/jv/mediapipe-0.8.9/mediapipe/framework/formats/BUILD:178:11: Compiling mediapipe/framework/formats/image_frame_opencv.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 61 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox In file included from ./mediapipe/framework/formats/image_frame_opencv.h:20, from mediapipe/framework/formats/image_frame_opencv.cc:15: ./mediapipe/framework/port/opencv_core_inc.h:18:10: fatal error: opencv2/core/version.hpp: No such file or directory
include <opencv2/core/version.hpp>
compilation terminated. Target //mediapipe/examples/desktop/hand_tracking:hand_tracking_gpu failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 1876,709s, Critical Path: 1216,06s INFO: 1383 processes: 293 internal, 1090 processwrapper-sandbox. FAILED: Build did NOT complete successfully