mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
MIPS arch support added to OpenCV manager;
Internal OpenCV library in OpenCV Manager support added; Unit tests improved, platform specific tests added, MIPS related tests added; Code refactoring done.
This commit is contained in:
parent
ad58e96581
commit
5ffbcf1e16
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.opencv.engine"
|
||||
android:versionCode="16"
|
||||
android:versionName="1.6" >
|
||||
android:versionCode="17"
|
||||
android:versionName="1.7" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
|
@ -26,6 +26,7 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_CFLAGS += -DPLATFORM_ANDROID
|
||||
LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
|
||||
LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
|
||||
LOCAL_CFLAGS += -D__SUPPORT_MIPS
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
@ -67,6 +68,7 @@ LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_CFLAGS += -DPLATFORM_ANDROID
|
||||
LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
|
||||
LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
|
||||
LOCAL_CFLAGS += -D__SUPPORT_MIPS
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
|
||||
|
||||
LOCAL_MODULE := libOpenCVEngine_jni
|
||||
|
@ -1,4 +1,4 @@
|
||||
APP_ABI := armeabi x86
|
||||
APP_ABI := armeabi x86 mips
|
||||
APP_PLATFORM := android-8
|
||||
APP_STL := stlport_static
|
||||
APP_CPPFLAGS := -fno-rtti -fno-exceptions
|
||||
|
@ -13,7 +13,7 @@ int GetCpuID()
|
||||
map<string, string> cpu_info = GetCpuInfo();
|
||||
map<string, string>::const_iterator it;
|
||||
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__)
|
||||
LOGD("Using X86 HW detector");
|
||||
result |= ARCH_X86;
|
||||
it = cpu_info.find("flags");
|
||||
@ -33,6 +33,12 @@ int GetCpuID()
|
||||
result |= FEATURES_HAS_SSSE3;
|
||||
}
|
||||
}
|
||||
#elif defined(__mips)
|
||||
#ifdef __SUPPORT_MIPS
|
||||
result |= ARCH_MIPS;
|
||||
#else
|
||||
result = ARCH_UNKNOWN;
|
||||
#endif
|
||||
#else
|
||||
LOGD("Using ARM HW detector");
|
||||
it = cpu_info.find("Processor");
|
||||
@ -64,7 +70,6 @@ int GetCpuID()
|
||||
{
|
||||
result |= ARCH_ARMv5;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,27 +113,27 @@ string GetPlatformName()
|
||||
map<string, string> cpu_info = GetCpuInfo();
|
||||
string hardware_name = "";
|
||||
map<string, string>::const_iterator hw_iterator = cpu_info.find("Hardware");
|
||||
|
||||
|
||||
if (cpu_info.end() != hw_iterator)
|
||||
{
|
||||
hardware_name = hw_iterator->second;
|
||||
}
|
||||
|
||||
return hardware_name;
|
||||
|
||||
return hardware_name;
|
||||
}
|
||||
|
||||
int GetProcessorCount()
|
||||
{
|
||||
{
|
||||
FILE* cpuPossible = fopen("/sys/devices/system/cpu/possible", "r");
|
||||
if(!cpuPossible)
|
||||
return 1;
|
||||
|
||||
|
||||
char buf[2000]; //big enough for 1000 CPUs in worst possible configuration
|
||||
char* pbuf = fgets(buf, sizeof(buf), cpuPossible);
|
||||
fclose(cpuPossible);
|
||||
if(!pbuf)
|
||||
return 1;
|
||||
|
||||
|
||||
//parse string of form "0-1,3,5-7,10,13-15"
|
||||
int cpusAvailable = 0;
|
||||
|
||||
@ -157,7 +162,7 @@ int GetProcessorCount()
|
||||
int DetectKnownPlatforms()
|
||||
{
|
||||
int tegra_status = DetectTegra();
|
||||
|
||||
|
||||
if (3 == tegra_status)
|
||||
{
|
||||
return PLATFORM_TEGRA3;
|
||||
@ -166,7 +171,7 @@ int DetectKnownPlatforms()
|
||||
{
|
||||
return PLATFORM_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Uncomment when all Tegras will be supported
|
||||
/*if (tegra_status > 0)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define ARCH_ARMv6 134217728L
|
||||
#define ARCH_ARMv7 268435456L
|
||||
#define ARCH_ARMv8 536870912L
|
||||
#define ARCH_MIPS 1073741824L
|
||||
|
||||
#define FEATURES_HAS_VFPv3d16 1L
|
||||
#define FEATURES_HAS_VFPv3 2L
|
||||
|
@ -79,7 +79,7 @@ OpenCVEngine::OpenCVEngine(IPackageManager* PkgManager):
|
||||
|
||||
int32_t OpenCVEngine::GetVersion()
|
||||
{
|
||||
return OPEN_CV_ENGINE_VERSION;
|
||||
return OPEN_CV_ENGINE_VERSION;
|
||||
}
|
||||
|
||||
String16 OpenCVEngine::GetLibPathByVersion(android::String16 version)
|
||||
@ -124,17 +124,17 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version)
|
||||
std::string tmp = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
|
||||
if (!tmp.empty())
|
||||
{
|
||||
tmp += "/libopencvinfo.so";
|
||||
tmp += (std::string("/") + LIB_OPENCV_INFO_NAME);
|
||||
|
||||
LOGD("Trying to load info library \"%s\"", tmp.c_str());
|
||||
|
||||
void *handle;
|
||||
void* handle;
|
||||
char* (*info_func)();
|
||||
|
||||
handle = dlopen(tmp.c_str(), RTLD_LAZY);
|
||||
if (handle)
|
||||
{
|
||||
const char *error;
|
||||
const char* error;
|
||||
|
||||
dlerror();
|
||||
*(void **) (&info_func) = dlsym(handle, "GetLibraryList");
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#define CPU_INFO_ARCH_X86_STR "x86"
|
||||
|
||||
#define CPU_INFO_ARCH_MIPS_STR "MIPS"
|
||||
|
||||
|
||||
// public part
|
||||
std::map<std::string, std::string> GetCpuInfo();
|
||||
|
@ -34,7 +34,7 @@ int DetectTegra()
|
||||
result = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (0 == strncmp(tmpbuf, tegra3_config, len3))
|
||||
{
|
||||
result = 3;
|
||||
@ -48,6 +48,6 @@ int DetectTegra()
|
||||
{
|
||||
result = TEGRA_DETECTOR_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
@ -3,23 +3,23 @@
|
||||
#include <jni.h>
|
||||
#include <string>
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_manager_HardwareDetector_GetCpuID(JNIEnv* env, jclass)
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetCpuID(JNIEnv* env, jclass)
|
||||
{
|
||||
return GetCpuID();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_opencv_engine_manager_HardwareDetector_GetPlatformName(JNIEnv* env, jclass)
|
||||
JNIEXPORT jstring JNICALL Java_org_opencv_engine_HardwareDetector_GetPlatformName(JNIEnv* env, jclass)
|
||||
{
|
||||
std::string hardware_name = GetPlatformName();
|
||||
return env->NewStringUTF(hardware_name.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_manager_HardwareDetector_GetProcessorCount(JNIEnv* env, jclass)
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetProcessorCount(JNIEnv* env, jclass)
|
||||
{
|
||||
return GetProcessorCount();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_manager_HardwareDetector_DetectKnownPlatforms(JNIEnv* env, jclass)
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_DetectKnownPlatforms(JNIEnv* env, jclass)
|
||||
{
|
||||
return DetectKnownPlatforms();
|
||||
}
|
@ -10,35 +10,35 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Class: org_opencv_engine_manager_HardwareDetector
|
||||
* Class: org_opencv_engine_HardwareDetector
|
||||
* Method: GetCpuID
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_manager_HardwareDetector_GetCpuID
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetCpuID
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_opencv_engine_manager_HardwareDetector
|
||||
* Class: org_opencv_engine_HardwareDetector
|
||||
* Method: GetPlatformName
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_opencv_engine_manager_HardwareDetector_GetPlatformName
|
||||
JNIEXPORT jstring JNICALL Java_org_opencv_engine_HardwareDetector_GetPlatformName
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_opencv_engine_manager_HardwareDetector
|
||||
* Class: org_opencv_engine_HardwareDetector
|
||||
* Method: GetProcessorCount
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_manager_HardwareDetector_GetProcessorCount
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetProcessorCount
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_opencv_engine_manager_HardwareDetector
|
||||
* Class: org_opencv_engine_HardwareDetector
|
||||
* Method: DetectKnownPlatforms
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_manager_HardwareDetector_DetectKnownPlatforms
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_DetectKnownPlatforms
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -37,7 +37,7 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_engine_BinderConnector_Init(JNIEnv* e
|
||||
if (NULL == PackageManager)
|
||||
{
|
||||
JavaVM* jvm;
|
||||
env->GetJavaVM(&jvm);;
|
||||
env->GetJavaVM(&jvm);
|
||||
PackageManager = new JavaBasedPackageManager(jvm, env->NewGlobalRef(market));
|
||||
}
|
||||
if (PackageManager)
|
||||
|
@ -19,15 +19,15 @@ public:
|
||||
protected:
|
||||
static std::vector<std::pair<int, int> > ArmRating;
|
||||
static std::vector<std::pair<int, int> > IntelRating;
|
||||
|
||||
|
||||
static std::vector<std::pair<int, int> > InitArmRating();
|
||||
static std::vector<std::pair<int, int> > InitIntelRating();
|
||||
|
||||
|
||||
bool IsVersionCompatible(const std::string& target_version, const std::string& package_version);
|
||||
int GetHardwareRating(int platform, int cpu_id, const std::vector<std::pair<int, int> >& group);
|
||||
|
||||
|
||||
virtual bool InstallPackage(const PackageInfo& package) = 0;
|
||||
virtual std::vector<PackageInfo> GetInstalledPackages() = 0;
|
||||
virtual std::vector<PackageInfo> GetInstalledPackages() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ bool NativePackageManager::InstallPackage(const PackageInfo& package)
|
||||
vector<PackageInfo> NativePackageManager::GetInstalledPackages()
|
||||
{
|
||||
vector<PackageInfo> result;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
virtual ~NativePackageManager();
|
||||
protected:
|
||||
virtual bool InstallPackage(const PackageInfo& package);
|
||||
virtual std::vector<PackageInfo> GetInstalledPackages();
|
||||
virtual std::vector<PackageInfo> GetInstalledPackages();
|
||||
};
|
||||
|
||||
#endif
|
@ -6,23 +6,25 @@
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <utils/Log.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
map<int, string> PackageInfo::InitPlatformNameMap()
|
||||
{
|
||||
map<int, string> result;
|
||||
|
||||
|
||||
// TODO: Do not forget to add Platrfom constant to HardwareDetector.h
|
||||
result[PLATFORM_TEGRA] = PLATFORM_TEGRA_NAME;
|
||||
result[PLATFORM_TEGRA2] = PLATFORM_TEGRA2_NAME;
|
||||
result[PLATFORM_TEGRA3] = PLATFORM_TEGRA3_NAME;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const map<int, string> PackageInfo::PlatformNameMap = InitPlatformNameMap();
|
||||
const string PackageInfo::BasePackageName = "org.opencv.lib";
|
||||
const string DEFAULT_ENGINE_INSTALL_PATH = "/data/data/org.opencv.engine";
|
||||
|
||||
inline string JoinARMFeatures(int cpu_id)
|
||||
{
|
||||
@ -32,7 +34,7 @@ inline string JoinARMFeatures(int cpu_id)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id)))
|
||||
@ -48,14 +50,14 @@ inline string JoinARMFeatures(int cpu_id)
|
||||
if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id))
|
||||
result = string(FEATURES_HAS_VFPv3d16_NAME);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline int SplitARMFeatures(const vector<string>& features)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
|
||||
for (size_t i = 3; i < features.size(); i++)
|
||||
{
|
||||
if (FEATURES_HAS_VFPv3_NAME == features[i])
|
||||
@ -75,14 +77,14 @@ inline int SplitARMFeatures(const vector<string>& features)
|
||||
result |= FEATURES_HAS_NEON2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline string JoinIntelFeatures(int cpu_id)
|
||||
{
|
||||
string result;
|
||||
|
||||
|
||||
if (FEATURES_HAS_SSSE3 & cpu_id)
|
||||
{
|
||||
result = FEATURES_HAS_SSSE3_NAME;
|
||||
@ -95,14 +97,14 @@ inline string JoinIntelFeatures(int cpu_id)
|
||||
{
|
||||
result = FEATURES_HAS_SSE_NAME;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline int SplitIntelFeatures(const vector<string>& features)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
|
||||
for (size_t i = 3; i < features.size(); i++)
|
||||
{
|
||||
if (FEATURES_HAS_SSSE3_NAME == features[i])
|
||||
@ -117,15 +119,15 @@ inline int SplitIntelFeatures(const vector<string>& features)
|
||||
{
|
||||
result |= FEATURES_HAS_SSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline string SplitVersion(const vector<string>& features, const string& package_version)
|
||||
{
|
||||
string result;
|
||||
|
||||
|
||||
if ((features.size() > 1) && ('v' == features[1][0]))
|
||||
{
|
||||
result = features[1].substr(1);
|
||||
@ -135,7 +137,7 @@ inline string SplitVersion(const vector<string>& features, const string& package
|
||||
{
|
||||
// TODO: Report package name format error
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -143,17 +145,17 @@ inline string JoinPlatform(int platform)
|
||||
{
|
||||
string result;
|
||||
map<int, string>::const_iterator it = PackageInfo::PlatformNameMap.find(platform);
|
||||
|
||||
|
||||
assert(PackageInfo::PlatformNameMap.end() != it);
|
||||
result = it->second;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline int SplitPlatfrom(const vector<string>& features)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
|
||||
if (features.size() > 2)
|
||||
{
|
||||
string tmp = features[2];
|
||||
@ -174,7 +176,7 @@ inline int SplitPlatfrom(const vector<string>& features)
|
||||
{
|
||||
// TODO: Report package name format error
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -185,7 +187,7 @@ inline int SplitPlatfrom(const vector<string>& features)
|
||||
* If platform is known third part is platform name
|
||||
* 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, std::string install_path):
|
||||
Version(version),
|
||||
Platform(platform),
|
||||
@ -284,6 +286,12 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::s
|
||||
// FullName += string("_") + features;
|
||||
//}
|
||||
}
|
||||
#ifdef __SUPPORT_MIPS
|
||||
else if (ARCH_MIPS & CpuID)
|
||||
{
|
||||
FullName += string("_") + ARCH_MIPS_NAME;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
LOGD("PackageInfo::PackageInfo: package arch unknown");
|
||||
@ -300,24 +308,77 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::s
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!FullName.empty())
|
||||
{
|
||||
InstallPath = install_path + FullName + "/lib";
|
||||
}
|
||||
}
|
||||
|
||||
PackageInfo::PackageInfo(const string& fullname, const string& install_path, const string& package_version):
|
||||
PackageInfo::PackageInfo(const string& fullname, const string& install_path, string package_version):
|
||||
FullName(fullname),
|
||||
InstallPath(install_path)
|
||||
{
|
||||
LOGD("PackageInfo::PackageInfo(\"%s\", \"%s\", \"%s\")", fullname.c_str(), install_path.c_str(), package_version.c_str());
|
||||
|
||||
|
||||
assert(!fullname.empty());
|
||||
assert(!install_path.empty());
|
||||
|
||||
|
||||
if (OPENCV_ENGINE_PACKAGE == fullname)
|
||||
{
|
||||
// Science version 1.7 OpenCV Manager has it's own version of OpenCV inside
|
||||
// Load libopencv_info.so to understand OpenCV version, platform and other features
|
||||
std::string tmp;
|
||||
if (install_path.empty())
|
||||
{
|
||||
tmp = std::string(DEFAULT_ENGINE_INSTALL_PATH) + "/" + LIB_OPENCV_INFO_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = install_path + "/" + LIB_OPENCV_INFO_NAME;
|
||||
}
|
||||
|
||||
LOGD("Trying to load info library \"%s\"", tmp.c_str());
|
||||
|
||||
void* handle;
|
||||
const char* (*name_func)();
|
||||
const char* (*revision_func)();
|
||||
|
||||
handle = dlopen(tmp.c_str(), RTLD_LAZY);
|
||||
if (handle)
|
||||
{
|
||||
const char* error;
|
||||
|
||||
dlerror();
|
||||
*(void **) (&name_func) = dlsym(handle, "GetPackageName");
|
||||
*(void **) (&revision_func) = dlsym(handle, "GetRevision");
|
||||
error = dlerror();
|
||||
|
||||
if (!error && revision_func && name_func)
|
||||
{
|
||||
FullName = std::string((*name_func)());
|
||||
package_version = std::string((*revision_func)());
|
||||
dlclose(handle);
|
||||
LOGI("OpenCV package \"%s\" revision \"%s\" found", FullName.c_str(), package_version.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGE("Library loading error (%x, %x): \"%s\"", name_func, revision_func, error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("Info library not found in package");
|
||||
LOGI("OpenCV Manager package does not contain any verison of OpenCV library");
|
||||
Version.clear();
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> features = SplitStringVector(FullName, '_');
|
||||
|
||||
|
||||
if (!features.empty() && (BasePackageName == features[0]))
|
||||
{
|
||||
Version = SplitVersion(features, package_version);
|
||||
@ -363,6 +424,12 @@ PackageInfo::PackageInfo(const string& fullname, const string& install_path, con
|
||||
{
|
||||
CpuID = ARCH_X64 | SplitIntelFeatures(features);
|
||||
}
|
||||
#ifdef __SUPPORT_MIPS
|
||||
else if (ARCH_MIPS_NAME == features[2])
|
||||
{
|
||||
CpuID = ARCH_MIPS;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
LOGD("It is not OpenCV library package for this platform");
|
||||
|
@ -6,11 +6,13 @@
|
||||
|
||||
#define ARCH_X86_NAME "x86"
|
||||
#define ARCH_X64_NAME "x64"
|
||||
#define ARCH_MIPS_NAME "mips"
|
||||
#define ARCH_ARMv5_NAME "armv5"
|
||||
#define ARCH_ARMv6_NAME "armv6"
|
||||
#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"
|
||||
@ -29,7 +31,7 @@ class PackageInfo
|
||||
{
|
||||
public:
|
||||
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");
|
||||
PackageInfo(const std::string& fullname, const std::string& install_path, std::string package_version = "0.0");
|
||||
std::string GetFullName() const;
|
||||
std::string GetVersion() const;
|
||||
int GetPlatform() const;
|
||||
|
@ -19,14 +19,14 @@ int main(int argc, char *argv[])
|
||||
LOGI("OpenCVEngine native service starting");
|
||||
IPackageManager* PackageManager = new NativePackageManager();
|
||||
sp<IBinder> Engine = new OpenCVEngine(PackageManager);
|
||||
|
||||
|
||||
defaultServiceManager()->addService(IOpenCVEngine::descriptor, Engine);
|
||||
LOGI("OpenCVEngine native service started successfully");
|
||||
ProcessState::self()->startThreadPool();
|
||||
IPCThreadState::self()->joinThreadPool();
|
||||
LOGI("OpenCVEngine native service finished");
|
||||
|
||||
|
||||
delete PackageManager;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@ -108,6 +108,12 @@ TEST(Split, SplitMultiElementString)
|
||||
EXPECT_FALSE(b.find("eee") == b.end());
|
||||
}
|
||||
|
||||
TEST(CpuCount, CheckNonZero)
|
||||
{
|
||||
EXPECT_TRUE(GetProcessorCount() != 0);
|
||||
EXPECT_TRUE(a.find("") == a.end());
|
||||
}
|
||||
|
||||
TEST(GetCpuInfo, GetCpuInfo)
|
||||
{
|
||||
map<string, string> a = GetCpuInfo();
|
||||
@ -115,22 +121,38 @@ TEST(GetCpuInfo, GetCpuInfo)
|
||||
EXPECT_TRUE(a.find("") == a.end());
|
||||
}
|
||||
|
||||
TEST(TegraDetector, Detect)
|
||||
{
|
||||
EXPECT_TRUE(DetectTegra() != 0);
|
||||
}
|
||||
|
||||
TEST(CpuCount, CheckNonZero)
|
||||
{
|
||||
EXPECT_TRUE(GetProcessorCount() != 0);
|
||||
}
|
||||
|
||||
TEST(CpuID, CheckNotEmpy)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_NE(0, cpu_id);
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
TEST(CpuID, CheckX86)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & ARCH_X86);
|
||||
}
|
||||
|
||||
TEST(CpuID, CheckSSE2)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & FEATURES_HAS_SSE2);
|
||||
}
|
||||
#elseif __mips
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(CpuID, CheckMips)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & ARCH_MIPS);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
TEST(TegraDetector, Detect)
|
||||
{
|
||||
EXPECT_TRUE(DetectTegra() != 0);
|
||||
}
|
||||
|
||||
TEST(CpuID, CheckArmV7)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
@ -152,4 +174,5 @@ TEST(CpuID, CheckVFPv3)
|
||||
TEST(PlatfromDetector, CheckTegra)
|
||||
{
|
||||
EXPECT_NE(PLATFORM_UNKNOWN, DetectKnownPlatforms());
|
||||
}
|
||||
}
|
||||
#endif
|
@ -20,7 +20,7 @@ class ServiceStarter
|
||||
public:
|
||||
ServiceStarter()
|
||||
{
|
||||
PackageManager = new PackageManagerStub();
|
||||
PackageManager = new PackageManagerStub();
|
||||
Engine = new OpenCVEngine(PackageManager);
|
||||
|
||||
defaultServiceManager()->addService(IOpenCVEngine::descriptor, Engine);
|
||||
@ -36,23 +36,23 @@ public:
|
||||
sp<IBinder> Engine;
|
||||
};
|
||||
|
||||
static ServiceStarter Starter;
|
||||
static ServiceStarter Starter;
|
||||
|
||||
sp<IOpenCVEngine> InitConnect()
|
||||
{
|
||||
sp<IServiceManager> ServiceManager = defaultServiceManager();
|
||||
sp<IBinder> EngineService;
|
||||
sp<IOpenCVEngine> Engine;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
EngineService = ServiceManager->getService(IOpenCVEngine::descriptor);
|
||||
if (EngineService != 0) break;
|
||||
usleep(500000); // 0.5 s
|
||||
} while(true);
|
||||
|
||||
|
||||
Engine = interface_cast<IOpenCVEngine>(EngineService);
|
||||
|
||||
|
||||
return Engine;
|
||||
}
|
||||
|
||||
@ -64,6 +64,69 @@ TEST(OpenCVEngineTest, GetVersion)
|
||||
EXPECT_EQ(OPEN_CV_ENGINE_VERSION, Version);
|
||||
}
|
||||
|
||||
#if defined(__i386__)
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
#elif defined (__mips)
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
#else
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
@ -71,15 +134,15 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
|
||||
#else
|
||||
#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
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
@ -89,15 +152,15 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
|
||||
#else
|
||||
#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
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
@ -110,21 +173,13 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForUnExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.5"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> 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"));
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string());
|
||||
}
|
||||
|
||||
@ -138,22 +193,12 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage2)
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
|
||||
#else
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
|
||||
#else
|
||||
#else
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> 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)
|
||||
@ -163,13 +208,44 @@ TEST(OpenCVEngineTest, InstallAndGetVersion)
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
EXPECT_TRUE(Engine->InstallVersion(String16("2.4")));
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
|
||||
#else
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
#else
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
|
||||
#else
|
||||
#else
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __i386__
|
||||
TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> 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());
|
||||
}
|
||||
#else
|
||||
TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathForUnExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.5"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
@ -96,6 +96,15 @@ TEST(PackageInfo, FullNameX86SSE2)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(PackageInfo, FullNameMips)
|
||||
{
|
||||
PackageInfo info("243", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v24_mips", name.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(PackageInfo, Armv7NeonFromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon");
|
||||
@ -139,6 +148,15 @@ TEST(PackageInfo, Tegra3FromFullName)
|
||||
EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform());
|
||||
}
|
||||
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(PackageInfo, MipsFromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v24_mips", "/data/data/org.opencv.lib_v24_mips");
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(ARCH_MIPS, info.GetCpuID());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(PackageInfo, Comparator1)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
@ -167,4 +185,5 @@ TEST(PackageInfo, Comparator3)
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -39,6 +39,14 @@ TEST(PackageManager, InstallVersion)
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv5)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv7)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
@ -52,9 +60,9 @@ TEST(PackageManager, GetPackagePathForArmv7Neon)
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str());
|
||||
#else
|
||||
#else
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
|
||||
#endif
|
||||
}
|
||||
@ -72,9 +80,9 @@ TEST(PackageManager, GetPackagePathForX86SSE2)
|
||||
PackageManagerStub pm;
|
||||
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
|
||||
#ifdef __SUPPORT_INTEL_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str());
|
||||
#else
|
||||
#else
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str());
|
||||
#endif
|
||||
}
|
||||
@ -95,6 +103,16 @@ TEST(PackageManager, GetPackagePathForTegra3)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(PackageManager, GetPackagePathForMips)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS));
|
||||
string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", path.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Enable tests if seporate package will be exists
|
||||
// TEST(PackageManager, GetPackagePathForTegra2)
|
||||
// {
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* return 0;*/
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
@ -33,6 +33,7 @@ LOCAL_C_INCLUDES := \
|
||||
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_MIPS
|
||||
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
|
||||
|
||||
LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined
|
||||
|
@ -9,4 +9,6 @@
|
||||
#define OPEN_CV_ENGINE_VERSION 1
|
||||
#endif
|
||||
|
||||
#define LIB_OPENCV_INFO_NAME "libopencv_info.so"
|
||||
|
||||
#endif
|
@ -5,6 +5,8 @@
|
||||
#include <binder/Parcel.h>
|
||||
#include <utils/String16.h>
|
||||
|
||||
// OpenCV Manager package name
|
||||
#define OPENCV_ENGINE_PACKAGE "org.opencv.engine"
|
||||
// Class name of OpenCV engine binder object. Is needned for connection to service
|
||||
#define OPECV_ENGINE_CLASSNAME "org.opencv.engine.OpenCVEngineInterface"
|
||||
|
||||
|
@ -3,44 +3,51 @@ package org.opencv.engine;
|
||||
public class HardwareDetector
|
||||
{
|
||||
public static final int ARCH_UNKNOWN = -1;
|
||||
|
||||
|
||||
public static final int ARCH_X86 = 0x01000000;
|
||||
public static final int ARCH_X64 = 0x02000000;
|
||||
|
||||
|
||||
public static final int ARCH_ARMv5 = 0x04000000;
|
||||
public static final int ARCH_ARMv6 = 0x08000000;
|
||||
public static final int ARCH_ARMv7 = 0x10000000;
|
||||
public static final int ARCH_ARMv8 = 0x20000000;
|
||||
|
||||
|
||||
public static final int ARCH_MIPS = 0x40000000;
|
||||
// Platform specific features
|
||||
// ! Check CPU arch before !
|
||||
|
||||
|
||||
// ARM specific features
|
||||
public static final int FEATURES_HAS_VFPv3d16 = 0x01;
|
||||
public static final int FEATURES_HAS_VFPv3 = 0x02;
|
||||
public static final int FEATURES_HAS_NEON = 0x04;
|
||||
public static final int FEATURES_HAS_NEON2 = 0x08;
|
||||
|
||||
|
||||
// X86 specific features
|
||||
public static final int FEATURES_HAS_SSE = 0x01;
|
||||
public static final int FEATURES_HAS_SSE2 = 0x02;
|
||||
public static final int FEATURES_HAS_SSE3 = 0x04;
|
||||
|
||||
|
||||
// GPU Acceleration options
|
||||
public static final int FEATURES_HAS_GPU = 0x010000;
|
||||
|
||||
|
||||
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_UNKNOWN = -1;
|
||||
|
||||
|
||||
public static final int PLATFORM_UNKNOWN = 0;
|
||||
|
||||
// Return CPU arch and list of supported features
|
||||
public static native int GetCpuID();
|
||||
// Return hardware platform name
|
||||
public static native String GetPlatformName();
|
||||
// Return processor count
|
||||
public static native int GetProcessorCount();
|
||||
|
||||
|
||||
public static native int DetectKnownPlatforms();
|
||||
|
||||
static
|
||||
{
|
||||
System.loadLibrary("OpenCVEngine");
|
||||
System.loadLibrary("OpenCVEngine_jni");
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,17 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
public class MarketConnector
|
||||
{
|
||||
protected static final String OpenCVPackageNamePreffix = "org.opencv.lib";
|
||||
private static final String TAG = "OpenCVEngine/MarketConnector";
|
||||
protected Context mContext;
|
||||
|
||||
public boolean mIncludeManager = true;
|
||||
|
||||
public MarketConnector(Context context)
|
||||
{
|
||||
@ -26,7 +31,7 @@ public class MarketConnector
|
||||
{
|
||||
return (String) info.loadLabel(mContext.getPackageManager());
|
||||
}
|
||||
|
||||
|
||||
public boolean InstallAppFromMarket(String AppID)
|
||||
{
|
||||
boolean result = true;
|
||||
@ -50,7 +55,7 @@ public class MarketConnector
|
||||
public boolean RemoveAppFromMarket(String AppID, boolean wait)
|
||||
{
|
||||
boolean result = true;
|
||||
try
|
||||
try
|
||||
{
|
||||
Intent intent = new Intent(
|
||||
Intent.ACTION_DELETE,
|
||||
@ -75,7 +80,6 @@ public class MarketConnector
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public boolean CheckPackageInstalled(String AppID)
|
||||
{
|
||||
List<PackageInfo> Packages = mContext.getPackageManager().getInstalledPackages(PackageManager.GET_CONFIGURATIONS);
|
||||
@ -96,6 +100,15 @@ public class MarketConnector
|
||||
{
|
||||
List<PackageInfo> AllPackages = mContext.getPackageManager().getInstalledPackages(PackageManager.GET_CONFIGURATIONS);
|
||||
List<PackageInfo> OpenCVPackages = new ArrayList<PackageInfo>();
|
||||
if (mIncludeManager)
|
||||
{
|
||||
try {
|
||||
OpenCVPackages.add(mContext.getPackageManager().getPackageInfo("org.opencv.engine", PackageManager.GET_CONFIGURATIONS));
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "OpenCV Manager package info was not found!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Iterator<PackageInfo> it = AllPackages.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
|
@ -1,52 +0,0 @@
|
||||
package org.opencv.engine.manager;
|
||||
|
||||
public class HardwareDetector
|
||||
{
|
||||
public static final int ARCH_UNKNOWN = -1;
|
||||
|
||||
public static final int ARCH_X86 = 0x01000000;
|
||||
public static final int ARCH_X64 = 0x02000000;
|
||||
|
||||
public static final int ARCH_ARMv5 = 0x04000000;
|
||||
public static final int ARCH_ARMv6 = 0x08000000;
|
||||
public static final int ARCH_ARMv7 = 0x10000000;
|
||||
public static final int ARCH_ARMv8 = 0x20000000;
|
||||
|
||||
// Platform specific features
|
||||
// ! Check CPU arch before !
|
||||
|
||||
// ARM specific features
|
||||
public static final int FEATURES_HAS_VFPv3d16 = 0x01;
|
||||
public static final int FEATURES_HAS_VFPv3 = 0x02;
|
||||
public static final int FEATURES_HAS_NEON = 0x04;
|
||||
public static final int FEATURES_HAS_NEON2 = 0x08;
|
||||
|
||||
// X86 specific features
|
||||
public static final int FEATURES_HAS_SSE = 0x01;
|
||||
public static final int FEATURES_HAS_SSE2 = 0x02;
|
||||
public static final int FEATURES_HAS_SSE3 = 0x04;
|
||||
|
||||
// GPU Acceleration options
|
||||
public static final int FEATURES_HAS_GPU = 0x010000;
|
||||
|
||||
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_UNKNOWN = 0;
|
||||
|
||||
// Return CPU arch and list of supported features
|
||||
public static native int GetCpuID();
|
||||
// Return hardware platform name
|
||||
public static native String GetPlatformName();
|
||||
// Return processor count
|
||||
public static native int GetProcessorCount();
|
||||
|
||||
public static native int DetectKnownPlatforms();
|
||||
|
||||
static
|
||||
{
|
||||
System.loadLibrary("OpenCVEngine");
|
||||
System.loadLibrary("OpenCVEngine_jni");
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.opencv.engine.HardwareDetector;
|
||||
import org.opencv.engine.MarketConnector;
|
||||
import org.opencv.engine.OpenCVEngineInterface;
|
||||
import org.opencv.engine.R;
|
||||
@ -45,13 +46,12 @@ public class ManagerActivity extends Activity
|
||||
OsVersionView.setText(Build.VERSION.CODENAME + " (" + Build.VERSION.RELEASE + "), API " + Build.VERSION.SDK_INT);
|
||||
|
||||
try {
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);
|
||||
ManagerVersion = packageInfo.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
ManagerVersion = "N/A";
|
||||
e.printStackTrace();
|
||||
}
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);
|
||||
ManagerVersion = packageInfo.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
ManagerVersion = "N/A";
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mInstalledPackageView = (ListView)findViewById(R.id.InstalledPackageList);
|
||||
|
||||
@ -112,6 +112,10 @@ public class ManagerActivity extends Activity
|
||||
{
|
||||
HardwarePlatformView.setText("ARM v8 " + JoinArmFeatures(CpuId));
|
||||
}
|
||||
else if ((CpuId & HardwareDetector.ARCH_MIPS) == HardwareDetector.ARCH_MIPS)
|
||||
{
|
||||
HardwarePlatformView.setText("MIPS");
|
||||
}
|
||||
else
|
||||
{
|
||||
HardwarePlatformView.setText("not detected");
|
||||
@ -120,41 +124,41 @@ public class ManagerActivity extends Activity
|
||||
|
||||
mUpdateEngineButton = (Button)findViewById(R.id.CheckEngineUpdate);
|
||||
mUpdateEngineButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
if (!mMarket.InstallAppFromMarket("org.opencv.engine"))
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public void onClick(View v) {
|
||||
if (!mMarket.InstallAppFromMarket("org.opencv.engine"))
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mActionDialog = new AlertDialog.Builder(this).create();
|
||||
|
||||
mActionDialog.setTitle("Choose action");
|
||||
mActionDialog.setButton("Update", new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int index = (Integer)mInstalledPackageView.getTag();
|
||||
if (!mMarket.InstallAppFromMarket(mInstalledPackageInfo[index].packageName))
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int index = (Integer)mInstalledPackageView.getTag();
|
||||
if (!mMarket.InstallAppFromMarket(mInstalledPackageInfo[index].packageName))
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mActionDialog.setButton3("Remove", new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int index = (Integer)mInstalledPackageView.getTag();
|
||||
if (!mMarket.RemoveAppFromMarket(mInstalledPackageInfo[index].packageName, true))
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int index = (Integer)mInstalledPackageView.getTag();
|
||||
if (!mMarket.RemoveAppFromMarket(mInstalledPackageInfo[index].packageName, true))
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mActionDialog.setButton2("Return", new DialogInterface.OnClickListener() {
|
||||
@ -165,27 +169,20 @@ public class ManagerActivity extends Activity
|
||||
});
|
||||
|
||||
mInstalledPackageView.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) {
|
||||
|
||||
mInstalledPackageView.setTag(Integer.valueOf((int)id));
|
||||
mActionDialog.show();
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) {
|
||||
mInstalledPackageView.setTag(Integer.valueOf((int)id));
|
||||
mActionDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
if (!bindService(new Intent("org.opencv.engine.BIND"), mServiceConnection, Context.BIND_AUTO_CREATE))
|
||||
{
|
||||
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
|
||||
EngineVersionView.setText("not avaliable");
|
||||
}
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_INSTALL);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
|
||||
|
||||
|
||||
registerReceiver(mPackageChangeReciever, filter);
|
||||
}
|
||||
|
||||
@ -272,6 +269,7 @@ public class ManagerActivity extends Activity
|
||||
protected void FillPackageList()
|
||||
{
|
||||
synchronized (mListViewItems) {
|
||||
mMarket.mIncludeManager = false;
|
||||
mInstalledPackageInfo = mMarket.GetInstalledOpenCVPackages();
|
||||
mListViewItems.clear();
|
||||
|
||||
@ -328,11 +326,11 @@ public class ManagerActivity extends Activity
|
||||
}
|
||||
|
||||
temp.put("Name", PublicName);
|
||||
temp.put("Version", NormalizeVersion(OpenCVersion, mInstalledPackageInfo[i].versionName));
|
||||
temp.put("Version", NormalizeVersion(OpenCVersion, mInstalledPackageInfo[i].versionName));
|
||||
temp.put("Hardware", HardwareName);
|
||||
mListViewItems.add(temp);
|
||||
}
|
||||
|
||||
|
||||
mInstalledPacksAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package org.opencv.engine.manager;
|
||||
|
||||
public class OpenCVPackageInfo
|
||||
{
|
||||
public OpenCVPackageInfo(String PackageName, String PackageInstallPath, String RevName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected long mNativeObject = 0;
|
||||
|
||||
protected static native long nativeConstructor(String PackageName, String PackageInstallPath, String RevName);
|
||||
protected static native void nativeDestructor(long nativeAddress);
|
||||
protected static native String nativeGetVersion(long thiz);
|
||||
protected static native String nativeGetPlatfrom(long thiz);
|
||||
}
|
Loading…
Reference in New Issue
Block a user