Skip to content

Commit

Permalink
Merge branch '2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kamaev committed Mar 21, 2013
2 parents bbae054 + b636569 commit 1ca8f33
Show file tree
Hide file tree
Showing 276 changed files with 11,822 additions and 5,158 deletions.
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,6 @@ endif()
# --- OpenCL ---
if(WITH_OPENCL)
include(cmake/OpenCVDetectOpenCL.cmake)
if(OPENCL_FOUND)
set(HAVE_OPENCL 1)
endif()
if(WITH_OPENCLAMDFFT AND CLAMDFFT_INCLUDE_DIR)
set(HAVE_CLAMDFFT 1)
endif()
if(WITH_OPENCLAMDBLAS AND CLAMDBLAS_INCLUDE_DIR)
set(HAVE_CLAMDBLAS 1)
endif()
endif()

# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -799,11 +790,11 @@ if(HAVE_CUDA)
status(" Use fast math:" CUDA_FAST_MATH THEN YES ELSE NO)
endif()

if(HAVE_OPENCL AND BUILD_opencv_ocl)
if(HAVE_OPENCL)
status("")
status(" OpenCL")
if(OPENCL_INCLUDE_DIR)
status(" Include:" ${OPENCL_INCLUDE_DIR})
status(" Include path:" ${OPENCL_INCLUDE_DIRS})
endif()
if(OPENCL_LIBRARIES)
status(" libraries:" ${OPENCL_LIBRARIES})
Expand Down
15 changes: 3 additions & 12 deletions android/service/engine/jni/BinderComponent/HardwareDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,13 @@ int DetectKnownPlatforms()
{
int tegra_status = DetectTegra();

if (3 == tegra_status)
// All Tegra platforms since Tegra3
if (2 < tegra_status)
{
return PLATFORM_TEGRA3;
return PLATFORM_TEGRA + tegra_status - 1;
}
else
{
return PLATFORM_UNKNOWN;
}

// NOTE: Uncomment when all Tegras will be supported
/*if (tegra_status > 0)
* {
* return PLATFORM_TEGRA + tegra_status - 1;
}
else
{
return PLATFORM_UNKNOWN;
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define PLATFORM_TEGRA 1L
#define PLATFORM_TEGRA2 2L
#define PLATFORM_TEGRA3 3L
#define PLATFORM_TEGRA4 4L

int DetectKnownPlatforms();
int GetProcessorCount();
Expand Down
8 changes: 8 additions & 0 deletions android/service/engine/jni/BinderComponent/TegraDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#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()
Expand All @@ -19,9 +20,11 @@ int DetectTegra()
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))
Expand All @@ -41,6 +44,11 @@ int DetectTegra()
break;
}

if (0 == strncmp(tmpbuf, tegra4_config, len4))
{
result = 4;
break;
}
}
gzclose(kernelConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ std::vector<std::pair<int, int> > CommonPackageManager::InitArmRating()
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_TEGRA4, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));

return result;
}
Expand All @@ -218,8 +219,8 @@ std::vector<std::pair<int, int> > CommonPackageManager::InitMipsRating()
}

const std::vector<std::pair<int, int> > CommonPackageManager::ArchRatings[] = {
CommonPackageManager::InitArmRating(),
CommonPackageManager::InitIntelRating(),
CommonPackageManager::InitArmRating(),
CommonPackageManager::InitIntelRating(),
CommonPackageManager::InitMipsRating()
};

Expand Down
9 changes: 9 additions & 0 deletions android/service/engine/jni/NativeService/PackageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ map<int, string> PackageInfo::InitPlatformNameMap()
result[PLATFORM_TEGRA] = PLATFORM_TEGRA_NAME;
result[PLATFORM_TEGRA2] = PLATFORM_TEGRA2_NAME;
result[PLATFORM_TEGRA3] = PLATFORM_TEGRA3_NAME;
result[PLATFORM_TEGRA4] = PLATFORM_TEGRA4_NAME;

return result;
}
Expand Down Expand Up @@ -186,6 +187,10 @@ inline int SplitPlatfrom(const vector<string>& features)
{
result = PLATFORM_TEGRA3;
}
else if (PLATFORM_TEGRA4_NAME == tmp)
{
result = PLATFORM_TEGRA4;
}
}
else
{
Expand Down Expand Up @@ -425,6 +430,10 @@ InstallPath(install_path)
{
CpuID = ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON;
} break;
case PLATFORM_TEGRA4:
{
CpuID = ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON;
} break;
}
}
else
Expand Down
3 changes: 1 addition & 2 deletions android/service/engine/jni/NativeService/PackageInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#define ARCH_ARMv7_NAME "armv7a"
#define ARCH_ARMv8_NAME "armv8"


#define FEATURES_HAS_VFPv3d16_NAME "vfpv3d16"
#define FEATURES_HAS_VFPv3_NAME "vfpv3"
#define FEATURES_HAS_NEON_NAME "neon"
Expand All @@ -25,7 +24,7 @@
#define PLATFORM_TEGRA_NAME "tegra"
#define PLATFORM_TEGRA2_NAME "tegra2"
#define PLATFORM_TEGRA3_NAME "tegra3"

#define PLATFORM_TEGRA4_NAME "tegra4"

class PackageInfo
{
Expand Down
18 changes: 18 additions & 0 deletions android/service/engine/jni/Tests/OpenCVEngineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage2)
#endif
}

TEST(OpenCVEngineTest, GetPathForCompatiblePackage3)
{
sp<IOpenCVEngine> Engine = InitConnect();
Starter.PackageManager->InstalledPackages.clear();
Starter.PackageManager->InstallVersion(2040400, PLATFORM_TEGRA4, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
EXPECT_FALSE(NULL == Engine.get());
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
#ifdef __SUPPORT_TEGRA3
EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra4/lib", String8(result).string());
#else
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
#else
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
#endif
#endif
}

TEST(OpenCVEngineTest, InstallAndGetVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();
Expand Down
22 changes: 22 additions & 0 deletions android/service/engine/jni/Tests/PackageInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ TEST(PackageInfo, FullNameTegra3)
#endif
}

TEST(PackageInfo, FullNameTegra4)
{
PackageInfo info(2040400, PLATFORM_TEGRA4, ARCH_ARMv7 | FEATURES_HAS_NEON);
string name = info.GetFullName();
#ifdef __SUPPORT_TEGRA3
EXPECT_STREQ("org.opencv.lib_v24_tegra4", name.c_str());
#else
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
EXPECT_STREQ("org.opencv.lib_v24_armv7a_neon", name.c_str());
#else
EXPECT_STREQ("org.opencv.lib_v24_armv7a", name.c_str());
#endif
#endif
}

TEST(PackageInfo, FullNameX86SSE2)
{
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
Expand Down Expand Up @@ -148,6 +163,13 @@ TEST(PackageInfo, Tegra3FromFullName)
EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform());
}

TEST(PackageInfo, Tegra4FromFullName)
{
PackageInfo info("org.opencv.lib_v24_tegra4", "/data/data/org.opencv.lib_v24_tegra4");
EXPECT_EQ(2040000, info.GetVersion());
EXPECT_EQ(PLATFORM_TEGRA4, info.GetPlatform());
}

#ifdef __SUPPORT_MIPS
TEST(PackageInfo, MipsFromFullName)
{
Expand Down
16 changes: 16 additions & 0 deletions android/service/engine/jni/Tests/PackageManagmentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ TEST(PackageManager, GetPackagePathForTegra3)
#endif
}

TEST(PackageManager, GetPackagePathForTegra4)
{
PackageManagerStub pm;
EXPECT_TRUE(pm.InstallVersion(2040400, PLATFORM_TEGRA4, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
string path = pm.GetPackagePathByVersion(2040400, PLATFORM_TEGRA4, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
#ifdef __SUPPORT_TEGRA3
EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra4/lib", path.c_str());
#else
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", path.c_str());
#else
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", path.c_str());
#endif
#endif
}

#ifdef __SUPPORT_MIPS
TEST(PackageManager, GetPackagePathForMips)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class HardwareDetector
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_UNKNOWN = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ else if (HardwareDetector.PLATFORM_TEGRA2 == Platfrom)
{
HardwarePlatformView.setText("Tegra 2");
}
else
else if (HardwareDetector.PLATFORM_TEGRA3 == Platfrom)
{
HardwarePlatformView.setText("Tegra 3");
}
else
{
HardwarePlatformView.setText("Tegra 4");
}
}
else
{
Expand Down Expand Up @@ -367,10 +371,10 @@ else if (idx >= 2)
temp.put("Version", NormalizeVersion(OpenCVersion, VersionName));
// HACK: OpenCV Manager for Armv7-a Neon already has Tegra3 optimizations
// that is enabled on proper hardware
if (HardwareDetector.DetectKnownPlatforms() == HardwareDetector.PLATFORM_TEGRA3 &&
if (HardwareDetector.DetectKnownPlatforms() >= HardwareDetector.PLATFORM_TEGRA3 &&
HardwareName.equals("armv7a neon ") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
{
temp.put("Hardware", "Tegra 3");
temp.put("Hardware", "Tegra");
if (Tags == null)
{
Tags = "optimized";
Expand Down
10 changes: 10 additions & 0 deletions cmake/OpenCVDetectAndroidSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,23 @@ macro(add_android_project target path)
ocv_list_filterout(android_proj_jni_files "\\\\.svn")

if(android_proj_jni_files AND EXISTS ${path}/jni/Android.mk AND NOT DEFINED JNI_LIB_NAME)
# find local module name in Android.mk file to build native lib
file(STRINGS "${path}/jni/Android.mk" JNI_LIB_NAME REGEX "LOCAL_MODULE[ ]*:=[ ]*.*" )
string(REGEX REPLACE "LOCAL_MODULE[ ]*:=[ ]*([a-zA-Z_][a-zA-Z_0-9]*)[ ]*" "\\1" JNI_LIB_NAME "${JNI_LIB_NAME}")

# find using of native app glue to determine native activity
file(STRINGS "${path}/jni/Android.mk" NATIVE_APP_GLUE REGEX ".*(call import-module,android/native_app_glue)" )

if(JNI_LIB_NAME)
ocv_include_modules_recurse(${android_proj_NATIVE_DEPS})
ocv_include_directories("${path}/jni")

if (NATIVE_APP_GLUE)
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
list(APPEND android_proj_jni_files ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
set(android_proj_NATIVE_DEPS ${android_proj_NATIVE_DEPS} android)
endif()

add_library(${JNI_LIB_NAME} MODULE ${android_proj_jni_files})
target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})

Expand Down
Loading

0 comments on commit 1ca8f33

Please sign in to comment.