Issue
Is there a way to compile the library OpenALPR (https://github.com/openalpr/openalpr) for Android using NDK (ndk-build)?
Solution
This is a guide to compile the library for android :
Tutorial for compiling OpenALPR for Android devices
[Step 0]
- Download and deploy android-ndk
- Make a symbolic link to android-ndk root folder to /opt
[Step 1]
- Download and Install OpenCV for Android (http://opencv.org/platforms/android.html) (Simply follow the tutorial provided by the OpenCV team)
[Step 2]
- Build the tess-two library (https://github.com/rmtheis/tess-two) (Same thing as OpenCV4Android, follow the build step on the GitHub page)
[Step 3]
Download and install the Android CMake project (https://code.google.com/p/android-cmake/) You should end up with a toolchain for generating android projects. If you got to choose which compiler to use, I recommend the gcc4.6 as I did not achieve compiling OpenALPR with a toolchain pointing to the gcc4.8 compiler...
Make a symbolic link to android-toolchain folder inside /opt (ie : sudo ln -s PATH_TO_ANDROID_TOOLCHAIN /opt/android-toolchain). (The android-toolchain folder is generated during the deployment of Android CMake project !)
[Step 4]
- Download the openalpr-master from github (https://github.com/openalpr/openalpr)
- Create a folder "build" inside openalpr-master directory
Go to the src directory and edit the CMakeLists.txt file :
- Replace this line : SET(OpenCV_DIR "${CMAKE_SOURCE_DIR}/../libraries/opencv/")
- with : SET(OpenCV_DIR "path_to_OpenCV4Android/sdk/native/jni")
Then comment the section for generating alprd (or just remove it) :
Compile the alprd library on Unix-based OS
IF (NOT WIN32) ADD_EXECUTABLE( alprd daemon.cpp videobuffer.cpp daemon/beanstalk.c daemon/beanstalk.cc daemon/uuid.cpp )
TARGET_LINK_LIBRARIES(alprd openalpr support uuid curl log4cplus ${OpenCV_LIBS} ${Tesseract_LIBS} ) ENDIF()
Open CMake
- Point the Source code to the openalpr-master/src directory
- Point the Build path to the openalpr-master/build directory
- Press the "Configure" button
- Choose "Unix Makefiles" (default) and select "Specify toolchain for cross-compiling" then click "Next"
- Specify the toolchain file to use : if you achieved step 3, it should be located under $ANDROID_CMAKE/toolchain/android.toolchain.cmake (be sure to replace the $ANDROID_CMAKE with its corresponding absolute path)
- Click on finish
There should not be any error but some warnings... it's ok
- Press Generate
[Step 5]
- Go to the build directory and edit this file : misc_utilities/CMakeFiles/benchmark.dir/link.txt : remove the -lpthread option (there should be only one line like this). Save and exit.
- Open a file explorer and go to path_to_tess-two/tess-two/jni/com_googlecode_tesseract_android/src
- Now search every header file (Press the search button and type in ".h" )
- Copy and paste every header file to openalpr-master/src/openalpr/tesseract (you should create this directory first)
- Creates these directories "libraries/tesseract-ocr/api/.libs" in the root path of openalpr-master (mkdir -p libraries/tesseract-ocr/api/.libs)
- Copy and paste path_to_tess-two/tess-two/libs/armeabi-v7a/libtess.so to openalpr-master/libraries/tesseract-ocr/api/.libs/libtesseract.so (be sure to rename it from libtess.so to libtesseract.so !)
- Open a terminal and go to the build folder (openalpr-master/build)
- Do "make"
Everything should compile smoothly. You can find the alpr library in the openalpr-master/src/libs/armeabi-v7a
That's all, let me know your successes and failures, i'll try to help you as best as possible
Answered By - jav974
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.