derzu / BodySkeletonTracker

Human body skeleton detection an tracking from video camera in real time. It was developed for an Orbbec Astra camera DRGB (Depth-RGB), uses the OpenNI2 driver, it also works with Asus Xtion and Prime sense. It works with normal webcam too, in the case of background is smooth and white.
MIT License
123 stars 45 forks source link

Cross compiling - opencv2/highgui.hpp: No such file or directory #2

Closed manolisan closed 6 years ago

manolisan commented 7 years ago

Hi,

I am trying to cross compile the library for an ARM machine with my host machine Ubuntu 16.04. However the make command results in the following error.

arm-linux-gnueabi-g++ -MD -MP -MT "./Bin/Intermediate/Arm-Release/BodySkeletonTracker/Skeleton.d Bin/Intermediate/Arm-Release/BodySkeletonTracker/Skeleton.o" -c -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard  -O3 -fno-tree-pre -fno-strict-aliasing -ftree-vectorize -ffast-math -funsafe-math-optimizations  -flax-vector-conversions -DUNIX -DGLX_GLXEXT_LEGACY -DDEPTH --sysroot=Staging -O2 -DNDEBUG -Iinclude -I/home/manolis/OpenNI-Linux-x64-2.3/Include -DXN_NEON -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/Arm-Release/BodySkeletonTracker/Skeleton.o src/Skeleton.cpp
In file included from src/Skeleton.cpp:1:0:
include/Skeleton.h:4:31: fatal error: opencv2/highgui.hpp: No such file or directory
compilation terminated.
CommonCppMakefile:133: recipe for target 'Bin/Intermediate/Arm-Release/BodySkeletonTracker/Skeleton.o' failed
make: *** [Bin/Intermediate/Arm-Release/BodySkeletonTracker/Skeleton.o] Error 1

Note that I have successfully compiled and run natively the code for my host x86 machine. So what am I missing?

Thanks a lot

derzu commented 7 years ago

Hi @manolisan,

The compiler is not finding the opencv2 include files. Is opencv installed on your device?

Please run this command on your terminal: pkg-config --cflags --libs opencv

Here on my machine the command exit is: -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core

This command is used at the Makefile, and it has the flags for include the opencv head files (-I/usr/local/include/opencv -I/usr/local/include).

If, in your device, it does not returns, you should replace the Makefile line #31: LDFLAGS += $(shell pkg-config --libs --static opencv) by: LDFLAGS += -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core

And install the opencv lib at your device.

manolisan commented 7 years ago

Thanks for the quick reply @derzu!

The output of the command pkg-config --cflags --libs opencv is

-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core

I did the suggested replacement in the Makefile line #31 and I got the same error.

Opencv lib is installed on my device and I have successfully compiled and run your code on my host device, but I haven't compiled it for an arm device.

So, maybe the problem could be that I haven't cross-compiled opencv.

derzu commented 7 years ago

I think I found the problem.

Replace the line include/Skeleton.h:4 #include <opencv2/highgui.hpp> for #include <opencv2/highgui/highgui.hpp>

You will probably get more errors, please change also this include, on the files where it happens: #include <opencv2/core.hpp> to #include <opencv2/core/core.hpp>

Please let me know if it works.

Check this answer at StackOverflow: https://stackoverflow.com/a/43701862/1178478

manolisan commented 7 years ago

No, that didn't work.

I added this line: INC_DIRS += /usr/local/include in the Makefile:40. Now I can get the source files compiled to intermediate object files, but I get an error while loading the libraries in the linking phase.

arm-linux-gnueabi-g++ -o Bin/Arm-Release/BodySkeletonTracker ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/Skeleton.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/Point3D.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/SkeletonPoints.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/DrawAux.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/SkeletonListener.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/SkeletonDepth.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/SampleViewer.o ./Bin/Intermediate/Arm-Release/BodySkeletonTracker/main.o -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core -lpng -lz -ltiff -ljasper -ljpeg -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lv4l1 -lv4l2 -lavcodec-ffmpeg -lavformat-ffmpeg -lavutil-ffmpeg -lswscale-ffmpeg -ldl -lm -lpthread -lrt --sysroot=Staging  -LBin/Arm-Release -lOpenNI2 -Wl,-rpath ./
/usr/local/lib/libopencv_stitching.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
CommonCppMakefile:139: recipe for target 'Bin/Arm-Release/BodySkeletonTracker' failed
make: *** [Bin/Arm-Release/BodySkeletonTracker] Error 1