Bug #2595 in OpenCV Manager fixed.
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>
Wed, 5 Dec 2012 09:04:45 +0000 (13:04 +0400)
committerAlexander Smorkalov <alexander.smorkalov@itseez.com>
Wed, 5 Dec 2012 14:03:42 +0000 (18:03 +0400)
OpenCV Manager 2.x marks old 2.4.2 binary package for Tegra as "in use".
The latest version of OpenCV library compatible with platform is used now.

android/service/engine/jni/NativeService/CommonPackageManager.cpp
android/service/engine/jni/NativeService/PackageInfo.cpp

index ecaa5d6..e99d9b2 100644 (file)
@@ -78,49 +78,45 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
 
     if (!packages.empty())
     {
-        vector<PackageInfo>::iterator found = find(packages.begin(), packages.end(), target_package);
-        if (packages.end() != found)
+        int OptRating = -1;
+        std::string OptVersion = "";
+        std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
+
+        if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
+            group = CommonPackageManager::IntelRating;
+
+        int HardwareRating = GetHardwareRating(platform, cpu_id, group);
+        LOGD("Current hardware platform rating %d for (%d,%d)", HardwareRating, platform, cpu_id);
+
+        if (-1 == HardwareRating)
         {
-            result = found->GetInstalationPath();
+            LOGE("Cannot calculate rating for current hardware platform!");
         }
         else
         {
-            int OptRating = -1;
-            std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
-
-            if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
-                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 platform!");
-            }
-            else
+            vector<PackageInfo>::iterator found = packages.end();
+            for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
             {
-                for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
+                int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
+                LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), PackageRating, it->GetPlatform(), it->GetCpuID());
+                if ((PackageRating >= 0) && (PackageRating <= HardwareRating))
                 {
-                    int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
-                    if (PackageRating >= 0)
+                    if (((it->GetVersion() >= OptVersion) && (PackageRating >= OptRating)) || (it->GetVersion() > OptVersion))
                     {
-                        if ((PackageRating <= HardwareRating) && (PackageRating > OptRating))
-                        {
-                            OptRating = PackageRating;
-                            found = it;
-                        }
+                        OptRating = PackageRating;
+                        OptVersion = it->GetVersion();
+                        found = it;
                     }
                 }
+            }
 
-                if ((-1 != OptRating) && (packages.end() != found))
-                {
-                    result = found->GetInstalationPath();
-                }
-                else
-                {
-                    LOGI("Found package is incompatible with current hardware platform");
-                }
+            if ((-1 != OptRating) && (packages.end() != found))
+            {
+                result = found->GetInstalationPath();
+            }
+            else
+            {
+                LOGI("Found package is incompatible with current hardware platform");
             }
         }
     }
@@ -171,14 +167,14 @@ std::vector<std::pair<int, int> > CommonPackageManager::InitArmRating()
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16));
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7));
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
+    result.push_back(std::pair<int, int>(PLATFORM_TEGRA2,  ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3));
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_VFPv3));
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
     result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_NEON));
     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_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
-    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_TEGRA3,  ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
 
     return result;
 }
index 237e979..1f4878f 100644 (file)
@@ -197,6 +197,7 @@ InstallPath("")
     #ifndef __SUPPORT_TEGRA3
     Platform = PLATFORM_UNKNOWN;
     #endif
+
     FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1);
     if (PLATFORM_UNKNOWN != Platform)
     {
@@ -392,7 +393,17 @@ InstallPath(install_path)
         Platform = SplitPlatfrom(features);
         if (PLATFORM_UNKNOWN != Platform)
         {
-            CpuID = 0;
+            switch (Platform)
+            {
+                case PLATFORM_TEGRA2:
+                {
+                    CpuID = ARCH_ARMv7 | FEATURES_HAS_VFPv3d16;
+                } break;
+                case PLATFORM_TEGRA3:
+                {
+                    CpuID = ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON;
+                } break;
+            }
         }
         else
         {