New Tegra detector with Android 4.3 support added. Manager version++.

pull/1338/head
Alexander Smorkalov 11 years ago
parent 7cefb6f50b
commit aa00b5a0ab
  1. 4
      platforms/android/service/engine/AndroidManifest.xml
  2. 33
      platforms/android/service/engine/CMakeLists.txt
  3. 7
      platforms/android/service/engine/jni/BinderComponent/HardwareDetector.cpp
  4. 61
      platforms/android/service/engine/jni/BinderComponent/TegraDetector.cpp
  5. 7
      platforms/android/service/engine/jni/BinderComponent/TegraDetector.h
  6. 11
      platforms/android/service/engine/src/org/opencv/engine/HardwareDetector.java
  7. 4
      platforms/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine"
android:versionCode="29@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.9" >
android:versionCode="210@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.10" >
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>

@ -26,19 +26,32 @@ endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/platforms/android/service/engine/.build/${ANDROID_MANIFEST_FILE}" @ONLY)
link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}")
link_directories(
"${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib"
"${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib"
"${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}")
file(GLOB engine_files "jni/BinderComponent/*.cpp" "jni/BinderComponent/*.h" "jni/include/*.h")
set(engine_libs "z" "binder" "log" "utils")
if (TEGRA_DETECTOR)
if (ANDROID_NATIVE_API_LEVEL GREATER 8)
add_definitions(-DUSE_TEGRA_HW_DETECTOR)
list(APPEND engine_libs ${TEGRA_DETECTOR} GLESv2 EGL)
else()
message(FATAL_ERROR "Tegra detector required native api level 9 or above")
endif()
endif()
# -D__SUPPORT_ARMEABI_FEATURES key is also available
add_definitions(-DPLATFORM_ANDROID -D__SUPPORT_ARMEABI_V7A_FEATURES -D__SUPPORT_TEGRA3 -D__SUPPORT_MIPS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
file(GLOB engine_files "jni/BinderComponent/*.cpp" "jni/BinderComponent/*.h" "jni/include/*.h")
include_directories(jni/BinderComponent jni/include)
include_directories("jni/BinderComponent" "jni/include")
include_directories(SYSTEM "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/system/core/include")
add_library(${engine} SHARED ${engine_files})
target_link_libraries(${engine} z binder log utils)
target_link_libraries(${engine} ${engine_libs})
set_target_properties(${engine} PROPERTIES
OUTPUT_NAME ${engine}
@ -51,7 +64,15 @@ add_custom_command(TARGET ${engine} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-un
file(GLOB engine_jni_files "jni/JNIWrapper/*.cpp" "jni/JNIWrapper/*.h" "jni/include/*.h")
list(APPEND engine_jni_files jni/NativeService/CommonPackageManager.cpp jni/NativeService/PackageInfo.cpp)
include_directories(jni/include jni/JNIWrapper jni/NativeService jni/BinderComponent "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/system/core/include" "${ANDROID_SOURCE_TREE}/frameworks/base/core/jni")
include_directories(
jni/include jni/JNIWrapper
jni/NativeService
jni/BinderComponent
"${ANDROID_SOURCE_TREE}/frameworks/base/include"
"${ANDROID_SOURCE_TREE}/system/core/include"
"${ANDROID_SOURCE_TREE}/frameworks/base/core/jni"
)
add_library(${engine}_jni SHARED ${engine_jni_files})
target_link_libraries(${engine}_jni z binder log utils android_runtime ${engine})

@ -13,7 +13,7 @@ int GetCpuID()
map<string, string> cpu_info = GetCpuInfo();
map<string, string>::const_iterator it;
#if defined(__i386__)
#if defined(__i386__)
LOGD("Using X86 HW detector");
result |= ARCH_X86;
it = cpu_info.find("flags");
@ -161,8 +161,11 @@ int GetProcessorCount()
int DetectKnownPlatforms()
{
#if defined(__arm__) && defined(USE_TEGRA_HW_DETECTOR)
int tegra_status = DetectTegra();
#else
int tegra_status = NOT_TEGRA;
#endif
// All Tegra platforms since Tegra3
if (2 < tegra_status)
{

@ -1,61 +0,0 @@
#include "TegraDetector.h"
#include <zlib.h>
#include <string.h>
#define KERNEL_CONFIG "/proc/config.gz"
#define KERNEL_CONFIG_MAX_LINE_WIDTH 512
#define KERNEL_CONFIG_TEGRA_MAGIC "CONFIG_ARCH_TEGRA=y"
#define KERNEL_CONFIG_TEGRA2_MAGIC "CONFIG_ARCH_TEGRA_2x_SOC=y"
#define KERNEL_CONFIG_TEGRA3_MAGIC "CONFIG_ARCH_TEGRA_3x_SOC=y"
#define KERNEL_CONFIG_TEGRA4_MAGIC "CONFIG_ARCH_TEGRA_11x_SOC=y"
#define MAX_DATA_LEN 4096
int DetectTegra()
{
int result = TEGRA_NOT_TEGRA;
gzFile kernelConfig = gzopen(KERNEL_CONFIG, "r");
if (kernelConfig != 0)
{
char tmpbuf[KERNEL_CONFIG_MAX_LINE_WIDTH];
const char *tegra_config = KERNEL_CONFIG_TEGRA_MAGIC;
const char *tegra2_config = KERNEL_CONFIG_TEGRA2_MAGIC;
const char *tegra3_config = KERNEL_CONFIG_TEGRA3_MAGIC;
const char *tegra4_config = KERNEL_CONFIG_TEGRA4_MAGIC;
int len = strlen(tegra_config);
int len2 = strlen(tegra2_config);
int len3 = strlen(tegra3_config);
int len4 = strlen(tegra4_config);
while (0 != gzgets(kernelConfig, tmpbuf, KERNEL_CONFIG_MAX_LINE_WIDTH))
{
if (0 == strncmp(tmpbuf, tegra_config, len))
{
result = 1;
}
if (0 == strncmp(tmpbuf, tegra2_config, len2))
{
result = 2;
break;
}
if (0 == strncmp(tmpbuf, tegra3_config, len3))
{
result = 3;
break;
}
if (0 == strncmp(tmpbuf, tegra4_config, len4))
{
result = 4;
break;
}
}
gzclose(kernelConfig);
}
else
{
result = TEGRA_DETECTOR_ERROR;
}
return result;
}

@ -2,7 +2,12 @@
#define __TEGRA_DETECTOR_H__
#define TEGRA_DETECTOR_ERROR -2
#define TEGRA_NOT_TEGRA -1
#define NOT_TEGRA -1
#define TEGRA2 2
#define TEGRA3 3
#define TEGRA4i 4
#define TEGRA4 5
#define TEGRA5 6
int DetectTegra();

@ -30,11 +30,12 @@ public class HardwareDetector
// GPU Acceleration options
public static final int FEATURES_HAS_GPU = 0x010000;
public static final int PLATFORM_TEGRA = 1;
public static final int PLATFORM_TEGRA2 = 2;
public static final int PLATFORM_TEGRA3 = 3;
public static final int PLATFORM_TEGRA4 = 4;
public static final int PLATFORM_TEGRA = 1;
public static final int PLATFORM_TEGRA2 = 2;
public static final int PLATFORM_TEGRA3 = 3;
public static final int PLATFORM_TEGRA4i = 4;
public static final int PLATFORM_TEGRA4 = 5;
public static final int PLATFORM_TEGRA5 = 6;
public static final int PLATFORM_UNKNOWN = 0;

@ -107,6 +107,10 @@ public class ManagerActivity extends Activity
{
HardwarePlatformView.setText("Tegra 3");
}
else if (HardwareDetector.PLATFORM_TEGRA4i == Platfrom)
{
HardwarePlatformView.setText("Tegra 4i");
}
else
{
HardwarePlatformView.setText("Tegra 4");

Loading…
Cancel
Save