diff --git a/android/apps/HelloAndroid/cmake_android.cmd b/android/apps/HelloAndroid/cmake_android.cmd deleted file mode 100644 index e43e39016..000000000 --- a/android/apps/HelloAndroid/cmake_android.cmd +++ /dev/null @@ -1,9 +0,0 @@ -@ECHO OFF -SETLOCAL -PUSHD %~dp0 -SET PROJECT_NAME=HelloAndroid -SET BUILD_DIR=build_armeabi -SET ARM_TARGET=armeabi -CALL ..\..\scripts\build.cmd %* -POPD -ENDLOCAL \ No newline at end of file diff --git a/android/scripts/cmake_android_armeabi.sh b/android/scripts/cmake_android_armeabi.sh index 3e6ee1d68..961c9d685 100644 --- a/android/scripts/cmake_android_armeabi.sh +++ b/android/scripts/cmake_android_armeabi.sh @@ -4,5 +4,5 @@ cd `dirname $0`/.. mkdir -p build_armeabi cd build_armeabi -cmake -C ../CMakeCache.android.initial.cmake -DARM_TARGET=armeabi -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake ../.. +cmake -C ../CMakeCache.android.initial.cmake -DARM_TARGET=armeabi -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. diff --git a/samples/android/CMakeLists.txt b/samples/android/CMakeLists.txt index 692a73e8c..7ed8686cd 100644 --- a/samples/android/CMakeLists.txt +++ b/samples/android/CMakeLists.txt @@ -85,6 +85,7 @@ if (BUILD_EXAMPLES) endmacro() file(GLOB android_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) + list(REMOVE_ITEM android_samples hello-android) list(SORT android_samples) foreach(sample ${android_samples}) @@ -93,5 +94,12 @@ if (BUILD_EXAMPLES) endif() endforeach() + #hello-android sample + ADD_EXECUTABLE( hello-android hello-android/main.cpp ) + ADD_DEPENDENCIES(hello-android ${sample_dependencies}) + TARGET_LINK_LIBRARIES(hello-android ${OPENCV_LINKER_LIBS} ${sample_dependencies}) + set_target_properties(hello-android PROPERTIES OUTPUT_NAME hello-android RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") + + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${additional_clean_files}") endif() diff --git a/android/apps/HelloAndroid/CMakeLists.txt b/samples/android/hello-android/CMakeLists.txt similarity index 91% rename from android/apps/HelloAndroid/CMakeLists.txt rename to samples/android/hello-android/CMakeLists.txt index c4c1d969f..032d98369 100644 --- a/android/apps/HelloAndroid/CMakeLists.txt +++ b/samples/android/hello-android/CMakeLists.txt @@ -8,7 +8,7 @@ IF( NOT PROJECT_NAME ) IF ( NOT "x$ENV{PROJECT_NAME}" STREQUAL "x" ) SET( PROJECT_NAME $ENV{PROJECT_NAME} ) ELSE() - SET( PROJECT_NAME HelloAndroid ) + SET( PROJECT_NAME hello-android ) ENDIF() ENDIF() SET( PROJECT_NAME ${PROJECT_NAME} CACHE STRING "The name of your project") @@ -19,7 +19,6 @@ PROJECT( ${PROJECT_NAME} ) # Find OpenCV ######################################################### -SET( OpenCV_DIR ${CMAKE_SOURCE_DIR}/../../build CACHE PATH "The path where you built opencv for android" ) FIND_PACKAGE( OpenCV REQUIRED ) ######################################################### @@ -55,7 +54,7 @@ message( STATUS "") message( STATUS "General configuration for ${PROJECT_NAME} =====================================") message( STATUS "") message( STATUS " OpenCV path: ${OpenCV_DIR}") -message( STATUS " Compiler: ${CMAKE_COMPILER}") +message( STATUS " Compiler: ${CMAKE_CXX_COMPILER}") message( STATUS " C++ flags (Release): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") message( STATUS " C++ flags (Debug): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") if(WIN32) diff --git a/samples/android/hello-android/cmake_android.cmd b/samples/android/hello-android/cmake_android.cmd new file mode 100644 index 000000000..e9daa2765 --- /dev/null +++ b/samples/android/hello-android/cmake_android.cmd @@ -0,0 +1,9 @@ +@ECHO OFF +SETLOCAL +PUSHD %~dp0 +SET PROJECT_NAME=hello-android +SET BUILD_DIR=build_armeabi +SET ARM_TARGET=armeabi +CALL ..\..\..\android\scripts\build.cmd %* +POPD +ENDLOCAL diff --git a/android/apps/HelloAndroid/cmake_android.sh b/samples/android/hello-android/cmake_android.sh similarity index 88% rename from android/apps/HelloAndroid/cmake_android.sh rename to samples/android/hello-android/cmake_android.sh index d724bf23e..f233e302e 100644 --- a/android/apps/HelloAndroid/cmake_android.sh +++ b/samples/android/hello-android/cmake_android.sh @@ -2,7 +2,7 @@ cd `dirname $0` BUILD_DIR=build_armeabi -opencv_android=`pwd`/../.. +opencv_android=`pwd`/../../../android opencv_build_dir=$opencv_android/$BUILD_DIR mkdir -p $BUILD_DIR diff --git a/android/apps/HelloAndroid/main.cpp b/samples/android/hello-android/main.cpp similarity index 100% rename from android/apps/HelloAndroid/main.cpp rename to samples/android/hello-android/main.cpp diff --git a/android/apps/HelloAndroid/run.cmd b/samples/android/hello-android/run.cmd similarity index 77% rename from android/apps/HelloAndroid/run.cmd rename to samples/android/hello-android/run.cmd index f54b826a5..717d56d3f 100644 --- a/android/apps/HelloAndroid/run.cmd +++ b/samples/android/hello-android/run.cmd @@ -15,12 +15,10 @@ SETLOCAL ENABLEEXTENSIONS || (ECHO Unable to enable command extensions. & EXIT \ PUSHD %~dp0 :: project specific settings -SET PROJECT_NAME=HelloAndroid -SET BUILD_DIR=build_armeabi -SET ARM_TARGET=armeabi +SET PROJECT_NAME=hello-android :: try to load config file -SET CFG_PATH=..\..\scripts\wincfg.cmd +SET CFG_PATH=..\..\..\android\scripts\wincfg.cmd IF EXIST %CFG_PATH% CALL %CFG_PATH% :: check if sdk path defined @@ -28,11 +26,8 @@ IF NOT DEFINED ANDROID_SDK (ECHO. & ECHO You should set an environment variable (PUSHD "%ANDROID_SDK%" 2>NUL && POPD) || (ECHO. & ECHO Directory "%ANDROID_SDK%" specified by ANDROID_SDK variable does not exist & GOTO end) SET adb=%ANDROID_SDK%\platform-tools\adb.exe -::binary output path is different for emulator build -IF "%ARM_TARGET%"=="armeabi" (SET OUT_DIR=armeabi) ELSE (SET OUT_DIR=armeabi-v7a) - :: copy file to device (usually takes 10 seconds or more) -%adb% push .\bin\%OUT_DIR%\%PROJECT_NAME% /data/bin/sample/%PROJECT_NAME% || GOTO end +%adb% push .\bin\%PROJECT_NAME% /data/bin/sample/%PROJECT_NAME% || GOTO end :: set execute permission %adb% shell chmod 777 /data/bin/sample/%PROJECT_NAME% || GOTO end @@ -51,4 +46,4 @@ GOTO end :end POPD -ENDLOCAL \ No newline at end of file +ENDLOCAL diff --git a/android/apps/HelloAndroid/run.sh b/samples/android/hello-android/run.sh similarity index 62% rename from android/apps/HelloAndroid/run.sh rename to samples/android/hello-android/run.sh index 467a4a6a6..1168c51df 100644 --- a/android/apps/HelloAndroid/run.sh +++ b/samples/android/hello-android/run.sh @@ -1,10 +1,9 @@ #!/bin/sh cd `dirname $0` -PROJECT_NAME=HelloAndroid -OUT_DIR=armeabi +PROJECT_NAME=hello-android # copy file to device (usually takes 10 seconds or more) -adb push ./bin/$OUT_DIR/$PROJECT_NAME /data/bin/sample/$PROJECT_NAME || return +adb push ./bin/$PROJECT_NAME /data/bin/sample/$PROJECT_NAME || return # set execute permission adb shell chmod 777 /data/bin/sample/$PROJECT_NAME || return @@ -13,4 +12,4 @@ adb shell chmod 777 /data/bin/sample/$PROJECT_NAME || return adb shell /data/bin/sample/$PROJECT_NAME || return # get image result from device -adb pull /mnt/sdcard/HelloAndroid.png || return \ No newline at end of file +adb pull /mnt/sdcard/HelloAndroid.png || return