Build
Ketika melakukan kompilasi ODKScanCore, Anda harus menggunakan OpenCV 2.3.1, download disini : https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/ (harus melakukan proses kompilasi dari source), ketika melakukan kompilasi, nonaktifkan opsi ffmpeg :
Untuk Mac OS X, penulis menggunakan Mojave, maka sebelumnya perlu menginstall OpenCV 2 dengan perintah :
brew install opencv@2
lalu edit src/Aligner.cpp dan tambahkan baris berikut :
#include <opencv2/nonfree/features2d.hpp>
Lalu untuk Makefile ubah bagian berikut :
INCLUDES := $(OPENCV_INCLUDES)\
-I./jsoncpp-src-0.5.0/include\
-I./src -I./\
-L/usr/lib
-I./zxing/core/src -I./zxing/cli/src
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=OFF \
-D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON \
-D WITH_FFMPEG=OFF ..
Untuk Mac OS X, penulis menggunakan Mojave, maka sebelumnya perlu menginstall OpenCV 2 dengan perintah :
brew install opencv@2
lalu edit src/Aligner.cpp dan tambahkan baris berikut :
#include <opencv2/nonfree/features2d.hpp>
Lalu untuk Makefile ubah bagian berikut :
INCLUDES := $(OPENCV_INCLUDES)\
-I./jsoncpp-src-0.5.0/include\
-I./src -I./\
-L/usr/lib
-I./zxing/core/src -I./zxing/cli/src
menjadi :
INCLUDES := -I/usr/local/Cellar/opencv\@2/2.4.13.7_3/include/\
-L/usr/local/Cellar/opencv\@2/2.4.13.7_3/lib\
-lopencv_core\
-lopencv_imgproc\
-lopencv_highgui\
-lopencv_ml\
-lopencv_video\
-lopencv_features2d\
-lopencv_calib3d\
-lopencv_objdetect\
-lopencv_contrib\
-lopencv_legacy\
-lopencv_flann\
-lopencv_nonfree\
-liconv\
-I./jsoncpp-src-0.5.0/include\
-I./src -I./\
-lboost_filesystem -lboost_system\
-I./zxing/core/src -I./zxing/cli/src
Berikutnya berlaku untuk Linux dan Mac
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=OFF \
-D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON \
-D WITH_FFMPEG=OFF ..
Error 1 :
OpenCV-2.3.1/share/OpenCV/../../include/opencv2/flann/any.h:88:67: error: call to function 'operator<<' that is neither visible in the template
definition nor found by argument-dependent lookup
Solusi, terapkan patch berikut [sumber]:
armeabi] SharedLibrary : libbubblebot.so
/home/wildan/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
/home/wildan/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
/home/wildan/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
/home/wildan/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4
Solusi :
Edit :
bubblebot_lib/jni/Android.mk
Tambahkan -latomic di LOCAL_LDLIBS :
LOCAL_LDLIBS += $(OPENCV_LIBS) $(ANDROID_OPENCV_LIBS) -llog -ldl -lGLESv2 -latomic
OSX Mojave
cd OpenCV-2.3.1
mkdir build
cd build
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_FFMPEG=OFF ..
Error 3
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/core/src/persistence.cpp:3437:36: error: ordered comparison
between pointer and zero ('const char *' and 'int')
if( rows < 0 || cols < 0 || dt < 0 )
~~ ^ ~
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/core/src/persistence.cpp:4503:16: error: ordered comparison
between pointer and zero ('const char *' and 'int')
if( vtx_dt > 0 )
~~~~~~ ^ ~
2 errors generated.
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/persistence.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2
Perbaikan, ubah :
if( rows < 0 || cols < 0 || dt < 0 ) menjadi : if( rows < 0 || cols < 0 || dt != nullptr )
dan
if( vtx_dt > 0 ) nenjadi if( vtx_dt != nullptr )
Error 4
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/highgui/src/window_QT.cpp:316:5: error: use of undeclared
identifier 'usleep'
usleep(1000);
^
1 error generated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_QT.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
Solusi :
tambahkan :
#include <unistd.h>
di OpenCV-2.3.1/modules/highgui/src/window_QT.cpp
Error 5
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/highgui/src/cap_qtkit.mm:34:9: fatal error: 'QTKit/QTKit.h'
file not found
#import <QTKit/QTKit.h>
^~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_qtkit.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
Solusi :
Here is a workaround solution to fix the issue:
- Download MACOSX SDK https://codeload.github.com/phracker/MacOSX-SDKs/zip/MacOSX10.11.sdk
- extract head files from MacOSX10.11.sdk/MacOSX10.11.sdk/System/Library/Frameworks/QTKit.framework/Headers/
- Create a folder under opencv source file folder: opencv-2.3.1/modules/highgui/src/QTKit, and copy all header files into the folder.
Scanning dependencies of target opencv_ts
[ 28%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.o
In file included from /Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/ts/src/precomp.cpp:1:
In file included from /Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/ts/src/precomp.hpp:7:
In file included from /Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/ts/include/opencv2/ts/ts.hpp:10:
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/ts/include/opencv2/ts/ts_gtest.h:1511:10: fatal error:
'tr1/tuple' file not found
#include <tr1/tuple> // NOLINT
^~~~~~~~~~~
1 error generated.
make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.o] Error 1
make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
make: *** [all] Error 2
Solusi
Aktifkan opsi GTEST_USE_OWN_TR1_TUPLE 1 di ts_gtest.h
Error 7
OPENCV_CONFIG =
PROJECT_PATH defaulting to this directory
/Users/earth/Library/Android/sdk/ndk-bundle/ndk-build NDK_LIBS_OUT=./../scan_app/src/main/jniLibs OPENCV_CONFIG= PROJECT_PATH=. V= ARM_TARGETS="armeabi armeabi-v6 armeabi-v7a"
make[1]: Entering directory `/Users/earth/jobstuff/software/OpenDataKit/scan/bubblebot_lib'
[armeabi-v7a] Install : libbubblebot.so => ../scan_app/src/main/jniLibs/armeabi-v7a/libbubblebot.so
[armeabi] SharedLibrary : libbubblebot.so
/Users/earth/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
/Users/earth/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
/Users/earth/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
/Users/earth/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/atomicity.h:49: error: undefined reference to '__atomic_fetch_add_4'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [obj/local/armeabi/libbubblebot.so] Error 1
make[1]: Leaving directory `/Users/earth/jobstuff/software/OpenDataKit/scan/bubblebot_lib'
make: *** [libs/armeabi-v7a/libbubblebot.so] Error 2
Solusi : untuk masalah ini bisa dibaca di : Error migrating from GCC to Clang - undefined reference to atomic #104.
yaitu di : bubblebot_lib/jni/Android.mk
LOCAL_LDLIBS += $(OPENCV_LIBS) $(ANDROID_OPENCV_LIBS) -llog -ldl -lGLESv2
ditambah -latomic menjadi :
LOCAL_LDLIBS += $(OPENCV_LIBS) $(ANDROID_OPENCV_LIBS) -llog -ldl -lGLESv2 -latomic
Error 8
[ 64%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/texture.o
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/legacy/src/texture.cpp:138:32: warning: 'memset' call
operates on objects of type 'CvGLCM' while the size is based on a different type 'CvGLCM *'
[-Wsizeof-pointer-memaccess]
memset( newGLCM, 0, sizeof(newGLCM) );
~~~~~~~ ^~~~~~~
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/legacy/src/texture.cpp:138:32: note: did you mean to
dereference the argument to 'sizeof' (and multiply it by the number of elements)?
memset( newGLCM, 0, sizeof(newGLCM) );
^~~~~~~
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/legacy/src/texture.cpp:472:32: error: ordered comparison
between pointer and zero ('double *' and 'int')
if( marginalProbability>0 )
~~~~~~~~~~~~~~~~~~~^~
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/legacy/src/texture.cpp:518:10: warning: use of unary
operator that may be intended as compound assignment (-=)
HXY1 =- HXY1;
^~
/Users/earth/jobstuff/software/OpenCV/OpenCV-2.3.1/modules/legacy/src/texture.cpp:519:10: warning: use of unary
operator that may be intended as compound assignment (-=)
HXY2 =- HXY2;
^~
3 warnings and 1 error generated.
make[2]: *** [modules/legacy/CMakeFiles/opencv_legacy.dir/src/texture.o] Error 1
make[1]: *** [modules/legacy/CMakeFiles/opencv_legacy.dir/all] Error 2
make: *** [all] Error 2
Solusi
ubah
if( marginalProbability>0 )
menjadi
if( marginalProbability > (void *)0 )
Referensi
- ODK Scan Wiki and Issues, https://github.com/opendatakit/scan