Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
6aea54e3
Commit
6aea54e3
authored
May 11, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added simple command line sample for Android
parent
5e4ca227
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
0 deletions
+156
-0
CMakeLists.txt
android/apps/HelloAndroid/CMakeLists.txt
+45
-0
cmake_android.cmd
android/apps/HelloAndroid/cmake_android.cmd
+8
-0
cmake_android.sh
android/apps/HelloAndroid/cmake_android.sh
+12
-0
main.cpp
android/apps/HelloAndroid/main.cpp
+26
-0
run.cmd
android/apps/HelloAndroid/run.cmd
+49
-0
run.sh
android/apps/HelloAndroid/run.sh
+16
-0
No files found.
android/apps/HelloAndroid/CMakeLists.txt
0 → 100644
View file @
6aea54e3
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
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
}
)
android/apps/HelloAndroid/cmake_android.cmd
0 → 100644
View file @
6aea54e3
@ECHO OFF
SETLOCAL
PUSHD %~dp0
SET PROJECT_NAME=HelloAndroid
CALL ..\..\scripts\build.cmd %*
POPD
ENDLOCAL
\ No newline at end of file
android/apps/HelloAndroid/cmake_android.sh
0 → 100644
View file @
6aea54e3
#!/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
cmake
-DOpenCV_DIR
=
$opencv_build_dir
-DARM_TARGET
=
armeabi
-DCMAKE_TOOLCHAIN_FILE
=
$opencv_android
/android.toolchain.cmake ..
android/apps/HelloAndroid/main.cpp
0 → 100644
View file @
6aea54e3
#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
;
}
android/apps/HelloAndroid/run.cmd
0 → 100644
View file @
6aea54e3
:: 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
SET PROJECT_NAME=HelloAndroid
:: 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
:: copy file to device (usually takes 10 seconds or more)
%adb% push .\bin\armeabi\%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
\ No newline at end of file
android/apps/HelloAndroid/run.sh
0 → 100644
View file @
6aea54e3
#!/bin/sh
cd
`
dirname
$0
`
PROJECT_NAME
=
HelloAndroid
# copy file to device (usually takes 10 seconds or more)
adb push ./bin/armeabi/
$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
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment