Luca96 / dlib-for-android

Compile and embed Dlib in your Android projects with ease.
MIT License
38 stars 14 forks source link

Quick Script Fix #6

Closed phypon closed 4 years ago

phypon commented 5 years ago

First off, thank you! Dude, you're awesome for sharing this!

I had to make these quick changes to make setup.sh run properly:

Change line 80 from: ${STRIP_TOOLS[$abi]} --strip-unneeded dlib/libdlib.so to: ${STRIP_TOOLS[$abi]} --strip-unneeded dlib/build/$abi/libdlib.so (it's just a simple directory structure issue)

and line 105 from: cp -v "$DLIB_PATH/build/$abi/dlib/libdlib.so" "$NATIVE_DIR/dlib/lib/$abi" to: cp -v "$DLIB_PATH/build/$abi/libdlib.so" "$NATIVE_DIR/dlib/lib/$abi" (it's just a simple directory structure issue)

Not sure if anyone else has encountered this problem so just wanted to put it out there.

Thanks again!

Luca96 commented 5 years ago

Hi @phypon, What kind of error you got? Can you write the complete error message? because the code should work fine.
Maybe is just a simple directory issue..

Thanks for pointing out the issue.

phypon commented 5 years ago

After making the two corrections I posted the script works great! I was just pointing it out in case anyone else encountered the same error. I just needed to make a quick change to those two lines and it works. I did place/run the .sh file directly in the dlib-19.17 folder.

It was just a simple path issue.

Luca96 commented 5 years ago

Maybe I figured out what's going on... If you change the current path to dlib-19.17, run the script, and keep the variable DLIB_PATH to 'dlib'. The script will create the build folder under dlib-19.17/dlib/build and not under dlib-19.17/build (that is what the script expect). In this way the compiler will generate and store the libdlib.so file at the following location: dlib-19.17/dlib/build/$abi/libdlib.so (that is your case).

In conclusion, your changes are correct and should be done when __DLIB_PATH__'s values is something similar to dlib-19.17/dlib. Otherwise, if DLIB_PATH='dlib-19.17' then there is no need to fix those lines (80 and 105). So my script is correct too. 😄

I think this is the key point. Just try the script with DLIB_PATH='dlib-19.17', and let me know what happens (I tested the ps1 version with DLIB_PATH='dlib-19.17/dlib', and the issue happened as described earlier).

phypon commented 5 years ago

Off the top of my head without looking at it right now, it actually looks for dlib-19.17/dlib/build/dlib/$abi/libdlib.so. The second dlib is where things get tripped up.

I did look at the windows version of the script today. The same issue persisted. I also had a bit of a problem with copying some files to the source directory of the NATIVE app directories with the Windows version. I still have to look into that a bit more. All in all, it's great work and I'm not complaining at all. Just wanted to point out that if anyone encounters any errors it's just a simple fix and not any fault of the work you have done.

Outside of the scope of this git, I have encountered problems with initializing OpenCV (opencv.initdebug) on different Android OS versions using various OpenCV builds. I'm trying to resolve those issues at the moment. Again, this is not related to your work, it's an OpenCV / Android fragmentation issue I believe. I've tried doing custom OpenCV builds with mixed results. I think it's better to stick with OpenCV for Android rather than using OpenCV source files for custom builds and better to combine the OpenCV Android with DLib to ease the pain that this process can cause.

At one point, I was looking into "training" for individual face recognition, but the accuracy is fairly low for real time processing without going the CNN training route. Now I'm just trying to find a stable solution to "detect" a face rather than "verification of an individual's face". I know this is way outside the scope of this initial comment by me, but just wanted to give some background.

I'll look more into the Windows ps1 file in the next day or so and let you know what I come up with in terms of copying files and any path issues.

Luca96 commented 5 years ago

I want to precise that this isn't an argue but just a friendly conversation ;)

The fact is that when compiling Dlib, the location of the generated libdlib.so varies according to the path of the build folder:

Maybe is just a little inconsistency of the Dlib's CMakeLists.txt script that gets executed when compiling. (Personally, I don't know which build path has more sense...)

For your work, I can suggest you to use OpenCV 4 (android build), which has a fully support for c++11 (thus, is compatible with Dlib). If you need real-time performance you can use the Android's camera1 build-it face detector (I don't know if the camera2 APIs has a face detector too). Also: reducing the input image size, and/or compiling native code with hardware optimization flags (as armeabi-v7a with NEON, armeabi-v7a with VFPV3) can boost the application performance.

phypon commented 5 years ago

Thanks for clearing that up. I'll give it a fresh try in a couple of days. I appreciate you taking the time to clear this up. Thanks!