HelloAndroid sample is moved to samples/android

This commit is contained in:
Andrey Kamaev
2011-07-01 13:12:05 +00:00
parent e005570719
commit f8e42721d3
9 changed files with 28 additions and 27 deletions

View File

@@ -1,67 +0,0 @@
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
#########################################################
# Set project name
#########################################################
IF( NOT PROJECT_NAME )
IF ( NOT "x$ENV{PROJECT_NAME}" STREQUAL "x" )
SET( PROJECT_NAME $ENV{PROJECT_NAME} )
ELSE()
SET( PROJECT_NAME HelloAndroid )
ENDIF()
ENDIF()
SET( PROJECT_NAME ${PROJECT_NAME} CACHE STRING "The name of your project")
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 )
#########################################################
# c/c++ flags, includes and lib dependencies
#########################################################
#notice the "recycling" of CMAKE_C_FLAGS
#this is necessary to pick up android flags
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic" )
SET( CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wall -pedantic" )
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET( LIBRARY_DEPS ${OpenCV_LIBS} )
IF( ANDROID )
SET( LIBRARY_DEPS ${LIBRARY_DEPS} log dl )
ENDIF()
#########################################################
# source files
#########################################################
FILE( GLOB hdrs "*.h*" )
FILE( GLOB srcs "*.cpp" )
ADD_EXECUTABLE( ${PROJECT_NAME} ${srcs} )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LIBRARY_DEPS} )
#########################################################
# Summary report
#########################################################
message( STATUS "")
message( STATUS "General configuration for ${PROJECT_NAME} =====================================")
message( STATUS "")
message( STATUS " OpenCV path: ${OpenCV_DIR}")
message( STATUS " Compiler: ${CMAKE_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)
message( STATUS " Linker flags (Release): ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
message( STATUS " Linker flags (Debug): ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
else()
message( STATUS " Linker flags (Release): ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
message( STATUS " Linker flags (Debug): ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
endif()

View File

@@ -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

View File

@@ -1,13 +0,0 @@
#!/bin/sh
cd `dirname $0`
BUILD_DIR=build_armeabi
opencv_android=`pwd`/../..
opencv_build_dir=$opencv_android/$BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
RUN_CMAKE="cmake -DOpenCV_DIR=$opencv_build_dir -DARM_TARGET=armeabi -DCMAKE_TOOLCHAIN_FILE=$opencv_android/android.toolchain.cmake .."
echo $RUN_CMAKE
$RUN_CMAKE

View File

@@ -1,26 +0,0 @@
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
const char* message = "Hello Android!";
int main(int argc, char* argv[])
{
// print message to console
printf("%s\n", message);
// put message to simple image
Size textsize = getTextSize(message, CV_FONT_HERSHEY_COMPLEX, 3, 5, 0);
Mat img(textsize.height + 20, textsize.width + 20, CV_32FC1, Scalar(230,230,230));
putText(img, message, Point(10, img.rows - 10), CV_FONT_HERSHEY_COMPLEX, 3, Scalar(0, 0, 0), 5);
// save\show resulting image
#if ANDROID
imwrite("/mnt/sdcard/HelloAndroid.png", img);
#else
imshow("test", img);
waitKey();
#endif
return 0;
}

View File

@@ -1,54 +0,0 @@
:: this batch file copies compiled executable to the device,
:: runs it and gets resulting image back to the host
::
:: Here is sample output of successful run:
::
:: 204 KB/s (2887388 bytes in 13.790s)
:: Hello Android!
:: 304 KB/s (8723 bytes in 0.028s)
@ECHO OFF
:: enable command extensions
VERIFY BADVALUE 2>NUL
SETLOCAL ENABLEEXTENSIONS || (ECHO Unable to enable command extensions. & EXIT \B)
PUSHD %~dp0
:: project specific settings
SET PROJECT_NAME=HelloAndroid
SET BUILD_DIR=build_armeabi
SET ARM_TARGET=armeabi
:: try to load config file
SET CFG_PATH=..\..\scripts\wincfg.cmd
IF EXIST %CFG_PATH% CALL %CFG_PATH%
:: check if sdk path defined
IF NOT DEFINED ANDROID_SDK (ECHO. & ECHO You should set an environment variable ANDROID_SDK to the full path to your copy of Android SDK & GOTO end)
(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
:: set execute permission
%adb% shell chmod 777 /data/bin/sample/%PROJECT_NAME% || GOTO end
:: execute our application
%adb% shell /data/bin/sample/%PROJECT_NAME% || GOTO end
:: get image result from device
%adb% pull /mnt/sdcard/HelloAndroid.png || GOTO end
GOTO end
:: cleanup (comment out GOTO above to enable cleanup)
%adb% shell rm /data/bin/sample/%PROJECT_NAME%
%adb% shell rm /mnt/sdcard/HelloAndroid.png
:end
POPD
ENDLOCAL

View File

@@ -1,16 +0,0 @@
#!/bin/sh
cd `dirname $0`
PROJECT_NAME=HelloAndroid
OUT_DIR=armeabi
# copy file to device (usually takes 10 seconds or more)
adb push ./bin/$OUT_DIR/$PROJECT_NAME /data/bin/sample/$PROJECT_NAME || return
# set execute permission
adb shell chmod 777 /data/bin/sample/$PROJECT_NAME || return
# execute our application
adb shell /data/bin/sample/$PROJECT_NAME || return
# get image result from device
adb pull /mnt/sdcard/HelloAndroid.png || return