diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 17bfab49f07772d7965f42c98b1372dbdf6a94ac..72b33093efae67fae50152dc9d282dcc79015f3d 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -97,6 +97,3 @@ endif() if(NOT BUILD_SHARED_LIBS) install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() - -ocv_parse_header2(ZLIB "${CMAKE_CURRENT_SOURCE_DIR}/zlib.h" ZLIB_VERSION PARENT_SCOPE) - diff --git a/android/java.rst b/android/java.rst new file mode 100644 index 0000000000000000000000000000000000000000..b5e3070d28e66ccb317d9d45f08dd0b91150eb6c --- /dev/null +++ b/android/java.rst @@ -0,0 +1,6 @@ +******** +Java API +******** + + +`Java API reference external link (JavaDoc) `_ \ No newline at end of file diff --git a/android/refman.rst b/android/refman.rst index ec95e22a9b8dc886ea18df419ff280344f98af07..12d7ea6ec0a0d2ef86b0323a6563b40f3943213f 100644 --- a/android/refman.rst +++ b/android/refman.rst @@ -5,4 +5,5 @@ OpenCV4Android Reference .. toctree:: :maxdepth: 2 - service/doc/index.rst \ No newline at end of file + service/doc/index.rst + java.rst \ No newline at end of file diff --git a/android/service/doc/BaseLoaderCallback.rst b/android/service/doc/BaseLoaderCallback.rst index d304d4b618a85d6e5428e8928a7e2508d90c74aa..b4ccf6fff64a5c42e9578bdb6fc7f626e04cd8b9 100644 --- a/android/service/doc/BaseLoaderCallback.rst +++ b/android/service/doc/BaseLoaderCallback.rst @@ -3,12 +3,9 @@ Base Loader Callback Interface implementation ********************************************* .. highlight:: java -.. module:: org.opencv.android - :platform: Android - :synopsis: Implements OpenCV initialization callback interface. .. class:: BaseLoaderCallback Basic implementation of LoaderCallbackInterface. Implementation logic is described by diagram. -.. image:: img/AndroidAppUsageModel.dia.png +.. image:: img/AndroidAppUsageModel.png diff --git a/android/service/doc/InstallCallbackInterface.rst b/android/service/doc/InstallCallbackInterface.rst index 3d608606119b99030ea528d237c8dcf1c1f2e5c6..d0044b9f9c3e7e45c9ddd020bbdce833ad2bb872 100644 --- a/android/service/doc/InstallCallbackInterface.rst +++ b/android/service/doc/InstallCallbackInterface.rst @@ -2,10 +2,6 @@ Install Callback Interface ************************** .. highlight:: java -.. module:: org.opencv.android - :platform: Android - :synopsis: Defines callback interface for package management. - .. class:: InstallCallbackInterface Callback interface for package installation or update. diff --git a/android/service/doc/Intro.rst b/android/service/doc/Intro.rst index 509fea76a84752514a0287a3c9b67cd2594716c0..452fc5be8a06ea70821ee31c02f4fc45780968ae 100644 --- a/android/service/doc/Intro.rst +++ b/android/service/doc/Intro.rst @@ -17,7 +17,7 @@ OpenCV Manager is an Android service targeted to manage OpenCV library binaries Usage model for target user --------------------------- -.. image:: img/AndroidAppUsageModel.dia.png +.. image:: img/AndroidAppUsageModel.png First OpenCV app\: @@ -37,4 +37,4 @@ Next OpenCV app\: OpenCV Manager structure ------------------------ -.. image:: img/Structure.dia.png \ No newline at end of file +.. image:: img/Structure.png \ No newline at end of file diff --git a/android/service/doc/JavaHelper.rst b/android/service/doc/JavaHelper.rst index 41e07ef6b91934c47d1f184ae2e0dda9d94e6eb7..9409231b0cf1591b2b24dea276d3531e59373646 100644 --- a/android/service/doc/JavaHelper.rst +++ b/android/service/doc/JavaHelper.rst @@ -3,9 +3,6 @@ Java OpenCV Loader ****************** .. highlight:: java -.. module:: org.opencv.android - :platform: Android - :synopsis: Implements Android dependent Java classes. .. Class:: OpenCVLoader Helper class provides common initialization methods for OpenCV library diff --git a/android/service/doc/LoaderCallbackInterface.rst b/android/service/doc/LoaderCallbackInterface.rst index 2539430d741f8d73bfe27c205b4fa9fadb7f7ae8..a2a2a2d4c81c1437a15b6a40d15186343036bc19 100644 --- a/android/service/doc/LoaderCallbackInterface.rst +++ b/android/service/doc/LoaderCallbackInterface.rst @@ -3,9 +3,6 @@ Loader Callback Interface ************************* .. highlight:: java -.. module:: org.opencv.android - :platform: Android - :synopsis: Defines OpenCV initialization callback interface. .. class:: LoaderCallbackInterface Interface for callback object in case of asynchronous initialization of OpenCV @@ -26,7 +23,7 @@ void onPackageInstall() Callback method that is called in case when package installation is needed - @param callback Answer object with approve and cancel methods and package description + :param callback: Answer object with approve and cancel methods and package description Initialization status constants ------------------------------- diff --git a/android/service/doc/UseCases.rst b/android/service/doc/UseCases.rst index 819ab2499a3da29e2b6c222015e5f37cc3ad93d6..1d42c66d54263203bdf5ef56173a38cafb2d170b 100644 --- a/android/service/doc/UseCases.rst +++ b/android/service/doc/UseCases.rst @@ -7,7 +7,7 @@ First application start There is no OpenCV Manager and OpenCV libraries. -.. image:: img/NoService.dia.png +.. image:: img/NoService.png Second application start ------------------------ @@ -15,15 +15,15 @@ Second application start There is OpenCV Manager service, but there is no OpenCV library. If OpenCV library installation approved\: -.. image:: img/LibInstallAproved.dia.png +.. image:: img/LibInstallAproved.png If OpenCV library installation canceled\: -.. image:: img/LibInstallCanceled.dia.png +.. image:: img/LibInstallCanceled.png Regular application start ------------------------- OpenCV Manager and OpenCV library has bee already installed. -.. image:: img/LibInstalled.dia.png \ No newline at end of file +.. image:: img/LibInstalled.png \ No newline at end of file diff --git a/android/service/doc/img/AndroidAppUsageModel.dia.png b/android/service/doc/img/AndroidAppUsageModel.png similarity index 100% rename from android/service/doc/img/AndroidAppUsageModel.dia.png rename to android/service/doc/img/AndroidAppUsageModel.png diff --git a/android/service/doc/img/LibInstallAproved.dia.png b/android/service/doc/img/LibInstallAproved.png similarity index 100% rename from android/service/doc/img/LibInstallAproved.dia.png rename to android/service/doc/img/LibInstallAproved.png diff --git a/android/service/doc/img/LibInstallCanceled.dia.png b/android/service/doc/img/LibInstallCanceled.png similarity index 100% rename from android/service/doc/img/LibInstallCanceled.dia.png rename to android/service/doc/img/LibInstallCanceled.png diff --git a/android/service/doc/img/LibInstalled.dia.png b/android/service/doc/img/LibInstalled.png similarity index 100% rename from android/service/doc/img/LibInstalled.dia.png rename to android/service/doc/img/LibInstalled.png diff --git a/android/service/doc/img/LibIntsallAproved.dia.png b/android/service/doc/img/LibIntsallAproved.png similarity index 100% rename from android/service/doc/img/LibIntsallAproved.dia.png rename to android/service/doc/img/LibIntsallAproved.png diff --git a/android/service/doc/img/LibIntsallCanceled.dia.png b/android/service/doc/img/LibIntsallCanceled.png similarity index 100% rename from android/service/doc/img/LibIntsallCanceled.dia.png rename to android/service/doc/img/LibIntsallCanceled.png diff --git a/android/service/doc/img/NoService.dia.png b/android/service/doc/img/NoService.png similarity index 100% rename from android/service/doc/img/NoService.dia.png rename to android/service/doc/img/NoService.png diff --git a/android/service/doc/img/Structure.dia.png b/android/service/doc/img/Structure.png similarity index 100% rename from android/service/doc/img/Structure.dia.png rename to android/service/doc/img/Structure.png diff --git a/android/service/engine/AndroidManifest.xml b/android/service/engine/AndroidManifest.xml index 7567dd31ea47ebb5ff5609bc5803ec028c58175a..9512c7b6cd0cd5c3016d044c0453ad6fe2b82df6 100644 --- a/android/service/engine/AndroidManifest.xml +++ b/android/service/engine/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="12" + android:versionName="1.2" > diff --git a/android/service/engine/jni/Android.mk b/android/service/engine/jni/Android.mk index 977ec73c32e1cffc72c1cb3ebcecbbf5515e2e1c..be73f6c5bd3d4a5ca55631e97b24321b24819a7e 100644 --- a/android/service/engine/jni/Android.mk +++ b/android/service/engine/jni/Android.mk @@ -24,6 +24,9 @@ LOCAL_C_INCLUDES := \ $(TOP)/system/core/include LOCAL_CFLAGS += -DPLATFORM_ANDROID +LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES +#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3 +#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_ARMEABI_V7A_FEATURES +#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3 +#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES LOCAL_MODULE := libOpenCVEngine_jni diff --git a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp index 5b870b4130496252fe85204c66b2938cc318a167..f8f7ee4f3cc271db5c70b34e6c20c127d0305878 100644 --- a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp +++ b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp @@ -106,7 +106,7 @@ String16 OpenCVEngine::GetLibPathByVersion(android::String16 version) } else { - LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str()); + LOGE("OpenCV version \"%s\" (%s) is not supported", String8(version).string(), norm_version.c_str()); } return String16(path.c_str()); diff --git a/android/service/engine/jni/NativeService/CommonPackageManager.cpp b/android/service/engine/jni/NativeService/CommonPackageManager.cpp index a9cd82b323a802c35876ec46cc8203592943c7b9..99eb7325c2b8da52fd450d358134f1cb19003f55 100644 --- a/android/service/engine/jni/NativeService/CommonPackageManager.cpp +++ b/android/service/engine/jni/NativeService/CommonPackageManager.cpp @@ -63,10 +63,16 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version, for (vector::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()) @@ -85,10 +91,11 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version, group = CommonPackageManager::IntelRating; int HardwareRating = GetHardwareRating(platform, cpu_id, group); + LOGD("Current hardware platform %d, %d", platform, cpu_id); if (-1 == HardwareRating) { - LOGE("Cannot calculate rating for current hardware platfrom!"); + LOGE("Cannot calculate rating for current hardware platform!"); } else { @@ -109,6 +116,10 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version, { result = found->GetInstalationPath(); } + else + { + LOGI("Found package is incompatible with current hardware platform"); + } } } } @@ -156,8 +167,10 @@ std::vector > CommonPackageManager::InitArmRating() result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv6)); result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3d16)); result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3)); + result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16)); result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv7)); result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3)); + result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON)); result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON)); result.push_back(std::pair(PLATFORM_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3)); result.push_back(std::pair(PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON)); diff --git a/android/service/engine/jni/NativeService/PackageInfo.cpp b/android/service/engine/jni/NativeService/PackageInfo.cpp index b0b48a933d2b600d3622a70cdb014316efb045e6..65828e7402568c6b96949996f1d9531f22b64e6a 100644 --- a/android/service/engine/jni/NativeService/PackageInfo.cpp +++ b/android/service/engine/jni/NativeService/PackageInfo.cpp @@ -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; @@ -179,15 +183,18 @@ inline int SplitPlatfrom(const vector& features) * First part is base namespace. * Second part is version. Version starts from "v" symbol. After "v" symbol version nomber without dot symbol added. * If platform is known third part is platform name - * If platform is unknown it is defined by hardware capabilities using pattern: ___ - * Example: armv7_vfpv3_neon, armv7_vfpv3d16_neon + * If platform is unknown it is defined by hardware capabilities using pattern: __ + * 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), InstallPath("") { +#ifndef __SUPPORT_TEGRA3 + Platform = PLATFORM_UNKNOWN; +#endif FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1); if (PLATFORM_UNKNOWN != Platform) { @@ -199,91 +206,112 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id): { if (ARCH_X86 & CpuID) { - LOGD("Found processor with x86 arch"); + LOGD("PackageInfo::PackageInfo: package arch x86"); FullName += string("_") + ARCH_X86_NAME; - // NOTE: Intel features temporary are not supported - //string features = JoinIntelFeatures(CpuID); - string features; +#ifdef __SUPPORT_INTEL_FEATURES + string features = JoinIntelFeatures(CpuID); if (!features.empty()) { FullName += string("_") + features; } +#endif } - if (ARCH_X64 & CpuID) + else if (ARCH_X64 & CpuID) { - LOGD("Found processor with x64 arch"); - // NOTE: Intel features temporary are not supported - //FullName += string("_") + ARCH_X64_NAME; - //string features = JoinIntelFeatures(CpuID); + LOGD("PackageInfo::PackageInfo: package arch x64"); +#ifdef __SUPPORT_INTEL_x64 + FullName += string("_") + ARCH_X64_NAME; +#else FullName += string("_") + ARCH_X86_NAME; - string features; +#endif +#ifdef __SUPPORT_INTEL_FEATURES + string features = JoinIntelFeatures(CpuID); if (!features.empty()) { FullName += string("_") + features; } +#endif } - if (ARCH_ARMv5 & CpuID) + else if (ARCH_ARMv5 & CpuID) { - LOGD("Found processor with ARMv5 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv5"); FullName += string("_") + ARCH_ARMv5_NAME; +#ifdef __SUPPORT_ARMEABI_FEATURES string features = JoinARMFeatures(CpuID); if (!features.empty()) { FullName += string("_") + features; } +#endif } - if (ARCH_ARMv6 & CpuID) + else if (ARCH_ARMv6 & CpuID) { - LOGD("Found processor with ARMv6 arch"); - // NOTE: ARM v6 used instead ARM v6 + LOGD("PackageInfo::PackageInfo: package arch ARMv6"); + // NOTE: ARM v5 used instead ARM v6 //FullName += string("_") + ARCH_ARMv6_NAME; FullName += string("_") + ARCH_ARMv5_NAME; - // NOTE: ARM features temporary are not supported - //string features = JoinARMFeatures(CpuID); - string features; +#ifdef __SUPPORT_ARMEABI_FEATURES + string features = JoinARMFeatures(CpuID); if (!features.empty()) { FullName += string("_") + features; } +#endif } - if (ARCH_ARMv7 & CpuID) + else if (ARCH_ARMv7 & CpuID) { - LOGD("Found processor with ARMv7 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv7"); FullName += string("_") + ARCH_ARMv7_NAME; - // NOTE: ARM features temporary are not supported - //string features = JoinARMFeatures(CpuID); - string features; +#ifdef __SUPPORT_ARMEABI_V7A_FEATURES + string features = JoinARMFeatures(CpuID); if (!features.empty()) { FullName += string("_") + features; } +#endif } - if (ARCH_ARMv8 & CpuID) + else if (ARCH_ARMv8 & CpuID) { - LOGD("Found processor with ARMv8 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv8"); +#ifdef __SUPPORT_ARMEABI_V8 FullName += string("_") + ARCH_ARMv8_NAME; - string features = JoinARMFeatures(CpuID); - if (!features.empty()) - { - FullName += string("_") + features; - } +#else + FullName += string("_") + ARCH_ARMv7_NAME; +#endif + //string features = JoinARMFeatures(CpuID); + //if (!features.empty()) + //{ + // FullName += string("_") + features; + //} + } + else + { + LOGD("PackageInfo::PackageInfo: package arch unknown"); + Version.clear(); + CpuID = ARCH_UNKNOWN; + Platform = PLATFORM_UNKNOWN; } } else { - LOGD("Found processor with unknown arch"); + LOGD("PackageInfo::PackageInfo: package arch unknown"); Version.clear(); CpuID = ARCH_UNKNOWN; 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()); diff --git a/android/service/engine/jni/NativeService/PackageInfo.h b/android/service/engine/jni/NativeService/PackageInfo.h index d9d93b5213a47f0cb364d0c73ec8099c506b4d88..216ad8f43aa25adacc57a4ed2fedc071f3b86ec1 100644 --- a/android/service/engine/jni/NativeService/PackageInfo.h +++ b/android/service/engine/jni/NativeService/PackageInfo.h @@ -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; diff --git a/android/service/engine/jni/Tests/OpenCVEngineTest.cpp b/android/service/engine/jni/Tests/OpenCVEngineTest.cpp index 0188bc96d1b0ae9ab4e288c701f811a784fc30e1..4ea8b3d2eaf824731465e1d76ea37df80e2d73e8 100644 --- a/android/service/engine/jni/Tests/OpenCVEngineTest.cpp +++ b/android/service/engine/jni/Tests/OpenCVEngineTest.cpp @@ -20,10 +20,7 @@ class ServiceStarter public: ServiceStarter() { - PackageManager = new PackageManagerStub(); - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); - PackageManager->InstalledPackages.push_back(info); - + PackageManager = new PackageManagerStub(); Engine = new OpenCVEngine(PackageManager); defaultServiceManager()->addService(IOpenCVEngine::descriptor, Engine); @@ -34,7 +31,7 @@ public: { delete PackageManager; } -private: + PackageManagerStub* PackageManager; sp Engine; }; @@ -67,20 +64,50 @@ TEST(OpenCVEngineTest, GetVersion) EXPECT_EQ(OPEN_CV_ENGINE_VERSION, Version); } -TEST(OpenCVEngineTest, InstallVersion) +TEST(OpenCVEngineTest, GetPathForExecHWExistVersion) { sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("240", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); EXPECT_FALSE(NULL == Engine.get()); - bool result = Engine->InstallVersion(String16("2.4")); - EXPECT_EQ(true, result); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); + #ifdef __SUPPORT_TEGRA3 + EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/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, GetPathForExistVersion) +TEST(OpenCVEngineTest, GetPathForExecHWOldVersion) { sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); EXPECT_FALSE(NULL == Engine.get()); - String16 result = Engine->GetLibPathByVersion(String16("2.3")); - EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7/lib",String8(result).string()); + String16 result = Engine->GetLibPathByVersion(String16("2.4.1")); + #ifdef __SUPPORT_TEGRA3 + EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/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, GetPathForExecHWNewVersion) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("241", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + EXPECT_FALSE(NULL == Engine.get()); + String16 result = Engine->GetLibPathByVersion(String16("2.4.2")); + EXPECT_EQ(0, result.size()); } TEST(OpenCVEngineTest, GetPathForUnExistVersion) @@ -91,11 +118,58 @@ TEST(OpenCVEngineTest, GetPathForUnExistVersion) EXPECT_EQ(0, result.size()); } +TEST(OpenCVEngineTest, GetPathForCompatiblePackage1) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv5); + EXPECT_FALSE(NULL == Engine.get()); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); + EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string()); +} + +TEST(OpenCVEngineTest, GetPathForCompatiblePackage2) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | 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_tegra3/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, GetPathForInCompatiblePackage1) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X64); + EXPECT_FALSE(NULL == Engine.get()); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); + EXPECT_EQ(0, result.size()); +} + TEST(OpenCVEngineTest, InstallAndGetVersion) { sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); EXPECT_FALSE(NULL == Engine.get()); - EXPECT_TRUE(Engine->InstallVersion(String16("2.5"))); - String16 result = Engine->GetLibPathByVersion(String16("2.5")); - EXPECT_STREQ("/data/data/org.opencv.lib_v25_tegra3/lib", String8(result).string()); + EXPECT_TRUE(Engine->InstallVersion(String16("2.4"))); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); +#ifdef __SUPPORT_TEGRA3 + EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/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 } \ No newline at end of file diff --git a/android/service/engine/jni/Tests/PackageInfoTest.cpp b/android/service/engine/jni/Tests/PackageInfoTest.cpp index cef3eef9d9f4e36d868fed93644af8de91ecf483..c8f6c7cedaa5673674939e4a0eabe5d93d750ab0 100644 --- a/android/service/engine/jni/Tests/PackageInfoTest.cpp +++ b/android/service/engine/jni/Tests/PackageInfoTest.cpp @@ -13,50 +13,108 @@ TEST(PackageInfo, FullNameArmv7) { PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); string name = info.GetFullName(); - EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str()); + EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str()); } 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(); - EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str()); - // TODO: Replace if seporate package will be exists - //EXPECT_STREQ("org.opencv.lib_v23_armv7_neon", name.c_str()); +#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 } 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_armv7", name.c_str()); - // TODO: Replace if seporate package will be exists - //EXPECT_STREQ("org.opencv.lib_v23_armv7_vfpv3", name.c_str()); + 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(); - EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str()); - // TODO: Replace if seporate package will be exists - //EXPECT_STREQ("org.opencv.lib_v23_armv7_neon", name.c_str()); +#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 +} + +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); string name = info.GetFullName(); +#ifdef __SUPPORT_INTEL_FEATURES + EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str()); +#else EXPECT_STREQ("org.opencv.lib_v23_x86", name.c_str()); - // TODO: Replace if seporate package will be exists - //EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str()); +#endif +} + +TEST(PackageInfo, Armv7NeonFromFullName) +{ + PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon"); + EXPECT_EQ("230", info.GetVersion()); + EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID()); } -TEST(PackageInfo, Armv7VFPv3NeonFromFullName) +TEST(PackageInfo, Armv5FromFullName) { - PackageInfo info("org.opencv.lib_v23_armv7_vfpv3_neon", "/data/data/org.opencv.lib_v23_armv7_vfpv3_neon"); + PackageInfo info("org.opencv.lib_v23_armv5", "/data/data/org.opencv.lib_v23_armv5"); EXPECT_EQ("230", info.GetVersion()); - EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON, info.GetCpuID()); + 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) @@ -81,24 +139,6 @@ TEST(PackageInfo, Tegra3FromFullName) EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform()); } -TEST(PackageInfo, FullNameTegra3) -{ - PackageInfo info("230", PLATFORM_TEGRA3, 0); - EXPECT_TRUE(!info.IsValid()); - // TODO: Replace if seporate package will be exists - //string name = info.GetFullName(); - //EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str()); -} - -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); @@ -110,18 +150,21 @@ TEST(PackageInfo, Comparator1) TEST(PackageInfo, Comparator2) { PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3); - PackageInfo info2("org.opencv.lib_v24_armv7", "/data/data/org.opencv.lib_v24_armv7"); - // 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"); +#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"); +#endif EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str()); EXPECT_EQ(info1, info2); } -// TODO: Enable test if seporate package will be exists -// TEST(PackageInfo, Comparator3) -// { -// PackageInfo info1("230", PLATFORM_TEGRA2, 0); -// PackageInfo info2("org.opencv.lib_v23_tegra2", "/data/data/org.opencv.lib_v23_tegra2"); -// EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str()); -// EXPECT_EQ(info1, info2); -// } \ No newline at end of file +#ifdef __SUPPORT_TEGRA3 +TEST(PackageInfo, Comparator3) +{ + 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); +} +#endif \ No newline at end of file diff --git a/android/service/engine/jni/Tests/PackageManagerStub.cpp b/android/service/engine/jni/Tests/PackageManagerStub.cpp index aebf8ea541f2f89f8ed6e96d216d898fa0d8e7c2..20be63a9b76508b31fdcfffc403e562a8f6f9329 100644 --- a/android/service/engine/jni/Tests/PackageManagerStub.cpp +++ b/android/service/engine/jni/Tests/PackageManagerStub.cpp @@ -4,7 +4,7 @@ using namespace std; bool PackageManagerStub::InstallPackage(const PackageInfo& package) { - InstalledPackages.push_back(PackageInfo(package.GetFullName(), "/data/data/" + package.GetFullName())); + InstalledPackages.push_back(package); return true; } diff --git a/android/service/engine/jni/Tests/PackageManagmentTest.cpp b/android/service/engine/jni/Tests/PackageManagmentTest.cpp index c0fbfa0ed9093318ab287630e4da411371ac0180..8d5c43afb671df253d9d84a9bf6cc067b266897f 100644 --- a/android/service/engine/jni/Tests/PackageManagmentTest.cpp +++ b/android/service/engine/jni/Tests/PackageManagmentTest.cpp @@ -24,47 +24,45 @@ TEST(PackageManager, InstalledVersions) TEST(PackageManager, CheckVersionInstalled) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_TEGRA3, 0); + PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); pm.InstalledPackages.push_back(info); - EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_TEGRA3, 0)); + EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_UNKNOWN, ARCH_ARMv7)); } TEST(PackageManager, InstallVersion) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_TEGRA3, 0); + PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5); pm.InstalledPackages.push_back(info); - EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_TEGRA3, 0)); + EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_UNKNOWN, ARCH_ARMv5)); EXPECT_EQ(2, pm.InstalledPackages.size()); - EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_TEGRA3, 0)); + EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_UNKNOWN, ARCH_ARMv5)); } TEST(PackageManager, GetPackagePathForArmv7) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); - pm.InstalledPackages.push_back(info); + EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7)); string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7); - EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7/lib", path.c_str()); + EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str()); } TEST(PackageManager, GetPackagePathForArmv7Neon) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON); - pm.InstalledPackages.push_back(info); - + EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON)); string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON); - EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7/lib", path.c_str()); - // TODO: Replace if seporate package will be exists - //EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7_neon/lib", path.c_str()); +#ifdef __SUPPORT_ARMEABI_V7A_FEATURES + EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str()); +#else + EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str()); +#endif } TEST(PackageManager, GetPackagePathForX86) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86); - pm.InstalledPackages.push_back(info); + EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86)); string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86); EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str()); } @@ -72,12 +70,29 @@ TEST(PackageManager, GetPackagePathForX86) TEST(PackageManager, GetPackagePathForX86SSE2) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2); - pm.InstalledPackages.push_back(info); + EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2)); string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2); +#ifdef __SUPPORT_INTEL_FEATURES + EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str()); +#else EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str()); - // TODO: Replace if seporate package will be exists - //EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str()); +#endif +} + +TEST(PackageManager, GetPackagePathForTegra3) +{ + PackageManagerStub pm; + EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON)); + string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); +#ifdef __SUPPORT_TEGRA3 + EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str()); +#else +#ifdef __SUPPORT_ARMEABI_V7A_FEATURES + EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str()); +#else + EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str()); +#endif +#endif } // TODO: Enable tests if seporate package will be exists @@ -89,12 +104,5 @@ TEST(PackageManager, GetPackagePathForX86SSE2) // string path = pm.GetPackagePathByVersion("240", PLATFORM_TEGRA2, 0); // EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra2/lib", path.c_str()); // } -// -// TEST(PackageManager, GetPackagePathForTegra3) -// { -// PackageManagerStub pm; -// PackageInfo info("230", PLATFORM_TEGRA3, 0); -// pm.InstalledPackages.push_back(info); -// string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, 0); -// EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str()); -// } + + diff --git a/android/service/engine/jni/Tests/Tests.mk b/android/service/engine/jni/Tests/Tests.mk index 083e37ac6bc9efd6b00d23872413b6cf959b6ca5..3dab5f010abdb56c391919ab7424dda87052758a 100644 --- a/android/service/engine/jni/Tests/Tests.mk +++ b/android/service/engine/jni/Tests/Tests.mk @@ -17,7 +17,7 @@ LOCAL_SRC_FILES := \ Tests/PackageManagmentTest.cpp \ Tests/PackageInfoTest.cpp \ Tests/OpenCVEngineTest.cpp \ - Tests/TestMain.cpp + Tests/TestMain.cpp # Tests/HardwareDetectionTest.cpp \ LOCAL_C_INCLUDES := \ @@ -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_ARMEABI_V7A_FEATURES +#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3 +#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined diff --git a/android/service/engine/jni/include/EngineCommon.h b/android/service/engine/jni/include/EngineCommon.h index 9968f4ff5b8c2a6ac494d7c955e42da236e57907..96f6dee9f715ff5b816e3fe159fa3cbbb6b84716 100644 --- a/android/service/engine/jni/include/EngineCommon.h +++ b/android/service/engine/jni/include/EngineCommon.h @@ -3,7 +3,7 @@ // Global tag for Logcat output #undef LOG_TAG -#define LOG_TAG "OpenCVEngine" +#define LOG_TAG "OpenCVEngine" #ifndef OPEN_CV_ENGINE_VERSION #define OPEN_CV_ENGINE_VERSION 1 diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index 9ece3a05959966bd05e110a1add8630e771a7ef4..42babbbdad033c4f29765e0fd4b4cf5155276598 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -1,5 +1,5 @@ if(${CMAKE_VERSION} VERSION_LESS "2.8.3") - message(STATUS WITH_CUDA flag requires CMake 2.8.3. CUDA support is disabled.) + message(STATUS "WITH_CUDA flag requires CMake 2.8.3 or newer. CUDA support is disabled.") return() endif() diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 54a1bde5f2ac76c4d4e61b6bd8fac76e61ad86cb..36b89cae5463f362bac0b5ee096baebda4ccbd4c 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -7,13 +7,6 @@ if(BUILD_ZLIB) ocv_clear_vars(ZLIB_FOUND) else() include(FindZLIB) - if(ZLIB_VERSION_STRING) - #cmake 2.8.2 bug - it fails to determine zlib version - unset(ZLIB_VERSION_STRING CACHE) - endif() - if(ZLIB_FOUND) - ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION "") - endif() if(ZLIB_FOUND AND ANDROID) if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so") set(ZLIB_LIBRARY z) @@ -29,6 +22,8 @@ if(NOT ZLIB_FOUND) set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib") set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}") + + ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION) endif() # --- libtiff (optional, should be searched after zlib) --- @@ -149,3 +144,8 @@ set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VE if(WITH_OPENEXR) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake") endif() + +#cmake 2.8.2 bug - it fails to determine zlib version +if(ZLIB_FOUND) + ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION) +endif() \ No newline at end of file diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 8698024cbbd671efaa0e551f49e41c610b26e491..7fa56781f86bf5b64e7e89fde92e400dd60352ce 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -468,32 +468,36 @@ macro(ocv_parse_header FILENAME FILE_VAR) endmacro() # read single version define from the header file -macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME SCOPE) +macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME) + ocv_clear_vars(${LIBNAME}_VERSION_MAJOR + ${LIBNAME}_VERSION_MAJOR + ${LIBNAME}_VERSION_MINOR + ${LIBNAME}_VERSION_PATCH + ${LIBNAME}_VERSION_TWEAK + ${LIBNAME}_VERSION_STRING) set(${LIBNAME}_H "") if(EXISTS "${HDR_PATH}") file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1) endif() + if(${LIBNAME}_H) string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}") string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}") string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_PATCH "${${LIBNAME}_H}") - set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${SCOPE}) - set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${SCOPE}) - set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${SCOPE}) - set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}" ${SCOPE}) + set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${ARGN}) + set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${ARGN}) + set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${ARGN}) + set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}") # append a TWEAK version if it exists: set(${LIBNAME}_VERSION_TWEAK "") if("${${LIBNAME}_H}" MATCHES "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") - set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${SCOPE}) - set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${SCOPE}) + set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${ARGN}) + endif() + if(${LIBNAME}_VERSION_TWEAK) + set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${ARGN}) + else() + set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}" ${ARGN}) endif() - else() - ocv_clear_vars(${LIBNAME}_VERSION_MAJOR - ${LIBNAME}_VERSION_MAJOR - ${LIBNAME}_VERSION_MINOR - ${LIBNAME}_VERSION_PATCH - ${LIBNAME}_VERSION_TWEAK - ${LIBNAME}_VERSION_STRING) endif() endmacro() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index cf19934116655e2d9c850c7a80f74f45e50d0432..bb04fa907a4b7b33f6b5e3ea45c6179859b9b26f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -47,6 +47,11 @@ if(BUILD_DOCS AND HAVE_SPHINX) endif() endforeach() + file(GLOB_RECURSE _OPENCV_FILES_REF "${OpenCV_SOURCE_DIR}/android/service/doc/*.rst") + file(GLOB_RECURSE _OPENCV_FILES_REF_PICT "${OpenCV_SOURCE_DIR}/android/service/doc/*.png" "${OpenCV_SOURCE_DIR}/android/service/doc/*.jpg") + list(APPEND OPENCV_FILES_REF ${_OPENCV_FILES_REF}) + list(APPEND OPENCV_FILES_REF_PICT ${_OPENCV_FILES_REF_PICT}) + configure_file("${OpenCV_SOURCE_DIR}/modules/refman.rst.in" "${OpenCV_SOURCE_DIR}/modules/refman.rst" IMMEDIATE @ONLY) file(GLOB_RECURSE OPENCV_FILES_UG user_guide/*.rst) @@ -61,9 +66,11 @@ if(BUILD_DOCS AND HAVE_SPHINX) COMMAND ${SPHINX_BUILD} -b latex -c ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. . COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/pics ${CMAKE_CURRENT_BINARY_DIR}/doc/opencv1/pics COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2refman.tex + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex + COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex + COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex COMMAND ${PDFLATEX_COMPILER} opencv_user.tex COMMAND ${PDFLATEX_COMPILER} opencv_user.tex COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex diff --git a/doc/conf.py b/doc/conf.py index a633c2401279e90b837ac2cb9a2b6f93d28be10f..7abafa3596ac81bbf4027c609f9045a4d62df3fb 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -234,6 +234,8 @@ latex_documents = [ u'', 'manual'), ('doc/tutorials/tutorials', 'opencv_tutorials.tex', u'The OpenCV Tutorials', u'', 'manual'), + ('android/refman', 'opencv2manager.tex', u'The OpenCV Manager Manual', + u'', 'manual'), ] preamble =""" diff --git a/doc/tutorials/introduction/android_binary_package/android_binary_package.rst b/doc/tutorials/introduction/android_binary_package/android_binary_package.rst index 72639b3a6625c738b5955c96a408bede6f4cdef6..5f61eadca3bec3becafb96c322d758051f51b44a 100644 --- a/doc/tutorials/introduction/android_binary_package/android_binary_package.rst +++ b/doc/tutorials/introduction/android_binary_package/android_binary_package.rst @@ -314,26 +314,30 @@ Well, running samples from Eclipse is very simple: How to use OpenCV library project in your application ===================================================== -In this section we will explain how to make some existing application to use OpenCV. Starting from 2.4.2 release on Android so-called "OpenCV Manager" is used for providing applications with the best version of OpenCV. You can get more information here: :ref:`Android_OpenCV_Manager`. +In this section we will explain how to make some existing application to use OpenCV. +Starting from 2.4.2 release on Android so-called "OpenCV Manager" is used for providing applications with the best version of OpenCV. +You can get more information here: :ref:`Android_OpenCV_Manager`. Application development with async initialization ------------------------------------------------- -Using async initialization is a preferred way for application development. It uses OpenCV Manager Android service to get OpenCV libraries. +Using async initialization is a preferred way for application development. It uses the OpenCV Manager for access to OpenCV libraries. -#. Add OpenCV library project to your workspace. Go to :guilabel:`File –> Import –> Existing project in your workspace`, push Browse button and select OpenCV SDK path. +#. Add OpenCV library project to your workspace. Use menu :guilabel:`File –> Import –> Existing project in your workspace`, + push :guilabel:`Browse` button and select OpenCV SDK path (:file:`OpenCV-2.4.2-android-sdk/sdk`). .. image:: images/eclipse_opencv_dependency0.png :alt: Add dependency from OpenCV library :align: center -#. In application project add reference to OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``; +#. In application project add a reference to the OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``. .. image:: images/eclipse_opencv_dependency1.png :alt: Add dependency from OpenCV library :align: center -If you want to use OpenCV Manager-based approach you need to install packages with the Service and OpenCV package for you platform. You can do it using Google Play service or manually with adb tool: +To use OpenCV Manager-based approach you need to install packages with the `Manager` and `OpenCV binary package` for you platform. +You can do it using Google Play Market or manually with ``adb`` tool: .. code-block:: sh :linenos: @@ -341,7 +345,7 @@ If you want to use OpenCV Manager-based approach you need to install packages wi adb install ./org.opencv.engine.apk adb install ./org.opencv.lib_v24_.apk -There is a very base code snippet for Async init. It shows only basis principles of library Initiation. See the "15-puzzle" OpenCV sample for details. +There is a very base code snippet implementing the async initialization. It shows basic principles. See the "15-puzzle" OpenCV sample for details. .. code-block:: java :linenos: @@ -354,14 +358,14 @@ There is a very base code snippet for Async init. It shows only basis principles switch (status) { case LoaderCallbackInterface.SUCCESS: { - Log.i(TAG, "OpenCV loaded successfully"); - // Create and set View - mView = new puzzle15View(mAppContext); - setContentView(mView); + Log.i(TAG, "OpenCV loaded successfully"); + // Create and set View + mView = new puzzle15View(mAppContext); + setContentView(mView); } break; default: { - super.onManagerConnected(status); + super.onManagerConnected(status); } break; } } @@ -385,55 +389,82 @@ There is a very base code snippet for Async init. It shows only basis principles } It this case application works with OpenCV Manager in asynchronous fashion. ``OnManagerConnected`` callback will be called in UI thread, when initialization finishes. -Please note, that it is not allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback. Load your own native libraries after OpenCV initialization. +Please note, that it is not allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback. +Load your own native libraries that depend on OpenCV after the successful OpenCV initialization. Application development with static initialization -------------------------------------------------- -According to this approach all OpenCV binaries are linked and put to your application package. It is designed mostly for development purposes. -This way is deprecated for the production code, release package should communicate with OpenCV Manager, use the async initialization described above. +According to this approach all OpenCV binaries are included into your application package. It is designed mostly for development purposes. +This approach is deprecated for the production code, release package is recommended to communicate with OpenCV Manager via the async initialization described above. -#. Add OpenCV library project to your workspace. Go to :guilabel:`File –> Import –> Existing project in your workspace`, push :guilabel:`Browse` button and select OpenCV SDK path. +#. Add the OpenCV library project to your workspace the same way as for the async initialization above. + Use menu :guilabel:`File –> Import –> Existing project in your workspace`, push :guilabel:`Browse` button and select OpenCV SDK path (:file:`OpenCV-2.4.2-android-sdk/sdk`). .. image:: images/eclipse_opencv_dependency0.png :alt: Add dependency from OpenCV library :align: center -#. In application project add reference to OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``; +#. In the application project add a reference to the OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``; .. image:: images/eclipse_opencv_dependency1.png :alt: Add dependency from OpenCV library :align: center -#. Copy native libs to your project directory to folder :file:`libs/target_arch/`. +#. If your application project **doesn't have a JNI part**, just copy the OpenCV native libs to your project directory to folder :file:`libs/target_arch/`. + + In case of the application project **with a JNI part**, instead of manual libraries copying you need to modify your ``Android.mk`` file: + add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before ``"include path_to_OpenCV-2.4.2-android-sdk/sdk/native/jni/OpenCV.mk"`` -After adding depedency from OpenCV library project, Eclipse will automatically copy all needed libraries to the application package. -To use OpenCV functionality you need to add OpenCV library initialization code before using any OpenCV specific code, for example, to the static section of ``Activity`` class. + .. code-block:: make + :linenos: -.. code-block:: java - :linenos: + OPENCV_CAMERA_MODULES:=on + OPENCV_INSTALL_MODULES:=on + + The result should look like the following: + + .. code-block:: make + :linenos: + + include $(CLEAR_VARS) + + # OpenCV + OPENCV_CAMERA_MODULES:=on + OPENCV_INSTALL_MODULES:=on + include ../../sdk/native/jni/OpenCV.mk + + After that the OpenCV libraries will be copied to your application :file:`libs` folder during the JNI part build. + + Eclipse will automatically include all the libraries from the :file:`libs` folder to the application package (APK). - static { - if (!OpenCVLoader.initDebug()) { - // Report initialization error +#. The last step of enabling OpenCV in your application is Java initialization code before call to OpenCV API. + It can be done, for example, in the static section of the ``Activity`` class: + + .. code-block:: java + :linenos: + + static { + if (!OpenCVLoader.initDebug()) { + // Handle initialization error + } } - } -If you application includes other OpenCV-dependent native libraries you need to init OpenCV before them. + If you application includes other OpenCV-dependent native libraries you should load them **after** OpenCV initialization: -.. code-block:: java - :linenos: + .. code-block:: java + :linenos: - static { - if (OpenCVLoader.initDebug()) { - System.loadLibrary("my_super_lib1"); - System.loadLibrary("my_super_lib2"); - } else { - // Report initialization error + static { + if (!OpenCVLoader.initDebug()) { + // Handle initialization error + } else { + System.loadLibrary("my_jni_lib1"); + System.loadLibrary("my_jni_lib2"); + } } - } -Whats next? -=========== +What's next? +============ Read the :ref:`Android_Binary_Package_with_NDK` tutorial to learn how to add native OpenCV code to your Android project. diff --git a/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.rst b/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.rst index 86d67ff8715dcf8c8b9ded8d77a5012066674419..93ab5d421aa9eb8643de4df46b0889a45b586652 100644 --- a/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.rst +++ b/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.rst @@ -162,8 +162,12 @@ then paste the CDT 8.0 repository URL http://download.eclipse.org/tools/cdt/rele #. Define the ``NDKROOT`` environment variable containing the path to Android NDK in your system (e.g. **"X:\\Apps\\android-ndk-r8"** or **"/opt/android-ndk-r8"**). -#. CDT Builder is configured for Windows hosts, on Linux or MacOS open `Project Properties` of the projects having JNI part (`face-detection`, `Tutorial 3` and `Tutorial 4`), select :guilabel:`C/C++ Build` in the left pane, remove **".cmd"** and leave ``"${NDKROOT}/ndk-build"`` in the :guilabel:`Build command` edit box and click :guilabel:`OK`. - +#. | CDT Builder is already configured for **Windows** hosts, + | on **Linux** or **MacOS** a small modification is required: + + Open `Project Properties` of the projects having JNI part (`face-detection`, `Tutorial 3` and `Tutorial 4`), + select :guilabel:`C/C++ Build` in the left pane, + remove **".cmd"** and leave ``"${NDKROOT}/ndk-build"`` in the :guilabel:`Build command` edit box and click :guilabel:`OK`. .. image:: images/eclipse_cdt_cfg4.png :alt: Configure CDT @@ -242,13 +246,15 @@ To build your own Android application, which uses OpenCV from native part, the f include C:\Work\android-opencv\OpenCV-2.4.0\share\OpenCV\OpenCV.mk - should be inserted into the :file:`jni/Android.mk` file right after the line + should be inserted into the :file:`jni/Android.mk` file **after** the line .. code-block:: make include $(CLEAR_VARS) - Several variables can be used to customize OpenCV stuff, they should be set **before** the ``"include ...\OpenCV.mk"`` line: +#. Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when your application uses the `async initialization` via the `OpenCV Manager` API. + + Note: these variables should be set **before** the ``"include .../OpenCV.mk"`` line: .. code-block:: make diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 732bf0e1132a71031a0c23ed9ad2493fb97211dd..5cf560998c7c49f0d5a37d94deb05caed39ba2b3 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -407,11 +407,11 @@ Decomposes a projection matrix into a rotation matrix and a camera matrix. :param rotMatrZ: Optional 3x3 rotation matrix around z-axis. - :param eulerAngles: Optional three-element vector containing three Euler angles of rotation. + :param eulerAngles: Optional three-element vector containing three Euler angles of rotation in degrees. The function computes a decomposition of a projection matrix into a calibration and a rotation matrix and the position of a camera. -It optionally returns three rotation matrices, one for each axis, and three Euler angles that could be used in OpenGL. +It optionally returns three rotation matrices, one for each axis, and three Euler angles that could be used in OpenGL. Note, there is always more than one sequence of rotations about the three principle axes that results in the same orientation of an object, eg. see [Slabaugh]_. Returned tree rotation matrices and corresponding three Euler angules are only one of the possible solutions. The function is based on :ocv:func:`RQDecomp3x3` . @@ -999,9 +999,7 @@ Computes an RQ decomposition of 3x3 matrices. The function computes a RQ decomposition using the given rotations. This function is used in :ocv:func:`decomposeProjectionMatrix` to decompose the left 3x3 submatrix of a projection matrix into a camera and a rotation matrix. -It optionally returns three rotation matrices, one for each axis, and the three Euler angles -(as the return value) -that could be used in OpenGL. +It optionally returns three rotation matrices, one for each axis, and the three Euler angles in degrees (as the return value) that could be used in OpenGL. Note, there is always more than one sequence of rotations about the three principle axes that results in the same orientation of an object, eg. see [Slabaugh]_. Returned tree rotation matrices and corresponding three Euler angules are only one of the possible solutions. @@ -1479,4 +1477,6 @@ The function reconstructs 3-dimensional points (in homogeneous coordinates) by u .. [HH08] Hirschmuller, H. Stereo Processing by Semiglobal Matching and Mutual Information, PAMI(30), No. 2, February 2008, pp. 328-341. +.. [Slabaugh] Slabaugh, G.G. Computing Euler angles from a rotation matrix. http://gregslabaugh.name/publications/euler.pdf + .. [Zhang2000] Z. Zhang. A Flexible New Technique for Camera Calibration. IEEE Transactions on Pattern Analysis and Machine Intelligence, 22(11):1330-1334, 2000. diff --git a/samples/android/face-detection/.cproject b/samples/android/face-detection/.cproject index 9e29990427bbfa5665131deae646b5d5e5111646..e126aa287f5a7ed6cdec299790ecd32c21e370d4 100644 --- a/samples/android/face-detection/.cproject +++ b/samples/android/face-detection/.cproject @@ -23,21 +23,14 @@ - -