Merge pull request #663 from asmorkalov:manager_tegra4

pull/656/merge
Andrey Kamaev 12 years ago committed by OpenCV Buildbot
commit 79e0e948a7
  1. 15
      android/service/engine/jni/BinderComponent/HardwareDetector.cpp
  2. 1
      android/service/engine/jni/BinderComponent/HardwareDetector.h
  3. 8
      android/service/engine/jni/BinderComponent/TegraDetector.cpp
  4. 5
      android/service/engine/jni/NativeService/CommonPackageManager.cpp
  5. 9
      android/service/engine/jni/NativeService/PackageInfo.cpp
  6. 3
      android/service/engine/jni/NativeService/PackageInfo.h
  7. 18
      android/service/engine/jni/Tests/OpenCVEngineTest.cpp
  8. 22
      android/service/engine/jni/Tests/PackageInfoTest.cpp
  9. 16
      android/service/engine/jni/Tests/PackageManagmentTest.cpp
  10. 2
      android/service/engine/src/org/opencv/engine/HardwareDetector.java
  11. 10
      android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java

@ -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;
}*/
}

@ -27,6 +27,7 @@
#define PLATFORM_TEGRA 1L
#define PLATFORM_TEGRA2 2L
#define PLATFORM_TEGRA3 3L
#define PLATFORM_TEGRA4 4L
int DetectKnownPlatforms();
int GetProcessorCount();

@ -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()
@ -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))
@ -41,6 +44,11 @@ int DetectTegra()
break;
}
if (0 == strncmp(tmpbuf, tegra4_config, len4))
{
result = 4;
break;
}
}
gzclose(kernelConfig);
}

@ -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;
}
@ -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()
};

@ -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;
}
@ -186,6 +187,10 @@ inline int SplitPlatfrom(const vector<string>& features)
{
result = PLATFORM_TEGRA3;
}
else if (PLATFORM_TEGRA4_NAME == tmp)
{
result = PLATFORM_TEGRA4;
}
}
else
{
@ -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

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

@ -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();

@ -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);
@ -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)
{

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

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

@ -83,10 +83,14 @@ public class ManagerActivity extends Activity
{
HardwarePlatformView.setText("Tegra 2");
}
else
else if (HardwareDetector.PLATFORM_TEGRA3 == Platfrom)
{
HardwarePlatformView.setText("Tegra 3");
}
else
{
HardwarePlatformView.setText("Tegra 4");
}
}
else
{
@ -367,10 +371,10 @@ public class ManagerActivity extends Activity
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";

Loading…
Cancel
Save