mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 11:40:44 +08:00
Package name logic improved;
Aditional tests added; Some bug fixes with different __SUPPORT_XXX defines.
This commit is contained in:
parent
2aacff4c39
commit
422f650b20
@ -24,6 +24,9 @@ LOCAL_C_INCLUDES := \
|
||||
$(TOP)/system/core/include
|
||||
|
||||
LOCAL_CFLAGS += -DPLATFORM_ANDROID
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
@ -62,6 +65,9 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
LOCAL_CFLAGS += -DPLATFORM_ANDROID
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
|
||||
|
||||
LOCAL_MODULE := libOpenCVEngine_jni
|
||||
|
||||
|
@ -63,10 +63,16 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
|
||||
for (vector<PackageInfo>::iterator it = all_packages.begin(); it != all_packages.end(); ++it)
|
||||
{
|
||||
LOGD("Check version \"%s\" compatibility with \"%s\"\n", version.c_str(), it->GetVersion().c_str());
|
||||
if (IsVersionCompatible(version, it->GetVersion()))
|
||||
{
|
||||
LOGD("Compatible");
|
||||
packages.push_back(*it);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGD("NOT Compatible");
|
||||
}
|
||||
}
|
||||
|
||||
if (!packages.empty())
|
||||
|
@ -30,19 +30,23 @@ inline string JoinARMFeatures(int cpu_id)
|
||||
|
||||
if (FEATURES_HAS_NEON2 & cpu_id)
|
||||
{
|
||||
result = string(FEATURES_HAS_NEON2_NAME);
|
||||
if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id) ||(ARCH_ARMv7 & cpu_id)))
|
||||
result = string(FEATURES_HAS_NEON2_NAME);
|
||||
}
|
||||
else if (FEATURES_HAS_NEON & cpu_id)
|
||||
{
|
||||
result = string(FEATURES_HAS_NEON_NAME);
|
||||
if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id)))
|
||||
result = string(FEATURES_HAS_NEON_NAME);
|
||||
}
|
||||
else if (FEATURES_HAS_VFPv3 & cpu_id)
|
||||
{
|
||||
result = string(FEATURES_HAS_VFPv3_NAME);
|
||||
if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id))
|
||||
result = string(FEATURES_HAS_VFPv3_NAME);
|
||||
}
|
||||
else if (FEATURES_HAS_VFPv3d16 & cpu_id)
|
||||
{
|
||||
result = string(FEATURES_HAS_VFPv3d16_NAME);
|
||||
if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id))
|
||||
result = string(FEATURES_HAS_VFPv3d16_NAME);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -182,7 +186,7 @@ inline int SplitPlatfrom(const vector<string>& features)
|
||||
* If platform is unknown it is defined by hardware capabilities using pattern: <arch>_<floating point and vectorization features>_<other features>
|
||||
* Example: armv7_neon, armv5_vfpv3
|
||||
*/
|
||||
PackageInfo::PackageInfo(const string& version, int platform, int cpu_id):
|
||||
PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::string install_path):
|
||||
Version(version),
|
||||
Platform(platform),
|
||||
CpuID(cpu_id),
|
||||
@ -194,7 +198,6 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id):
|
||||
FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1);
|
||||
if (PLATFORM_UNKNOWN != Platform)
|
||||
{
|
||||
LOGD("Try to use known platform !!!");
|
||||
FullName += string("_") + JoinPlatform(platform);
|
||||
}
|
||||
else
|
||||
@ -307,13 +310,18 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id):
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
if (!FullName.empty())
|
||||
{
|
||||
InstallPath = install_path + FullName + "/lib";
|
||||
}
|
||||
}
|
||||
|
||||
PackageInfo::PackageInfo(const string& fullname, const string& install_path, const string& package_version):
|
||||
FullName(fullname),
|
||||
InstallPath(install_path)
|
||||
{
|
||||
LOGD("PackageInfo::PackageInfo(\"%s\", \"%s\")", fullname.c_str(), install_path.c_str());
|
||||
LOGD("PackageInfo::PackageInfo(\"%s\", \"%s\", \"%s\")", fullname.c_str(), install_path.c_str(), package_version.c_str());
|
||||
|
||||
assert(!fullname.empty());
|
||||
assert(!install_path.empty());
|
||||
|
@ -28,7 +28,7 @@
|
||||
class PackageInfo
|
||||
{
|
||||
public:
|
||||
PackageInfo(const std::string& version, int platform, int cpu_id);
|
||||
PackageInfo(const std::string& version, int platform, int cpu_id, std::string install_path = "/data/data/");
|
||||
PackageInfo(const std::string& fullname, const std::string& install_path, const std::string& package_version = "0.0");
|
||||
std::string GetFullName() const;
|
||||
std::string GetVersion() const;
|
||||
|
@ -104,9 +104,9 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.3"));
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
@ -121,6 +121,7 @@ TEST(OpenCVEngineTest, GetPathForUnExistVersion)
|
||||
TEST(OpenCVEngineTest, InstallAndGetVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
EXPECT_TRUE(Engine->InstallVersion(String16("2.4")));
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
|
@ -18,25 +18,24 @@ TEST(PackageInfo, FullNameArmv7)
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7Neon)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
PackageInfo info("241", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
|
||||
EXPECT_STREQ("org.opencv.lib_v24_armv7a_neon", name.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
EXPECT_STREQ("org.opencv.lib_v24_armv7a", name.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7VFPv3)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info("233", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7VFPv3Neon)
|
||||
{
|
||||
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
@ -46,6 +45,46 @@ TEST(PackageInfo, FullNameArmv7VFPv3Neon)
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv5)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv6)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv6);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv6VFPv3)
|
||||
{
|
||||
PackageInfo info("232", PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5_vfpv3", name.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameTegra3)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str());
|
||||
#else
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameX86SSE2)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
@ -64,6 +103,20 @@ TEST(PackageInfo, Armv7NeonFromFullName)
|
||||
EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Armv5FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv5", "/data/data/org.opencv.lib_v23_armv5");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv5, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Armv5VFPv3FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv5_vfpv3", "/data/data/org.opencv.lib_v23_armv5_vfpv3");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv5 | FEATURES_HAS_VFPv3, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, X86SSE2FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v24_x86_sse2", "/data/data/org.opencv.lib_v24_x86_sse2");
|
||||
@ -86,30 +139,6 @@ TEST(PackageInfo, Tegra3FromFullName)
|
||||
EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameTegra3)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str());
|
||||
#else
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameTegra2)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_TEGRA2, 0);
|
||||
EXPECT_TRUE(!info.IsValid());
|
||||
// TODO: Replace if seporate package will be exists
|
||||
//string name = info.GetFullName();
|
||||
//EXPECT_STREQ("org.opencv.lib_v23_tegra2", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Comparator1)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
@ -121,9 +150,11 @@ TEST(PackageInfo, Comparator1)
|
||||
TEST(PackageInfo, Comparator2)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3);
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
PackageInfo info2("org.opencv.lib_v24_armv7a_neon", "/data/data/org.opencv.lib_v24_armv7a_neon");
|
||||
#else
|
||||
PackageInfo info2("org.opencv.lib_v24_armv7a", "/data/data/org.opencv.lib_v24_armv7a");
|
||||
// TODO: Replace if seporate package will be exists
|
||||
//PackageInfo info2("org.opencv.lib_v24_armv7_vfpv3_neon", "/data/data/org.opencv.lib_v24_armv7_vfpv3_neon");
|
||||
#endif
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
}
|
||||
@ -131,8 +162,8 @@ TEST(PackageInfo, Comparator2)
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
TEST(PackageInfo, Comparator3)
|
||||
{
|
||||
PackageInfo info1("230", PLATFORM_TEGRA2, 0);
|
||||
PackageInfo info2("org.opencv.lib_v23_tegra2", "/data/data/org.opencv.lib_v23_tegra2");
|
||||
PackageInfo info1("230", PLATFORM_TEGRA3, 0);
|
||||
PackageInfo info2("org.opencv.lib_v23_tegra3", "/data/data/org.opencv.lib_v23_tegra3");
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using namespace std;
|
||||
|
||||
bool PackageManagerStub::InstallPackage(const PackageInfo& package)
|
||||
{
|
||||
InstalledPackages.push_back(PackageInfo(package.GetFullName(), "/data/data/" + package.GetFullName() + "/lib"));
|
||||
InstalledPackages.push_back(package);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,9 @@ LOCAL_C_INCLUDES := \
|
||||
$(TOP)/system/core/include
|
||||
|
||||
LOCAL_CFLAGS += -O0 -DGTEST_HAS_CLONE=0 -DGTEST_OS_LINUX_ANDROID=1 -DGTEST_HAS_TR1_TUPLE=0
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
|
||||
|
||||
LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user