mirror of https://github.com/opencv/opencv.git
parent
d5f430cc11
commit
2b35c1708b
49 changed files with 1218 additions and 568 deletions
@ -1,5 +1,151 @@ |
|||||||
message(FATAL_ERROR " |
# https://developer.android.com/studio/releases/gradle-plugin |
||||||
Android gradle-based build/projects are not supported in this version of OpenCV. |
set(ANDROID_GRADLE_PLUGIN_VERSION "3.2.1" CACHE STRING "Android Gradle Plugin version (3.0+)") |
||||||
You need to downgrade Android SDK Tools to version 25.2.5. |
message(STATUS "Android Gradle Plugin version: ${ANDROID_GRADLE_PLUGIN_VERSION}") |
||||||
Details: https://github.com/opencv/opencv/issues/8460 |
|
||||||
|
set(ANDROID_COMPILE_SDK_VERSION "26" CACHE STRING "Android compileSdkVersion") |
||||||
|
set(ANDROID_MIN_SDK_VERSION "21" CACHE STRING "Android minSdkVersion") |
||||||
|
set(ANDROID_TARGET_SDK_VERSION "26" CACHE STRING "Android minSdkVersion") |
||||||
|
|
||||||
|
set(ANDROID_BUILD_BASE_DIR "${OpenCV_BINARY_DIR}/opencv_android" CACHE INTERNAL "") |
||||||
|
set(ANDROID_TMP_INSTALL_BASE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/install/opencv_android") |
||||||
|
|
||||||
|
set(ANDROID_INSTALL_SAMPLES_DIR "samples") |
||||||
|
|
||||||
|
set(ANDROID_BUILD_ABI_FILTER " |
||||||
|
reset() |
||||||
|
include '${ANDROID_ABI}' |
||||||
") |
") |
||||||
|
|
||||||
|
set(ANDROID_INSTALL_ABI_FILTER " |
||||||
|
//reset() |
||||||
|
//include 'armeabi-v7a' |
||||||
|
//include 'arm64-v8a' |
||||||
|
//include 'x86' |
||||||
|
//include 'x86_64' |
||||||
|
") |
||||||
|
if(NOT INSTALL_CREATE_DISTRIB) |
||||||
|
set(ANDROID_INSTALL_ABI_FILTER "${ANDROID_BUILD_ABI_FILTER}") |
||||||
|
endif() |
||||||
|
|
||||||
|
# BUG: Ninja generator generates broken targets with ANDROID_ABI_FILTER name (CMake 3.11.2) |
||||||
|
#set(__spaces " ") |
||||||
|
#string(REPLACE "\n" "\n${__spaces}" ANDROID_ABI_FILTER "${__spaces}${ANDROID_BUILD_ABI_FILTER}") |
||||||
|
#string(REPLACE REGEX "[ ]+$" "" ANDROID_ABI_FILTER "${ANDROID_ABI_FILTER}") |
||||||
|
set(ANDROID_ABI_FILTER "${ANDROID_BUILD_ABI_FILTER}") |
||||||
|
configure_file("${OpenCV_SOURCE_DIR}/samples/android/build.gradle.in" "${ANDROID_BUILD_BASE_DIR}/build.gradle" @ONLY) |
||||||
|
|
||||||
|
set(ANDROID_ABI_FILTER "${ANDROID_INSTALL_ABI_FILTER}") |
||||||
|
configure_file("${OpenCV_SOURCE_DIR}/samples/android/build.gradle.in" "${ANDROID_TMP_INSTALL_BASE_DIR}/${ANDROID_INSTALL_SAMPLES_DIR}/build.gradle" @ONLY) |
||||||
|
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/${ANDROID_INSTALL_SAMPLES_DIR}/build.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}" COMPONENT samples) |
||||||
|
|
||||||
|
set(GRADLE_WRAPPER_FILES |
||||||
|
"gradle/wrapper/gradle-wrapper.jar" |
||||||
|
"gradle/wrapper/gradle-wrapper.properties" |
||||||
|
"gradlew.bat" |
||||||
|
"gradlew" |
||||||
|
"gradle.properties" |
||||||
|
) |
||||||
|
foreach(fname ${GRADLE_WRAPPER_FILES}) |
||||||
|
get_filename_component(__dir "${fname}" DIRECTORY) |
||||||
|
set(__permissions "") |
||||||
|
set(__permissions_prefix "") |
||||||
|
if(fname STREQUAL "gradlew") |
||||||
|
set(__permissions FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
||||||
|
endif() |
||||||
|
file(COPY "${OpenCV_SOURCE_DIR}/platforms/android/gradle-wrapper/${fname}" DESTINATION "${ANDROID_BUILD_BASE_DIR}/${__dir}" ${__permissions}) |
||||||
|
string(REPLACE "FILE_PERMISSIONS" "PERMISSIONS" __permissions "${__permissions}") |
||||||
|
if("${__dir}" STREQUAL "") |
||||||
|
set(__dir ".") |
||||||
|
endif() |
||||||
|
install(FILES "${OpenCV_SOURCE_DIR}/platforms/android/gradle-wrapper/${fname}" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples ${__permissions}) |
||||||
|
endforeach() |
||||||
|
|
||||||
|
file(WRITE "${ANDROID_BUILD_BASE_DIR}/settings.gradle" " |
||||||
|
include ':opencv' |
||||||
|
") |
||||||
|
|
||||||
|
file(WRITE "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" " |
||||||
|
rootProject.name = 'opencv_samples' |
||||||
|
|
||||||
|
def opencvsdk='../' |
||||||
|
//def opencvsdk='/<path to OpenCV-android-sdk>' |
||||||
|
//println opencvsdk |
||||||
|
include ':opencv' |
||||||
|
project(':opencv').projectDir = new File(opencvsdk + '/sdk') |
||||||
|
") |
||||||
|
|
||||||
|
|
||||||
|
macro(add_android_project target path) |
||||||
|
get_filename_component(__dir "${path}" NAME) |
||||||
|
|
||||||
|
set(OPENCV_ANDROID_CMAKE_EXTRA_ARGS "") |
||||||
|
if(DEFINED ANDROID_TOOLCHAIN) |
||||||
|
set(OPENCV_ANDROID_CMAKE_EXTRA_ARGS "${OPENCV_ANDROID_CMAKE_EXTRA_ARGS},\n\"-DANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN}\"") |
||||||
|
endif() |
||||||
|
if(DEFINED ANDROID_STL) |
||||||
|
set(OPENCV_ANDROID_CMAKE_EXTRA_ARGS "${OPENCV_ANDROID_CMAKE_EXTRA_ARGS},\n\"-DANDROID_STL=${ANDROID_STL}\"") |
||||||
|
endif() |
||||||
|
|
||||||
|
# |
||||||
|
# Build |
||||||
|
# |
||||||
|
set(ANDROID_SAMPLE_JNI_PATH "${path}/jni") |
||||||
|
set(ANDROID_SAMPLE_JAVA_PATH "${path}/src") |
||||||
|
set(ANDROID_SAMPLE_RES_PATH "${path}/res") |
||||||
|
set(ANDROID_SAMPLE_MANIFEST_PATH "${path}/gradle/AndroidManifest.xml") |
||||||
|
|
||||||
|
set(ANDROID_ABI_FILTER "${ANDROID_BUILD_ABI_FILTER}") |
||||||
|
set(ANDROID_PROJECT_JNI_PATH "../../") |
||||||
|
|
||||||
|
string(REPLACE ";" "', '" ANDROID_SAMPLE_JAVA_PATH "['${ANDROID_SAMPLE_JAVA_PATH}']") |
||||||
|
string(REPLACE ";" "', '" ANDROID_SAMPLE_RES_PATH "['${ANDROID_SAMPLE_RES_PATH}']") |
||||||
|
configure_file("${path}/build.gradle.in" "${ANDROID_BUILD_BASE_DIR}/${__dir}/build.gradle" @ONLY) |
||||||
|
|
||||||
|
file(APPEND "${ANDROID_BUILD_BASE_DIR}/settings.gradle" " |
||||||
|
include ':${__dir}' |
||||||
|
") |
||||||
|
|
||||||
|
# build apk |
||||||
|
set(APK_FILE "${ANDROID_BUILD_BASE_DIR}/${__dir}/build/outputs/apk/release/${__dir}-${ANDROID_ABI}-release-unsigned.apk") |
||||||
|
ocv_update(OPENCV_GRADLE_VERBOSE_OPTIONS "-i") |
||||||
|
add_custom_command( |
||||||
|
OUTPUT "${APK_FILE}" "${OPENCV_DEPHELPER}/android_sample_${__dir}" |
||||||
|
COMMAND ./gradlew ${OPENCV_GRADLE_VERBOSE_OPTIONS} "${__dir}:assemble" |
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}" |
||||||
|
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}" |
||||||
|
DEPENDS ${depends} opencv_java_android |
||||||
|
COMMENT "Building OpenCV Android sample project: ${__dir}" |
||||||
|
) |
||||||
|
file(REMOVE "${OPENCV_DEPHELPER}/android_sample_${__dir}") # force rebuild after CMake run |
||||||
|
|
||||||
|
add_custom_target(android_sample_${__dir} ALL DEPENDS "${OPENCV_DEPHELPER}/android_sample_${__dir}" SOURCES "${ANDROID_SAMPLE_MANIFEST_PATH}") |
||||||
|
|
||||||
|
# |
||||||
|
# Install |
||||||
|
# |
||||||
|
set(ANDROID_SAMPLE_JNI_PATH "jni") |
||||||
|
set(ANDROID_SAMPLE_JAVA_PATH "src") |
||||||
|
set(ANDROID_SAMPLE_RES_PATH "res") |
||||||
|
set(ANDROID_SAMPLE_MANIFEST_PATH "AndroidManifest.xml") |
||||||
|
|
||||||
|
install(DIRECTORY "${path}/res" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples OPTIONAL) |
||||||
|
install(DIRECTORY "${path}/src" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples) |
||||||
|
install(DIRECTORY "${path}/jni" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples OPTIONAL) |
||||||
|
|
||||||
|
install(FILES "${path}/gradle/AndroidManifest.xml" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples) |
||||||
|
|
||||||
|
set(ANDROID_ABI_FILTER "${ANDROID_INSTALL_ABI_FILTER}") |
||||||
|
set(ANDROID_PROJECT_JNI_PATH "native/jni") |
||||||
|
|
||||||
|
string(REPLACE ";" "', '" ANDROID_SAMPLE_JAVA_PATH "['${ANDROID_SAMPLE_JAVA_PATH}']") |
||||||
|
string(REPLACE ";" "', '" ANDROID_SAMPLE_RES_PATH "['${ANDROID_SAMPLE_RES_PATH}']") |
||||||
|
configure_file("${path}/build.gradle.in" "${ANDROID_TMP_INSTALL_BASE_DIR}/${__dir}/build.gradle" @ONLY) |
||||||
|
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/${__dir}/build.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples) |
||||||
|
|
||||||
|
file(APPEND "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" " |
||||||
|
include ':${__dir}' |
||||||
|
") |
||||||
|
|
||||||
|
endmacro() |
||||||
|
|
||||||
|
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}" COMPONENT samples) |
||||||
|
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv" |
||||||
|
android:versionCode="@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@0" |
||||||
|
android:versionName="@OPENCV_VERSION@"> |
||||||
|
</manifest> |
@ -0,0 +1,35 @@ |
|||||||
|
apply plugin: 'com.android.library' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
//buildToolsVersion "x.y.z" // not needed since com.android.tools.build:gradle:3.0.0 |
||||||
|
|
||||||
|
defaultConfig { |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
} |
||||||
|
|
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' |
||||||
|
} |
||||||
|
} |
||||||
|
compileOptions { |
||||||
|
sourceCompatibility JavaVersion.VERSION_1_6 |
||||||
|
targetCompatibility JavaVersion.VERSION_1_6 |
||||||
|
} |
||||||
|
|
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
jniLibs.srcDirs = ['../../jni'] |
||||||
|
java.srcDirs = ['src'] // TODO Use original files instead of copied into build directory |
||||||
|
aidl.srcDirs = ['src'] |
||||||
|
res.srcDirs = ['@OpenCV_SOURCE_DIR@/modules/java/android_sdk/android_gradle_lib/res'] |
||||||
|
manifest.srcFile 'AndroidManifest.xml' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<resources> |
||||||
|
<declare-styleable name = "CameraBridgeViewBase" > |
||||||
|
<attr name="show_fps" format="boolean"/> |
||||||
|
<attr name="camera_id" format="integer" > |
||||||
|
<enum name="any" value="-1" /> |
||||||
|
<enum name="back" value="99" /> |
||||||
|
<enum name="front" value="98" /> |
||||||
|
</attr> |
||||||
|
</declare-styleable> |
||||||
|
</resources> |
@ -1,77 +0,0 @@ |
|||||||
#!/usr/bin/env python |
|
||||||
|
|
||||||
import unittest |
|
||||||
import os, sys, subprocess, argparse, shutil, re |
|
||||||
from os.path import abspath |
|
||||||
|
|
||||||
class TestAntBuild(unittest.TestCase): |
|
||||||
pass |
|
||||||
|
|
||||||
def __init__(self, target, workdir, lib_dir, sample_dir, *args, **kwargs): |
|
||||||
unittest.TestCase.__init__(self, *args, **kwargs) |
|
||||||
self.target = target |
|
||||||
self.workdir = workdir |
|
||||||
self.src_lib_dir = lib_dir |
|
||||||
self.src_sample_dir = sample_dir |
|
||||||
self.lib_dir = os.path.join(self.workdir, "opencv") |
|
||||||
self.sample_dir = os.path.join(self.workdir, "project") |
|
||||||
|
|
||||||
def shortDescription(self): |
|
||||||
return "TARGET: %r, SAMPLE: %s" % (self.target, os.path.basename(self.src_sample_dir)) |
|
||||||
|
|
||||||
def setUp(self): |
|
||||||
if os.path.exists(self.workdir): |
|
||||||
shutil.rmtree(self.workdir) |
|
||||||
os.mkdir(self.workdir) |
|
||||||
shutil.copytree(self.src_lib_dir, self.lib_dir) |
|
||||||
shutil.copytree(self.src_sample_dir, self.sample_dir) |
|
||||||
os.remove(os.path.join(self.sample_dir, "project.properties")) |
|
||||||
|
|
||||||
def tearDown(self): |
|
||||||
if os.path.exists(self.workdir): |
|
||||||
shutil.rmtree(self.workdir) |
|
||||||
|
|
||||||
def runTest(self): |
|
||||||
cmd = [os.path.join(os.environ["ANDROID_SDK"], "tools", "android"), "update", "project", "-p", self.lib_dir, "-t", self.target[0]] |
|
||||||
retcode = subprocess.call(cmd) |
|
||||||
self.assertEqual(retcode, 0, "android update opencv project failed") |
|
||||||
|
|
||||||
cmd = ["ant", "-f", os.path.join(self.lib_dir, "build.xml"), "debug"] |
|
||||||
retcode = subprocess.call(cmd) |
|
||||||
self.assertEqual(retcode, 0, "opencv ant build failed") |
|
||||||
|
|
||||||
cmd = [os.path.join(os.environ["ANDROID_SDK"], "tools", "android"), "update", "project", "-p", self.sample_dir, "-t", self.target[1], "-l", os.path.relpath(self.lib_dir, self.sample_dir)] |
|
||||||
retcode = subprocess.call(cmd) |
|
||||||
self.assertEqual(retcode, 0, "android update sample project failed") |
|
||||||
|
|
||||||
cmd = ["ant", "-f", os.path.join(self.sample_dir, "build.xml"), "debug"] |
|
||||||
retcode = subprocess.call(cmd) |
|
||||||
self.assertEqual(retcode, 0, "sample ant build failed") |
|
||||||
|
|
||||||
def suite(workdir, opencv_lib_path, opencv_samples_path): |
|
||||||
suite = unittest.TestSuite() |
|
||||||
for target in [("android-21", "android-14"), ("android-21", "android-17")]: |
|
||||||
for item in os.listdir(opencv_samples_path): |
|
||||||
item = os.path.join(opencv_samples_path, item) |
|
||||||
if (os.path.exists(os.path.join(item, "AndroidManifest.xml"))): |
|
||||||
suite.addTest(TestAntBuild(target, workdir, opencv_lib_path, item)) |
|
||||||
return suite |
|
||||||
|
|
||||||
if __name__ == '__main__': |
|
||||||
parser = argparse.ArgumentParser(description='Test OpenCV for Android SDK with ant') |
|
||||||
parser.add_argument('--sdk_path', help="Path to Android SDK to use for build") |
|
||||||
parser.add_argument("--workdir", default="testspace", help="Working directory (and output)") |
|
||||||
parser.add_argument("opencv_lib_path", help="Path to folder with SDK java library (usually <SDK>/sdk/java/)") |
|
||||||
parser.add_argument("opencv_samples_path", help="Path to folder with SDK samples (usually <SDK>/samples/)") |
|
||||||
|
|
||||||
args = parser.parse_args() |
|
||||||
|
|
||||||
if args.sdk_path is not None: |
|
||||||
os.environ["ANDROID_SDK"] = os.path.abspath(args.sdk_path) |
|
||||||
|
|
||||||
print("Using SDK: %s" % os.environ["ANDROID_SDK"]) |
|
||||||
|
|
||||||
s = suite(abspath(args.workdir), abspath(args.opencv_lib_path), abspath(args.opencv_samples_path)) |
|
||||||
res = unittest.TextTestRunner(verbosity=3).run(s) |
|
||||||
if not res.wasSuccessful(): |
|
||||||
sys.exit(res) |
|
@ -0,0 +1,37 @@ |
|||||||
|
#!/bin/bash -e |
||||||
|
SDK_DIR=$1 |
||||||
|
echo "OpenCV Android SDK path: ${SDK_DIR}" |
||||||
|
|
||||||
|
ANDROID_HOME=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-${ANDROID_SDK?Required ANDROID_HOME/ANDROID_SDK/ANDROID_SDK_ROOT}}} |
||||||
|
ANDROID_NDK=${ANDROID_NDK_HOME-${ANDROID_NDK:-${NDKROOT?Required ANDROID_NDK_HOME/ANDROID_NDK/NDKROOT}}} |
||||||
|
|
||||||
|
echo "Android SDK: ${ANDROID_HOME}" |
||||||
|
echo "Android NDK: ${ANDROID_NDK}" |
||||||
|
|
||||||
|
if [ ! -d "${ANDROID_HOME}" ]; then |
||||||
|
echo "FATAL: Missing Android SDK directory" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
if [ ! -d "${ANDROID_NDK}" ]; then |
||||||
|
echo "FATAL: Missing Android NDK directory" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
export ANDROID_HOME=${ANDROID_HOME} |
||||||
|
export ANDROID_SDK=${ANDROID_HOME} |
||||||
|
export ANDROID_SDK_ROOT=${ANDROID_HOME} |
||||||
|
|
||||||
|
export ANDROID_NDK=${ANDROID_NDK} |
||||||
|
export ANDROID_NDK_HOME=${ANDROID_NDK} |
||||||
|
|
||||||
|
echo "Cloning OpenCV Android SDK ..." |
||||||
|
rm -rf "test-gradle" |
||||||
|
cp -rp "${SDK_DIR}" "test-gradle" |
||||||
|
echo "Cloning OpenCV Android SDK ... Done!" |
||||||
|
|
||||||
|
echo "Run gradle ..." |
||||||
|
(cd "test-gradle/samples"; ./gradlew -i assemble) |
||||||
|
|
||||||
|
echo "#" |
||||||
|
echo "# Done!" |
||||||
|
echo "#" |
@ -1,148 +0,0 @@ |
|||||||
#!/usr/bin/env python |
|
||||||
|
|
||||||
import unittest |
|
||||||
import os, sys, subprocess, argparse, shutil, re |
|
||||||
|
|
||||||
TEMPLATE_ANDROID_MK = '''\ |
|
||||||
LOCAL_PATH := $(call my-dir) |
|
||||||
include $(CLEAR_VARS) |
|
||||||
{cut} |
|
||||||
LOCAL_MODULE := mixed_sample |
|
||||||
LOCAL_SRC_FILES := {cpp1} |
|
||||||
LOCAL_LDLIBS += -llog -ldl |
|
||||||
include $(BUILD_SHARED_LIBRARY) |
|
||||||
include $(CLEAR_VARS) |
|
||||||
{cut} |
|
||||||
LOCAL_MODULE := mixed_sample2 |
|
||||||
LOCAL_SRC_FILES := {cpp2} |
|
||||||
LOCAL_LDLIBS += -llog -ldl |
|
||||||
LOCAL_SHARED_LIBS := mixed_sample |
|
||||||
include $(BUILD_SHARED_LIBRARY) |
|
||||||
''' |
|
||||||
|
|
||||||
TEMPLATE_APPLICATION_MK = '''\ |
|
||||||
APP_STL := gnustl_static |
|
||||||
APP_CPPFLAGS := -frtti -fexceptions -std=c++11 |
|
||||||
APP_ABI := {abi} |
|
||||||
APP_PLATFORM := android-9 |
|
||||||
''' |
|
||||||
|
|
||||||
TEMPLATE_JNI = '''\ |
|
||||||
#include <jni.h> |
|
||||||
#include <opencv2/core.hpp> |
|
||||||
#include <opencv2/imgproc.hpp> |
|
||||||
#include <opencv2/features2d.hpp> |
|
||||||
#include <vector> |
|
||||||
using namespace std; |
|
||||||
using namespace cv; |
|
||||||
extern "C" { |
|
||||||
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial4_Sample4Mixed_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba); |
|
||||||
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial4_Sample4Mixed_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba) |
|
||||||
{ |
|
||||||
Mat& mGr = *(Mat*)addrGray; |
|
||||||
Mat& mRgb = *(Mat*)addrRgba; |
|
||||||
vector<KeyPoint> v; |
|
||||||
Ptr<FastFeatureDetector> detector = FastFeatureDetector::create(50); |
|
||||||
detector->detect(mGr, v); |
|
||||||
for( unsigned int i = 0; i < v.size(); i++ ) |
|
||||||
{ |
|
||||||
const KeyPoint& kp = v[i]; |
|
||||||
circle(mRgb, Point(kp.pt.x, kp.pt.y), 10, Scalar(255,0,0,255)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
''' |
|
||||||
|
|
||||||
#=================================================================================================== |
|
||||||
|
|
||||||
class TestNDKBuild(unittest.TestCase): |
|
||||||
def __init__(self, abi, libtype, opencv_mk_path, workdir, *args, **kwargs): |
|
||||||
unittest.TestCase.__init__(self, *args, **kwargs) |
|
||||||
self.abi = abi # official NDK ABI name or 'all' |
|
||||||
self.libtype = libtype # 'static', etc |
|
||||||
self.opencv_mk_path = opencv_mk_path |
|
||||||
self.workdir = workdir |
|
||||||
self.jnidir = os.path.join(self.workdir, "jni") |
|
||||||
self.cpp1 = "jni_part1.cpp" |
|
||||||
self.cpp2 = "jni_part2.cpp" |
|
||||||
|
|
||||||
def shortDescription(self): |
|
||||||
return "ABI: %s, LIBTYPE: %s" % (self.abi, self.libtype) |
|
||||||
|
|
||||||
def gen_android_mk(self): |
|
||||||
p = [] |
|
||||||
if self.libtype == "static": |
|
||||||
p.append("OPENCV_LIB_TYPE := STATIC") |
|
||||||
elif self.libtype == "shared": |
|
||||||
p.append("OPENCV_LIB_TYPE := SHARED") |
|
||||||
p.append("OPENCV_INSTALL_MODULES:=on") |
|
||||||
elif self.libtype == "shared_opencv_manager": |
|
||||||
p.append("OPENCV_LIB_TYPE := SHARED") |
|
||||||
p.append("OPENCV_INSTALL_MODULES:=off") |
|
||||||
p.append("include %s" % os.path.join(self.opencv_mk_path, "OpenCV.mk")) |
|
||||||
return TEMPLATE_ANDROID_MK.format(cut = "\n".join(p), cpp1 = self.cpp1, cpp2 = self.cpp2) |
|
||||||
|
|
||||||
def gen_jni_code(self): |
|
||||||
return TEMPLATE_JNI |
|
||||||
|
|
||||||
def gen_application_mk(self): |
|
||||||
return TEMPLATE_APPLICATION_MK.format(abi = self.abi) |
|
||||||
|
|
||||||
def write_jni_file(self, fname, contents): |
|
||||||
with open(os.path.join(self.jnidir, fname), "w") as f: |
|
||||||
f.write(contents) |
|
||||||
|
|
||||||
def setUp(self): |
|
||||||
if os.path.exists(self.workdir): |
|
||||||
shutil.rmtree(self.workdir) |
|
||||||
os.mkdir(self.workdir) |
|
||||||
os.mkdir(self.jnidir) |
|
||||||
self.write_jni_file("Android.mk", self.gen_android_mk()) |
|
||||||
self.write_jni_file("Application.mk", self.gen_application_mk()) |
|
||||||
self.write_jni_file(self.cpp1, self.gen_jni_code()) |
|
||||||
self.write_jni_file(self.cpp2, self.gen_jni_code()) |
|
||||||
os.chdir(self.workdir) |
|
||||||
|
|
||||||
def tearDown(self): |
|
||||||
if os.path.exists(self.workdir): |
|
||||||
shutil.rmtree(self.workdir) |
|
||||||
|
|
||||||
def runTest(self): |
|
||||||
ndk_path = os.environ["ANDROID_NDK"] |
|
||||||
retcode = subprocess.call([os.path.join(ndk_path, 'ndk-build'), "V=0"]) |
|
||||||
self.assertEqual(retcode, 0) |
|
||||||
|
|
||||||
def suite(workdir, opencv_mk_path): |
|
||||||
abis = ["armeabi", "armeabi-v7a", "x86", "mips"] |
|
||||||
ndk_path = os.environ["ANDROID_NDK"] |
|
||||||
if os.path.exists(os.path.join(ndk_path, "RELEASE.TXT")): |
|
||||||
with open(os.path.join(ndk_path, "RELEASE.TXT"), "r") as f: |
|
||||||
s = f.read() |
|
||||||
if re.search(r'r10[b-e]', s): |
|
||||||
abis.extend(["arm64-v8a", "x86_64"]) |
|
||||||
if os.path.exists(os.path.join(ndk_path, "source.properties")): # Android NDK 11+ |
|
||||||
abis.extend(["arm64-v8a", "x86_64"]) |
|
||||||
abis.append("all") |
|
||||||
|
|
||||||
suite = unittest.TestSuite() |
|
||||||
for libtype in ["static", "shared", "shared_opencv_manager"]: |
|
||||||
for abi in abis: |
|
||||||
suite.addTest(TestNDKBuild(abi, libtype, opencv_mk_path, workdir)) |
|
||||||
return suite |
|
||||||
|
|
||||||
if __name__ == '__main__': |
|
||||||
parser = argparse.ArgumentParser(description='Test OpenCV for Android SDK with NDK') |
|
||||||
parser.add_argument('--ndk_path', help="Path to Android NDK to use for build") |
|
||||||
parser.add_argument("--workdir", default="testspace", help="Working directory (and output)") |
|
||||||
parser.add_argument("opencv_mk_path", help="Path to folder with OpenCV.mk file (usually <SDK>/sdk/native/jni/") |
|
||||||
|
|
||||||
args = parser.parse_args() |
|
||||||
|
|
||||||
if args.ndk_path is not None: |
|
||||||
os.environ["ANDROID_NDK"] = os.path.abspath(args.ndk_path) |
|
||||||
|
|
||||||
print("Using NDK: %s" % os.environ["ANDROID_NDK"]) |
|
||||||
|
|
||||||
res = unittest.TextTestRunner(verbosity=3).run(suite(os.path.abspath(args.workdir), os.path.abspath(args.opencv_mk_path))) |
|
||||||
if not res.wasSuccessful(): |
|
||||||
sys.exit(res) |
|
@ -0,0 +1,6 @@ |
|||||||
|
ABIs = [ |
||||||
|
ABI("2", "armeabi-v7a", None, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')), |
||||||
|
ABI("3", "arm64-v8a", None), |
||||||
|
ABI("5", "x86_64", None), |
||||||
|
ABI("4", "x86", None), |
||||||
|
] |
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.puzzle15" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.puzzle15" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity |
||||||
|
android:name=".Puzzle15Activity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation" > |
||||||
|
|
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,66 @@ |
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules. |
||||||
|
|
||||||
|
buildscript { |
||||||
|
|
||||||
|
repositories { |
||||||
|
google() |
||||||
|
jcenter() |
||||||
|
} |
||||||
|
dependencies { |
||||||
|
classpath 'com.android.tools.build:gradle:@ANDROID_GRADLE_PLUGIN_VERSION@' |
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong |
||||||
|
// in the individual module build.gradle files |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
allprojects { |
||||||
|
repositories { |
||||||
|
google() |
||||||
|
jcenter() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task clean(type: Delete) { |
||||||
|
delete rootProject.buildDir |
||||||
|
} |
||||||
|
|
||||||
|
//allprojects { |
||||||
|
// gradle.projectsEvaluated { |
||||||
|
// tasks.withType(JavaCompile) { |
||||||
|
// options.compilerArgs << "-Xlint:unchecked" |
||||||
|
// options.compilerArgs << "-Xlint:deprecation" |
||||||
|
// } |
||||||
|
// } |
||||||
|
//} |
||||||
|
|
||||||
|
|
||||||
|
gradle.afterProject { project -> |
||||||
|
if (project.pluginManager.hasPlugin('com.android.application') |
||||||
|
|| project.pluginManager.hasPlugin('com.android.library') |
||||||
|
|| project.pluginManager.hasPlugin('com.android.test') |
||||||
|
|| project.pluginManager.hasPlugin('com.android.feature') ) { |
||||||
|
if (true) { |
||||||
|
gradle.println("Override build ABIs for the project ${project.name}") |
||||||
|
project.android { |
||||||
|
splits { |
||||||
|
abi { |
||||||
|
enable true |
||||||
|
universalApk false |
||||||
|
@ANDROID_ABI_FILTER@ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (true) { |
||||||
|
gradle.println("Override lintOptions for the project ${project.name}") |
||||||
|
project.android { |
||||||
|
lintOptions { |
||||||
|
// checkReleaseBuilds false |
||||||
|
abortOnError false |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.cameracalibration" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.cameracalibration" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> |
||||||
|
|
||||||
|
<activity android:name="CameraCalibrationActivity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.colorblobdetect" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.colorblobdetect" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity android:name="ColorBlobDetectionActivity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,43 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.facedetect" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
|
||||||
|
externalNativeBuild { |
||||||
|
cmake { |
||||||
|
arguments "-DOpenCV_DIR=" + project(':opencv').projectDir + "/@ANDROID_PROJECT_JNI_PATH@"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@ |
||||||
|
targets "detection_based_tracker" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
externalNativeBuild { |
||||||
|
cmake { |
||||||
|
path '@ANDROID_SAMPLE_JNI_PATH@/CMakeLists.txt' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.facedetect" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity android:name="FdActivity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,19 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.6) |
||||||
|
|
||||||
|
# Enable C++11 |
||||||
|
set(CMAKE_CXX_STANDARD 11) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) |
||||||
|
|
||||||
|
set(target detection_based_tracker) |
||||||
|
project(${target} CXX) |
||||||
|
|
||||||
|
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "") |
||||||
|
message(STATUS "ANDROID_ABI=${ANDROID_ABI}") |
||||||
|
find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS}) |
||||||
|
|
||||||
|
file(GLOB srcs *.cpp *.c) |
||||||
|
file(GLOB hdrs *.hpp *.h) |
||||||
|
|
||||||
|
include_directories("${CMAKE_CURRENT_LIST_DIR}") |
||||||
|
add_library(${target} SHARED ${srcs} ${hdrs}) |
||||||
|
target_link_libraries(${target} ${ANDROID_OPENCV_COMPONENTS}) |
@ -1,66 +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 hello-android ) |
|
||||||
ENDIF() |
|
||||||
ENDIF() |
|
||||||
SET( PROJECT_NAME ${PROJECT_NAME} CACHE STRING "The name of your project") |
|
||||||
|
|
||||||
PROJECT( ${PROJECT_NAME} ) |
|
||||||
|
|
||||||
######################################################### |
|
||||||
# Find OpenCV |
|
||||||
######################################################### |
|
||||||
|
|
||||||
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_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) |
|
||||||
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() |
|
@ -1,9 +0,0 @@ |
|||||||
@ECHO OFF |
|
||||||
SETLOCAL |
|
||||||
PUSHD %~dp0 |
|
||||||
SET PROJECT_NAME=hello-android |
|
||||||
SET BUILD_DIR=build_armeabi |
|
||||||
SET ANDROID_ABI=armeabi |
|
||||||
CALL ..\..\..\android\scripts\build.cmd %* |
|
||||||
POPD |
|
||||||
ENDLOCAL |
|
@ -1,13 +0,0 @@ |
|||||||
#!/bin/sh |
|
||||||
cd `dirname $0` |
|
||||||
|
|
||||||
BUILD_DIR=build_armeabi |
|
||||||
opencv_android=`pwd`/../../../android |
|
||||||
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 |
|
@ -1,28 +0,0 @@ |
|||||||
#include <opencv2/core.hpp> |
|
||||||
#include <opencv2/imgproc.hpp> |
|
||||||
#include <opencv2/imgcodecs.hpp> |
|
||||||
#include <opencv2/highgui.hpp> |
|
||||||
|
|
||||||
using namespace cv; |
|
||||||
const char* message = "Hello Android!"; |
|
||||||
|
|
||||||
int main(int argc, char* argv[]) |
|
||||||
{ |
|
||||||
(void)argc; (void)argv; |
|
||||||
// print message to console
|
|
||||||
printf("%s\n", message); |
|
||||||
|
|
||||||
// put message to simple image
|
|
||||||
Size textsize = getTextSize(message, 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), 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; |
|
||||||
} |
|
@ -1,49 +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=hello-android |
|
||||||
|
|
||||||
:: try to load config file |
|
||||||
SET CFG_PATH=..\..\..\android\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\%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 |
|
@ -1,15 +0,0 @@ |
|||||||
#!/bin/sh |
|
||||||
cd `dirname $0` |
|
||||||
PROJECT_NAME=hello-android |
|
||||||
|
|
||||||
# copy file to device (usually takes 10 seconds or more) |
|
||||||
adb push ./bin/$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 |
|
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.imagemanipulations" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.imagemanipulations" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity android:name="ImageManipulationsActivity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.opencv_mobilenet" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 341 |
||||||
|
versionName "3.41" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.opencv_mobilenet" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:allowBackup="true" |
||||||
|
android:icon="@mipmap/ic_launcher" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:roundIcon="@mipmap/ic_launcher_round" |
||||||
|
android:supportsRtl="true" |
||||||
|
android:theme="@style/Theme.AppCompat.NoActionBar"> <!--Full screen mode--> |
||||||
|
<activity android:name=".MainActivity" |
||||||
|
android:screenOrientation="landscape"> <!--Screen orientation--> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<!--Allow to use a camera--> |
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.tutorial1" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.tutorial1" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity android:name="Tutorial1Activity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,43 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.tutorial2" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
|
||||||
|
externalNativeBuild { |
||||||
|
cmake { |
||||||
|
arguments "-DOpenCV_DIR=" + project(':opencv').projectDir + "/@ANDROID_PROJECT_JNI_PATH@"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@ |
||||||
|
targets "mixed_sample" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
externalNativeBuild { |
||||||
|
cmake { |
||||||
|
path '@ANDROID_SAMPLE_JNI_PATH@/CMakeLists.txt' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.tutorial2" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity android:name="Tutorial2Activity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,19 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.6) |
||||||
|
|
||||||
|
# Enable C++11 |
||||||
|
set(CMAKE_CXX_STANDARD 11) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) |
||||||
|
|
||||||
|
set(target mixed_sample) |
||||||
|
project(${target} CXX) |
||||||
|
|
||||||
|
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "") |
||||||
|
message(STATUS "ANDROID_ABI=${ANDROID_ABI}") |
||||||
|
find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS}) |
||||||
|
|
||||||
|
file(GLOB srcs *.cpp *.c) |
||||||
|
file(GLOB hdrs *.hpp *.h) |
||||||
|
|
||||||
|
include_directories("${CMAKE_CURRENT_LIST_DIR}") |
||||||
|
add_library(${target} SHARED ${srcs} ${hdrs}) |
||||||
|
target_link_libraries(${target} ${ANDROID_OPENCV_COMPONENTS}) |
@ -0,0 +1,31 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.tutorial3" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.tutorial3" |
||||||
|
> |
||||||
|
|
||||||
|
<application |
||||||
|
android:label="@string/app_name" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
|
||||||
|
<activity android:name="Tutorial3Activity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
<supports-screens android:resizeable="true" |
||||||
|
android:smallScreens="true" |
||||||
|
android:normalScreens="true" |
||||||
|
android:largeScreens="true" |
||||||
|
android:anyDensity="true" /> |
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||||
|
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,43 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ |
||||||
|
defaultConfig { |
||||||
|
applicationId "org.opencv.samples.tutorial4" |
||||||
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@ |
||||||
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ |
||||||
|
versionCode 301 |
||||||
|
versionName "3.01" |
||||||
|
|
||||||
|
externalNativeBuild { |
||||||
|
cmake { |
||||||
|
arguments "-DOpenCV_DIR=" + project(':opencv').projectDir + "/@ANDROID_PROJECT_JNI_PATH@"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@ |
||||||
|
targets "JNIpart" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||||
|
} |
||||||
|
} |
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@ |
||||||
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@ |
||||||
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' |
||||||
|
} |
||||||
|
} |
||||||
|
externalNativeBuild { |
||||||
|
cmake { |
||||||
|
path '@ANDROID_SAMPLE_JNI_PATH@/CMakeLists.txt' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||||
|
implementation project(':opencv') |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="org.opencv.samples.tutorial4" |
||||||
|
android:versionCode="1" |
||||||
|
android:versionName="1.0" > |
||||||
|
|
||||||
|
<uses-sdk |
||||||
|
android:minSdkVersion="14" |
||||||
|
android:targetSdkVersion="21" /> |
||||||
|
|
||||||
|
<uses-feature android:glEsVersion="0x00020000" android:required="true"/> |
||||||
|
<uses-feature android:name="android.hardware.camera"/> |
||||||
|
<uses-feature android:name="android.hardware.camera2" android:required="false"/> |
||||||
|
<uses-permission android:name="android.permission.CAMERA"/> |
||||||
|
|
||||||
|
<application |
||||||
|
android:allowBackup="true" |
||||||
|
android:icon="@drawable/icon" |
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > |
||||||
|
<activity |
||||||
|
android:name=".Tutorial4Activity" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:screenOrientation="landscape" |
||||||
|
android:configChanges="keyboardHidden|orientation"> |
||||||
|
<intent-filter> |
||||||
|
<action android:name="android.intent.action.MAIN" /> |
||||||
|
<category android:name="android.intent.category.LAUNCHER" /> |
||||||
|
</intent-filter> |
||||||
|
</activity> |
||||||
|
</application> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,19 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.6) |
||||||
|
|
||||||
|
# Enable C++11 |
||||||
|
set(CMAKE_CXX_STANDARD 11) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) |
||||||
|
|
||||||
|
set(target mixed_sample) |
||||||
|
project(${target} CXX) |
||||||
|
|
||||||
|
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "") |
||||||
|
message(STATUS "ANDROID_ABI=${ANDROID_ABI}") |
||||||
|
find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS}) |
||||||
|
|
||||||
|
file(GLOB srcs *.cpp *.c) |
||||||
|
file(GLOB hdrs *.hpp *.h) |
||||||
|
|
||||||
|
include_directories("${CMAKE_CURRENT_LIST_DIR}") |
||||||
|
add_library(${target} SHARED ${srcs} ${hdrs}) |
||||||
|
target_link_libraries(${target} ${ANDROID_OPENCV_COMPONENTS} -lGLESv2 -lEGL -lOpenCL) |
Loading…
Reference in new issue