Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling for an ARM architecture #86

Closed
WajWaraich opened this issue Nov 3, 2016 · 19 comments
Closed

Compiling for an ARM architecture #86

WajWaraich opened this issue Nov 3, 2016 · 19 comments

Comments

@WajWaraich
Copy link

Hi, I wanted to see what the performance is like on an ARM architecture, I wanted to test it on an Intel computer stick, I have compiled OpenCV from source for ARM and have changed the dependencies accordingly, I am still running into issues, is there any good guides out there for building projects for ARM architecture. Also, will I have to recompile dlib for ARM too?

@TadasBaltrusaitis
Copy link
Owner

I have not tried to work on ARM architectures myself, but I believe you will need to recompile everything for ARM as well, including dlib.

@WajWaraich
Copy link
Author

Thanks for the reply @TadasBaltrusaitis, will do that.

@aljawo
Copy link

aljawo commented Nov 14, 2016

Hey ! I have recompiled everything on ARM, including Boost but for dlib I just got libopenblas-dev and liblapack-dev, still I get this error while compiling

fatal error: error in backend: IO failure on output stream.
lib/3rdParty/dlib/CMakeFiles/dlib.dir/build.make:62: recipe for target 'lib/3rdParty/dlib/CMakeFiles/dlib.dir/include/dlib/base64/base64_kernel_1.o' failed
make[2]: *** [lib/3rdParty/dlib/CMakeFiles/dlib.dir/include/dlib/base64/base64_kernel_1.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'lib/3rdParty/dlib/CMakeFiles/dlib.dir/all' failed
make[1]: *** [lib/3rdParty/dlib/CMakeFiles/dlib.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Should I compile dlib from sources instead ?

@WajWaraich
Copy link
Author

WajWaraich commented Nov 14, 2016

Hi, I do believe you would have to recompile the dlib library from source for ARM. Also, don't forget to compile the OpenCV library from source using CMake. Let us know how you get on, good luck.

There is a guide on how to compile dlib from source in the dlib repo: https://github.com/davisking/dlib

@aljawo
Copy link

aljawo commented Nov 14, 2016

Thanks Wajahat for the quick answer ! Sorry if the question is basic but I
am a new on this area. The instructions show how to compile all the
examples but I don’t actually want that or do I ?

Or should I download, uncompress and compile in a specific location ?

Thanks in advance !

@aljawo
Copy link

aljawo commented Nov 14, 2016

Oh.. on other note.. when I tried to compile with cmake I got this other error..

[ 92%] Linking CXX executable ../../bin/FaceLandmarkImg
/usr/bin/ld: /usr/local/lib/libopencv_core.a(ocl.cpp.o): undefined reference to symbol '_ZTTNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE@@GLIBCXX_3.4.21'
//usr/lib/arm-linux-gnueabihf/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/build.make:141: recipe for target 'bin/FaceLandmarkImg' failed
make[2]: *** [bin/FaceLandmarkImg] Error 1
CMakeFiles/Makefile2:252: recipe for target 'exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all' failed
make[1]: *** [exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

@WajWaraich
Copy link
Author

You're right the README in the repo does highlight how to compile the examples but you can compile the entire library in the same way from source.

What variables are you setting when you call cmake? Have you set CMAKE_BUILD_TYPE to release? Also, you will need to use some additional variables to compile for ARM, find more information under this link: http://www.vtk.org/Wiki/CMake_Cross_Compiling

@WajWaraich
Copy link
Author

Here is a good guide for compiling dlib from source on Linux: https://aleen42.gitbooks.io/personalwiki/content/qa/dlibonlinux.html

@aljawo
Copy link

aljawo commented Nov 14, 2016

Yes, for openFace I used the release value for BUILD_TYPE and thanks for the reference. I have had seen those instructions but I see that the guy uncompressed the whole library under a directory lib within the application directory together with the source code, that is why I couldn't figure out where should I have to do that in this case..

Have in mind that this is a linking problem and not a compilation one.
Update:
I could compile Dlib successfully but don't know how to put all together, not even sure that this is a dlib issue :-/

@svofski
Copy link

svofski commented Mar 10, 2017

Hi,
I was able to compile OpenFace on Raspberry Pi 3. I did build TBB and OpenCV 3 (and some dependencies like ffmpeg) from source.

I did replace various SSE options with -mfpu=neon and -funsafe-math-optimizations in CMakeLists.txt

The examples work well, but the performance is really poor. With a 480p webcam I get maybe 2 fps peak in the multiple face example in perfect conditions, but it keeps on staggering for extended periods of longer than 1 second, especially when it cannot see a face. What could be the cause of such staggering?

@TadasBaltrusaitis
Copy link
Owner

TadasBaltrusaitis commented Mar 10, 2017

Hi,

Great news on getting it to work on Raspberry Pi. From your description it sounds like the face detection is the expensive step. You could try switching to using OpenCV face detector which is faster but less accurate, you would need to set:
det_parameters.curr_face_detector = det_parameters.HAAR_DETECTOR;

You can also switch to a simpler landmark detection module which is faster but again less accurate, to do this you can pass -mloc model/main_clm_general.txt

This might make the tracking faster.

@svofski
Copy link

svofski commented Mar 14, 2017

Hi,
Thanks for the tips!
I expected to see the biggest difference without HOG, but I did not notice any significant difference between HOG and Haar face detectors. Could be because HOG is using Neon and I'm not sure about Haar but most likely it doesn't. Anyway, things that I found to be helpful are: scale down the source image for processing, simple landmark detection module, disable gaze tracking.

BTW, the Neon patch by @fastfastball that I'm talking about is https://github.com/fastfastball/arm_neon_for_dlib_simd

@xhzzhang
Copy link

@svofski I also need build it on Android, May I ask you to share your modified source code that can run on Android? or diff patch file? thanks

@MyraBaba
Copy link

Hi,

How you compiled the openface in raspberry pi 3 ? I have already dlib and opencv working on the raspberry pi 3.
Also I compiled tbb .

linking stage it gave error :

../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectionValidator.cpp.o):(.rodata+0xf0): undefined reference to `typeinfo for tbb::task'
collect2: error: ld returned 1 exit status
exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/build.make:157: recipe for target 'bin/FaceLandmarkImg' failed
make[2]: *** [bin/FaceLandmarkImg] Error 1
CMakeFiles/Makefile2:364: recipe for target 'exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all' failed
make[1]: *** [exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all] Error 2
Makefile:127: recipe for target 'all' failed

@markchrisallen
Copy link

@svofski I would also be super interested in seeing exactly how you got OpenFace working on the Raspberry Pi! Perhaps even your disk image if that is cool...

@MyraBaba
Copy link

MyraBaba commented May 9, 2018

the key is the installing TBB correctly (compiling). super adventure :)

I suggest : https://www.theimpossiblecode.com/blog/intel-tbb-on-raspberry-pi/

@svofski
Copy link

svofski commented May 9, 2018

@MyraBaba @markchrisallen sorry guys but I didn't document my build. It wasn't really performing very well on Rpi3, so I steered somewhere else. This build, with the entire environment, is long gone.

I do not remember any particular difficulties making it work though. I had to manually compile ffmpeg with its dependencies, same for TBB. Then of course make sure that cmake picks up all the right libraries for OpenFace.

I never tested OpenFace with an actual camera, I used an mp4 stream.

@markchrisallen
Copy link

Amazing thanks, quite new to all of this but I will keep on trying!

@juanparati
Copy link

I compiled OpenFace for aarm64 and I created a container that it's available at:
https://github.com/juanparati/openface-aarm64

If you want how I compile the OpenFace for Arm just check this Dockerfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants