Merge pull request #97 from asmorkalov/2.4

This commit is contained in:
Andrey Kamaev 2012-10-24 15:02:05 +04:00
commit 6c5922542e
30 changed files with 681 additions and 678 deletions

View File

@ -8,7 +8,7 @@ LOCAL_LOG_PATH = os.path.join(os.getcwd(), "logs")
if (__name__ == "__main__"):
if (not os.path.exists(LOCAL_LOG_PATH)):
os.makedirs(LOCAL_LOG_PATH)
os.makedirs(LOCAL_LOG_PATH)
print("Building native part of OpenCV Manager...")
HomeDir = os.getcwd()
@ -19,25 +19,25 @@ if (__name__ == "__main__"):
#print(BuildCommand)
res = os.system(BuildCommand)
if (0 == res):
print("Build\t[OK]")
print("Build\t[OK]")
else:
print("Build\t[FAILED]")
print("Build\t[FAILED]")
sys.exit(-1)
os.chdir(HomeDir)
ConfFile = open("device.conf", "rt")
for s in ConfFile.readlines():
keys = s.split(";")
if (len(keys) < 2):
print("Error: invalid config line: \"%s\"" % s)
continue
Arch = keys[0]
Name = keys[1]
print("testing \"%s\" arch" % Arch)
print("Pushing to device \"%s\"" % Name)
PushCommand = "%s \"%s\" \"%s\" 2>&1" % (os.path.join(HomeDir, "push_native.py"), Arch, Name)
os.system(PushCommand)
print("Testing on device \"%s\"" % Name)
TestCommand = "%s \"%s\" \"%s\" 2>&1" % (os.path.join(HomeDir, "test_native.py"), Arch, Name)
os.system(TestCommand)
keys = s.split(";")
if (len(keys) < 2):
print("Error: invalid config line: \"%s\"" % s)
continue
Arch = keys[0]
Name = keys[1]
print("testing \"%s\" arch" % Arch)
print("Pushing to device \"%s\"" % Name)
PushCommand = "%s \"%s\" \"%s\" 2>&1" % (os.path.join(HomeDir, "push_native.py"), Arch, Name)
os.system(PushCommand)
print("Testing on device \"%s\"" % Name)
TestCommand = "%s \"%s\" \"%s\" 2>&1" % (os.path.join(HomeDir, "test_native.py"), Arch, Name)
os.system(TestCommand)

View File

@ -46,7 +46,7 @@ There is a very base code snippet implementing the async initialization with Bas
super.onResume();
Log.i(TAG, "Trying to load OpenCV library");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mOpenCVCallBack))
{
Log.e(TAG, "Cannot connect to OpenCV Manager");
}
@ -55,6 +55,6 @@ There is a very base code snippet implementing the async initialization with Bas
Using in Service
----------------
Default BaseLoaderCallback implementation treat application context as Activity and calls Activity.finish() method to exit in case of initialization failure.
To override this behavior you need to override finish() method of BaseLoaderCallback class and implement your own finalization method.
Default BaseLoaderCallback implementation treat application context as Activity and calls Activity.finish() method to exit in case of initialization failure.
To override this behavior you need to override finish() method of BaseLoaderCallback class and implement your own finalization method.

View File

@ -40,6 +40,10 @@ OpenCV version constants
OpenCV Library version 2.4.2
.. data:: OPENCV_VERSION_2_4_3
OpenCV Library version 2.4.3
Other constatnts
----------------

View File

@ -13,7 +13,7 @@ void onManagerConnected()
.. method:: void onManagerConnected(int status)
Callback method that is called after OpenCV Library initialization.
:param status: status of initialization (see Initialization Status Constants).
void onPackageInstall()

View File

@ -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="17"
android:versionName="1.7" >
android:versionCode="18"
android:versionName="1.8" >
<uses-sdk android:minSdkVersion="8" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
@ -12,9 +12,9 @@
android:label="@string/app_name" >
<service android:exported="true" android:name="OpenCVEngineService" android:process=":OpenCVEngineProcess">
<intent-filter>
<action android:name="org.opencv.engine.BIND"></action>
</intent-filter>
<intent-filter>
<action android:name="org.opencv.engine.BIND"></action>
</intent-filter>
</service>
<activity
@ -22,7 +22,7 @@
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

View File

@ -21,53 +21,51 @@ status_t BnOpenCVEngine::onTransact(uint32_t code, const Parcel& data, android::
switch(code)
{
case OCVE_GET_ENGINE_VERSION:
{
LOGD("OpenCVEngine OCVE_GET_ENGINE_VERSION request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
LOGD("OpenCVEngine::GetVersion()");
reply->writeInt32(0);
return reply->writeInt32(GetVersion());
} break;
case OCVE_GET_LIB_PATH_BY_VERSION:
{
LOGD("OpenCVEngine OCVE_GET_LIB_PATH_BY_VERSION request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
const String16 version = data.readString16();
LOGD("OpenCVEngine::GetLibPathByVersion(%s)", String8(version).string());
String16 path = GetLibPathByVersion(version);
reply->writeInt32(0);
return reply->writeString16(path);
} break;
case OCVE_GET_LIB_LIST:
{
LOGD("OpenCVEngine OCVE_GET_LIB_LIST request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
const String16 version = data.readString16();
LOGD("OpenCVEngine::GetLibraryList(%s)", String8(version).string());
String16 path = GetLibraryList(version);
reply->writeInt32(0);
return reply->writeString16(path);
} break;
case OCVE_INSTALL_VERSION:
{
LOGD("OpenCVEngine OCVE_INSTALL_VERSION request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
const String16 version = data.readString16();
LOGD("OpenCVEngine::InstallVersion(%s)", String8(version).string());
bool result = InstallVersion(version);
reply->writeInt32(0);
int res = reply->writeInt32(static_cast<int32_t>(result));
LOGD("InstallVersion call to Binder finished with res %d", res);
return res;
} break;
default:
{
LOGD("OpenCVEngine unknown request");
return BBinder::onTransact(code, data, reply, flags);
}
case OCVE_GET_ENGINE_VERSION:
{
LOGD("OpenCVEngine OCVE_GET_ENGINE_VERSION request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
LOGD("OpenCVEngine::GetVersion()");
reply->writeInt32(0);
return reply->writeInt32(GetVersion());
} break;
case OCVE_GET_LIB_PATH_BY_VERSION:
{
LOGD("OpenCVEngine OCVE_GET_LIB_PATH_BY_VERSION request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
const String16 version = data.readString16();
LOGD("OpenCVEngine::GetLibPathByVersion(%s)", String8(version).string());
String16 path = GetLibPathByVersion(version);
reply->writeInt32(0);
return reply->writeString16(path);
} break;
case OCVE_GET_LIB_LIST:
{
LOGD("OpenCVEngine OCVE_GET_LIB_LIST request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
const String16 version = data.readString16();
LOGD("OpenCVEngine::GetLibraryList(%s)", String8(version).string());
String16 path = GetLibraryList(version);
reply->writeInt32(0);
return reply->writeString16(path);
} break;
case OCVE_INSTALL_VERSION:
{
LOGD("OpenCVEngine OCVE_INSTALL_VERSION request");
CHECK_INTERFACE(IOpenCVEngine, data, reply);
const String16 version = data.readString16();
LOGD("OpenCVEngine::InstallVersion(%s)", String8(version).string());
bool result = InstallVersion(version);
reply->writeInt32(0);
int res = reply->writeInt32(static_cast<int32_t>(result));
LOGD("InstallVersion call to Binder finished with res %d", res);
return res;
} break;
default:
{
LOGD("OpenCVEngine unknown request");
return BBinder::onTransact(code, data, reply, flags);
}
}
return android::NO_ERROR;

View File

@ -13,97 +13,97 @@ int GetCpuID()
map<string, string> cpu_info = GetCpuInfo();
map<string, string>::const_iterator it;
#if defined(__i386__)
#if defined(__i386__)
LOGD("Using X86 HW detector");
result |= ARCH_X86;
it = cpu_info.find("flags");
if (cpu_info.end() != it)
{
set<string> features = SplitString(it->second, ' ');
if (features.end() != features.find(CPU_INFO_SSE_STR))
{
result |= FEATURES_HAS_SSE;
}
if (features.end() != features.find(CPU_INFO_SSE2_STR))
{
result |= FEATURES_HAS_SSE2;
}
if (features.end() != features.find(CPU_INFO_SSSE3_STR))
{
result |= FEATURES_HAS_SSSE3;
}
set<string> features = SplitString(it->second, ' ');
if (features.end() != features.find(CPU_INFO_SSE_STR))
{
result |= FEATURES_HAS_SSE;
}
if (features.end() != features.find(CPU_INFO_SSE2_STR))
{
result |= FEATURES_HAS_SSE2;
}
if (features.end() != features.find(CPU_INFO_SSSE3_STR))
{
result |= FEATURES_HAS_SSSE3;
}
}
#elif defined(__mips)
#ifdef __SUPPORT_MIPS
#ifdef __SUPPORT_MIPS
result |= ARCH_MIPS;
#else
#else
result = ARCH_UNKNOWN;
#endif
#endif
#else
LOGD("Using ARM HW detector");
it = cpu_info.find("Processor");
if (cpu_info.end() != it)
{
size_t proc_name_pos = it->second.find(CPU_INFO_ARCH_X86_STR);
if (string::npos != proc_name_pos)
{
}
else
{
proc_name_pos = it->second.find(CPU_INFO_ARCH_ARMV7_STR);
size_t proc_name_pos = it->second.find(CPU_INFO_ARCH_X86_STR);
if (string::npos != proc_name_pos)
{
result |= ARCH_ARMv7;
}
else
{
proc_name_pos = it->second.find(CPU_INFO_ARCH_ARMV6_STR);
if (string::npos != proc_name_pos)
{
result |= ARCH_ARMv6;
}
else
{
proc_name_pos = it->second.find(CPU_INFO_ARCH_ARMV5_STR);
proc_name_pos = it->second.find(CPU_INFO_ARCH_ARMV7_STR);
if (string::npos != proc_name_pos)
{
result |= ARCH_ARMv5;
result |= ARCH_ARMv7;
}
else
{
proc_name_pos = it->second.find(CPU_INFO_ARCH_ARMV6_STR);
if (string::npos != proc_name_pos)
{
result |= ARCH_ARMv6;
}
else
{
proc_name_pos = it->second.find(CPU_INFO_ARCH_ARMV5_STR);
if (string::npos != proc_name_pos)
{
result |= ARCH_ARMv5;
}
}
}
}
}
}
}
else
{
return ARCH_UNKNOWN;
return ARCH_UNKNOWN;
}
it = cpu_info.find("Features");
if (cpu_info.end() != it)
{
set<string> features = SplitString(it->second, ' ');
if (features.end() != features.find(CPU_INFO_NEON_STR))
{
result |= FEATURES_HAS_NEON;
}
if (features.end() != features.find(CPU_INFO_NEON2_STR))
{
result |= FEATURES_HAS_NEON2;
}
if (features.end() != features.find(CPU_INFO_VFPV3_STR))
{
if (features.end () != features.find(CPU_INFO_VFPV3D16_STR))
set<string> features = SplitString(it->second, ' ');
if (features.end() != features.find(CPU_INFO_NEON_STR))
{
result |= FEATURES_HAS_VFPv3d16;
result |= FEATURES_HAS_NEON;
}
else
if (features.end() != features.find(CPU_INFO_NEON2_STR))
{
result |= FEATURES_HAS_VFPv3;
result |= FEATURES_HAS_NEON2;
}
if (features.end() != features.find(CPU_INFO_VFPV3_STR))
{
if (features.end () != features.find(CPU_INFO_VFPV3D16_STR))
{
result |= FEATURES_HAS_VFPv3d16;
}
else
{
result |= FEATURES_HAS_VFPv3;
}
}
}
}
#endif
#endif
return result;
}
@ -116,7 +116,7 @@ string GetPlatformName()
if (cpu_info.end() != hw_iterator)
{
hardware_name = hw_iterator->second;
hardware_name = hw_iterator->second;
}
return hardware_name;
@ -126,37 +126,37 @@ int GetProcessorCount()
{
FILE* cpuPossible = fopen("/sys/devices/system/cpu/possible", "r");
if(!cpuPossible)
return 1;
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;
return 1;
//parse string of form "0-1,3,5-7,10,13-15"
int cpusAvailable = 0;
int cpusAvailable = 0;
while(*pbuf)
{
const char* pos = pbuf;
bool range = false;
while(*pbuf && *pbuf != ',')
while(*pbuf)
{
if(*pbuf == '-') range = true;
++pbuf;
const char* pos = pbuf;
bool range = false;
while(*pbuf && *pbuf != ',')
{
if(*pbuf == '-') range = true;
++pbuf;
}
if(*pbuf) *pbuf++ = 0;
if(!range)
++cpusAvailable;
else
{
int rstart = 0, rend = 0;
sscanf(pos, "%d-%d", &rstart, &rend);
cpusAvailable += rend - rstart + 1;
}
}
if(*pbuf) *pbuf++ = 0;
if(!range)
++cpusAvailable;
else
{
int rstart = 0, rend = 0;
sscanf(pos, "%d-%d", &rstart, &rend);
cpusAvailable += rend - rstart + 1;
}
}
return cpusAvailable ? cpusAvailable : 1;
return cpusAvailable ? cpusAvailable : 1;
}
int DetectKnownPlatforms()
@ -165,20 +165,20 @@ int DetectKnownPlatforms()
if (3 == tegra_status)
{
return PLATFORM_TEGRA3;
return PLATFORM_TEGRA3;
}
else
{
return PLATFORM_UNKNOWN;
return PLATFORM_UNKNOWN;
}
// NOTE: Uncomment when all Tegras will be supported
/*if (tegra_status > 0)
{
return PLATFORM_TEGRA + tegra_status - 1;
}
else
{
return PLATFORM_UNKNOWN;
}*/
* {
* return PLATFORM_TEGRA + tegra_status - 1;
}
else
{
return PLATFORM_UNKNOWN;
}*/
}

View File

@ -23,6 +23,7 @@ std::set<std::string> OpenCVEngine::InitKnownOpenCVersions()
result.insert("240");
result.insert("241");
result.insert("242");
result.insert("243");
return result;
}
@ -41,31 +42,31 @@ std::string OpenCVEngine::NormalizeVersionString(std::string version)
if (version.empty())
{
return result;
return result;
}
if (('a' == version[version.size()-1]) || ('b' == version[version.size()-1]))
{
suffix = version[version.size()-1];
version.erase(version.size()-1);
suffix = version[version.size()-1];
version.erase(version.size()-1);
}
std::vector<std::string> parts = SplitStringVector(version, '.');
if (parts.size() >= 2)
{
if (parts.size() >= 3)
{
result = parts[0] + parts[1] + parts[2] + suffix;
if (!ValidateVersionString(result))
result = "";
}
else
{
result = parts[0] + parts[1] + "0" + suffix;
if (!ValidateVersionString(result))
result = "";
}
if (parts.size() >= 3)
{
result = parts[0] + parts[1] + parts[2] + suffix;
if (!ValidateVersionString(result))
result = "";
}
else
{
result = parts[0] + parts[1] + "0" + suffix;
if (!ValidateVersionString(result))
result = "";
}
}
return result;
@ -94,19 +95,19 @@ String16 OpenCVEngine::GetLibPathByVersion(android::String16 version)
if (!norm_version.empty())
{
path = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
if (path.empty())
{
LOGI("Package OpenCV of version %s is not installed. Try to install it :)", norm_version.c_str());
path = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
if (path.empty())
{
LOGI("Package OpenCV of version %s is not installed. Try to install it :)", norm_version.c_str());
}
else
{
FixPermissions(path);
}
}
else
{
FixPermissions(path);
}
}
else
{
LOGE("OpenCV version \"%s\" (%s) is not supported", String8(version).string(), norm_version.c_str());
LOGE("OpenCV version \"%s\" (%s) is not supported", String8(version).string(), norm_version.c_str());
}
return String16(path.c_str());
@ -121,46 +122,46 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version)
if (!norm_version.empty())
{
std::string tmp = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
if (!tmp.empty())
{
tmp += (std::string("/") + LIB_OPENCV_INFO_NAME);
LOGD("Trying to load info library \"%s\"", tmp.c_str());
void* handle;
char* (*info_func)();
handle = dlopen(tmp.c_str(), RTLD_LAZY);
if (handle)
std::string tmp = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
if (!tmp.empty())
{
const char* error;
tmp += (std::string("/") + LIB_OPENCV_INFO_NAME);
dlerror();
*(void **) (&info_func) = dlsym(handle, "GetLibraryList");
if ((error = dlerror()) == NULL)
{
result = String16((*info_func)());
dlclose(handle);
LOGD("Trying to load info library \"%s\"", tmp.c_str());
void* handle;
char* (*info_func)();
handle = dlopen(tmp.c_str(), RTLD_LAZY);
if (handle)
{
const char* error;
dlerror();
*(void **) (&info_func) = dlsym(handle, "GetLibraryList");
if ((error = dlerror()) == NULL)
{
result = String16((*info_func)());
dlclose(handle);
}
else
{
LOGE("Library loading error: \"%s\"", error);
}
}
else
{
LOGI("Info library not found in package");
}
}
else
{
LOGE("Library loading error: \"%s\"", error);
}
}
else
{
LOGI("Info library not found in package");
LOGI("Package OpenCV of version %s is not installed. Try to install it :)", norm_version.c_str());
}
}
else
{
LOGI("Package OpenCV of version %s is not installed. Try to install it :)", norm_version.c_str());
}
}
else
{
LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
}
return result;
@ -172,26 +173,18 @@ bool OpenCVEngine::InstallVersion(android::String16 version)
std::string norm_version;
bool result = false;
LOGD("OpenCVEngine::InstallVersion() begin");
norm_version = NormalizeVersionString(std_version);
if (!norm_version.empty())
{
LOGD("OpenCVEngine::InstallVersion() begin");
if (!PackageManager->CheckVersionInstalled(norm_version, Platform, CpuID))
{
LOGD("PackageManager->InstallVersion call");
result = PackageManager->InstallVersion(norm_version, Platform, CpuID);
}
else
{
LOGI("Package OpenCV of version %s is already installed. Skiped.", norm_version.c_str());
result = true;
}
}
else
{
LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
}
LOGD("OpenCVEngine::InstallVersion() end");
@ -207,16 +200,16 @@ bool OpenCVEngine::FixPermissions(const std::string& path)
DIR* dir = opendir(path.c_str());
if (!dir)
{
LOGD("Fixing permissions error");
return false;
LOGD("Fixing permissions error");
return false;
}
dirent* files = readdir(dir);
while (files)
{
LOGD("Fix permissions for \"%s\"", files->d_name);
chmod((path + std::string("/") + std::string(files->d_name)).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
files = readdir(dir);
LOGD("Fix permissions for \"%s\"", files->d_name);
chmod((path + std::string("/") + std::string(files->d_name)).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
files = readdir(dir);
}
closedir(dir);

View File

@ -12,18 +12,18 @@ map<string, string> GetCpuInfo()
f.open("/proc/cpuinfo");
if (f.is_open())
{
while (!f.eof())
{
string tmp;
string key;
string value;
getline(f, tmp);
if (ParseString(tmp, key, value))
while (!f.eof())
{
result[key] = value;
string tmp;
string key;
string value;
getline(f, tmp);
if (ParseString(tmp, key, value))
{
result[key] = value;
}
}
}
}
f.close();

View File

@ -8,7 +8,7 @@ bool StripString(string& src)
if (src.empty())
{
return false;
return false;
}
while ((pos < src.length()) && (' ' == src[pos])) pos++;
@ -32,7 +32,7 @@ bool StripString(string& src)
bool ParseString(const string& src, string& key, string& value)
{
if (src.empty())
return false;
return false;
// find seporator ":"
size_t seporator_pos = src.find(":");
@ -52,20 +52,19 @@ bool ParseString(const string& src, string& key, string& value)
set<string> SplitString(const string& src, const char seporator)
{
set<string> result;
if (!src.empty())
{
size_t seporator_pos;
size_t prev_pos = 0;
do
{
seporator_pos = src.find(seporator, prev_pos);
result.insert(src.substr(prev_pos, seporator_pos - prev_pos));
prev_pos = seporator_pos + 1;
}
while (string::npos != seporator_pos);
size_t seporator_pos;
size_t prev_pos = 0;
do
{
seporator_pos = src.find(seporator, prev_pos);
result.insert(src.substr(prev_pos, seporator_pos - prev_pos));
prev_pos = seporator_pos + 1;
}
while (string::npos != seporator_pos);
}
return result;
@ -77,16 +76,16 @@ vector<string> SplitStringVector(const string& src, const char seporator)
if (!src.empty())
{
size_t seporator_pos;
size_t prev_pos = 0;
do
{
seporator_pos = src.find(seporator, prev_pos);
string tmp = src.substr(prev_pos, seporator_pos - prev_pos);
result.push_back(tmp);
prev_pos = seporator_pos + 1;
}
while (string::npos != seporator_pos);
size_t seporator_pos;
size_t prev_pos = 0;
do
{
seporator_pos = src.find(seporator, prev_pos);
string tmp = src.substr(prev_pos, seporator_pos - prev_pos);
result.push_back(tmp);
prev_pos = seporator_pos + 1;
}
while (string::npos != seporator_pos);
}
return result;

View File

@ -15,38 +15,38 @@ int DetectTegra()
gzFile kernelConfig = gzopen(KERNEL_CONFIG, "r");
if (kernelConfig != 0)
{
char tmpbuf[KERNEL_CONFIG_MAX_LINE_WIDTH];
const char *tegra_config = KERNEL_CONFIG_TEGRA_MAGIC;
const char *tegra2_config = KERNEL_CONFIG_TEGRA2_MAGIC;
const char *tegra3_config = KERNEL_CONFIG_TEGRA3_MAGIC;
int len = strlen(tegra_config);
int len2 = strlen(tegra2_config);
int len3 = strlen(tegra3_config);
while (0 != gzgets(kernelConfig, tmpbuf, KERNEL_CONFIG_MAX_LINE_WIDTH))
{
if (0 == strncmp(tmpbuf, tegra_config, len))
char tmpbuf[KERNEL_CONFIG_MAX_LINE_WIDTH];
const char *tegra_config = KERNEL_CONFIG_TEGRA_MAGIC;
const char *tegra2_config = KERNEL_CONFIG_TEGRA2_MAGIC;
const char *tegra3_config = KERNEL_CONFIG_TEGRA3_MAGIC;
int len = strlen(tegra_config);
int len2 = strlen(tegra2_config);
int len3 = strlen(tegra3_config);
while (0 != gzgets(kernelConfig, tmpbuf, KERNEL_CONFIG_MAX_LINE_WIDTH))
{
result = 1;
}
if (0 == strncmp(tmpbuf, tegra_config, len))
{
result = 1;
}
if (0 == strncmp(tmpbuf, tegra2_config, len2))
{
result = 2;
break;
}
if (0 == strncmp(tmpbuf, tegra2_config, len2))
{
result = 2;
break;
}
if (0 == strncmp(tmpbuf, tegra3_config, len3))
{
result = 3;
break;
}
if (0 == strncmp(tmpbuf, tegra3_config, len3))
{
result = 3;
break;
}
}
gzclose(kernelConfig);
}
gzclose(kernelConfig);
}
else
{
result = TEGRA_DETECTOR_ERROR;
result = TEGRA_DETECTOR_ERROR;
}
return result;

View File

@ -8,8 +8,8 @@
using namespace std;
JavaBasedPackageManager::JavaBasedPackageManager(JavaVM* JavaMashine, jobject MarketConnector):
JavaContext(JavaMashine),
JavaPackageManager(MarketConnector)
JavaContext(JavaMashine),
JavaPackageManager(MarketConnector)
{
assert(JavaContext);
assert(JavaPackageManager);
@ -24,23 +24,23 @@ bool JavaBasedPackageManager::InstallPackage(const PackageInfo& package)
self_attached = (JNI_EDETACHED == JavaContext->GetEnv((void**)&jenv, JNI_VERSION_1_6));
if (self_attached)
{
JavaContext->AttachCurrentThread(&jenv, NULL);
JavaContext->AttachCurrentThread(&jenv, NULL);
}
LOGD("GetObjectClass call\n");
jclass jclazz = jenv->GetObjectClass(JavaPackageManager);
if (!jclazz)
{
LOGE("MarketConnector class was not found!");
return false;
LOGE("MarketConnector class was not found!");
return false;
}
LOGD("GetMethodID call\n");
jmethodID jmethod = jenv->GetMethodID(jclazz, "InstallAppFromMarket", "(Ljava/lang/String;)Z");
if (!jmethod)
{
LOGE("MarketConnector::GetAppFormMarket method was not found!");
return false;
LOGE("MarketConnector::GetAppFormMarket method was not found!");
return false;
}
LOGD("Calling java package manager with package name %s\n", package.GetFullName().c_str());
@ -50,7 +50,7 @@ bool JavaBasedPackageManager::InstallPackage(const PackageInfo& package)
if (self_attached)
{
JavaContext->DetachCurrentThread();
JavaContext->DetachCurrentThread();
}
LOGD("JavaBasedPackageManager::InstallPackage() end\n");
@ -69,23 +69,23 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
self_attached = (JNI_EDETACHED == JavaContext->GetEnv((void**)&jenv, JNI_VERSION_1_6));
if (self_attached)
{
JavaContext->AttachCurrentThread(&jenv, NULL);
JavaContext->AttachCurrentThread(&jenv, NULL);
}
LOGD("GetObjectClass call");
jclass jclazz = jenv->GetObjectClass(JavaPackageManager);
if (!jclazz)
{
LOGE("MarketConnector class was not found!");
return result;
LOGE("MarketConnector class was not found!");
return result;
}
LOGD("GetMethodID call");
jmethodID jmethod = jenv->GetMethodID(jclazz, "GetInstalledOpenCVPackages", "()[Landroid/content/pm/PackageInfo;");
if (!jmethod)
{
LOGE("MarketConnector::GetInstalledOpenCVPackages method was not found!");
return result;
LOGE("MarketConnector::GetInstalledOpenCVPackages method was not found!");
return result;
}
LOGD("Java package manager call");
@ -98,19 +98,19 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
for (jsize i = 0; i < size; i++)
{
jobject jtmp = jenv->GetObjectArrayElement(jpkgs, i);
PackageInfo tmp = ConvertPackageFromJava(jtmp, jenv);
jenv->DeleteLocalRef(jtmp);
jobject jtmp = jenv->GetObjectArrayElement(jpkgs, i);
PackageInfo tmp = ConvertPackageFromJava(jtmp, jenv);
jenv->DeleteLocalRef(jtmp);
if (tmp.IsValid())
result.push_back(tmp);
if (tmp.IsValid())
result.push_back(tmp);
}
jenv->DeleteLocalRef(jpkgs);
if (self_attached)
{
JavaContext->DetachCurrentThread();
JavaContext->DetachCurrentThread();
}
LOGD("JavaBasedPackageManager::GetInstalledPackages() end");
@ -140,20 +140,20 @@ PackageInfo JavaBasedPackageManager::ConvertPackageFromJava(jobject package, JNI
jint api_level = jenv->GetStaticIntField(jclazz, jfield);
if (api_level > 8)
{
jclazz = jenv->GetObjectClass(package);
jfield = jenv->GetFieldID(jclazz, "applicationInfo", "Landroid/content/pm/ApplicationInfo;");
jobject japp_info = jenv->GetObjectField(package, jfield);
jclazz = jenv->GetObjectClass(japp_info);
jfield = jenv->GetFieldID(jclazz, "nativeLibraryDir", "Ljava/lang/String;");
jstring jpathobj = static_cast<jstring>(jenv->GetObjectField(japp_info, jfield));
const char* jpathstr = jenv->GetStringUTFChars(jpathobj, NULL);
path = string(jpathstr);
jenv->ReleaseStringUTFChars(jpathobj, jpathstr);
jenv->DeleteLocalRef(jpathobj);
jclazz = jenv->GetObjectClass(package);
jfield = jenv->GetFieldID(jclazz, "applicationInfo", "Landroid/content/pm/ApplicationInfo;");
jobject japp_info = jenv->GetObjectField(package, jfield);
jclazz = jenv->GetObjectClass(japp_info);
jfield = jenv->GetFieldID(jclazz, "nativeLibraryDir", "Ljava/lang/String;");
jstring jpathobj = static_cast<jstring>(jenv->GetObjectField(japp_info, jfield));
const char* jpathstr = jenv->GetStringUTFChars(jpathobj, NULL);
path = string(jpathstr);
jenv->ReleaseStringUTFChars(jpathobj, jpathstr);
jenv->DeleteLocalRef(jpathobj);
}
else
{
path = "/data/data/" + name + "/lib";
path = "/data/data/" + name + "/lib";
}
return PackageInfo(name, path, verison);
@ -170,14 +170,14 @@ JavaBasedPackageManager::~JavaBasedPackageManager()
self_attached = (JNI_EDETACHED == JavaContext->GetEnv((void**)&jenv, JNI_VERSION_1_6));
if (self_attached)
{
JavaContext->AttachCurrentThread(&jenv, NULL);
JavaContext->AttachCurrentThread(&jenv, NULL);
}
jenv->DeleteGlobalRef(JavaPackageManager);
if (self_attached)
{
JavaContext->DetachCurrentThread();
JavaContext->DetachCurrentThread();
}
LOGD("JavaBasedPackageManager::~JavaBasedPackageManager() end");
}

View File

@ -20,11 +20,11 @@ JNIEXPORT jobject JNICALL Java_org_opencv_engine_BinderConnector_Connect(JNIEnv*
LOGI("Creating new component");
if (NULL != OpenCVEngineBinder.get())
{
LOGI("New component created successfully");
LOGI("New component created successfully");
}
else
{
LOGE("OpenCV Engine component was not created!");
LOGE("OpenCV Engine component was not created!");
}
return javaObjectForIBinder(env, OpenCVEngineBinder);
@ -36,25 +36,25 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_engine_BinderConnector_Init(JNIEnv* e
if (NULL == PackageManager)
{
JavaVM* jvm;
env->GetJavaVM(&jvm);
PackageManager = new JavaBasedPackageManager(jvm, env->NewGlobalRef(market));
JavaVM* jvm;
env->GetJavaVM(&jvm);
PackageManager = new JavaBasedPackageManager(jvm, env->NewGlobalRef(market));
}
if (PackageManager)
{
if (!OpenCVEngineBinder.get())
{
OpenCVEngineBinder = new OpenCVEngine(PackageManager);
return (NULL != OpenCVEngineBinder.get());
if (!OpenCVEngineBinder.get())
{
OpenCVEngineBinder = new OpenCVEngine(PackageManager);
return (NULL != OpenCVEngineBinder.get());
}
else
{
return true;
}
}
else
{
return true;
}
}
else
{
return false;
return false;
}
}
@ -67,4 +67,3 @@ JNIEXPORT void JNICALL Java_org_opencv_engine_BinderConnector_Final(JNIEnv *, jo
delete PackageManager;
PackageManager = NULL;
}

View File

@ -25,10 +25,10 @@ int main(int argc, char *argv[])
LOGI("Trying to contect to service");
do {
EngineService = ServiceManager->getService(IOpenCVEngine::descriptor);
if (EngineService != 0) break;
LOGW("OpenCVEngine not published, waiting...");
usleep(500000); // 0.5 s
EngineService = ServiceManager->getService(IOpenCVEngine::descriptor);
if (EngineService != 0) break;
LOGW("OpenCVEngine not published, waiting...");
usleep(500000); // 0.5 s
} while(true);
LOGI("Connection established");

View File

@ -18,9 +18,9 @@ set<string> CommonPackageManager::GetInstalledVersions()
for (vector<PackageInfo>::const_iterator it = installed_packages.begin(); it != installed_packages.end(); ++it)
{
string version = it->GetVersion();
assert(!version.empty());
result.insert(version);
string version = it->GetVersion();
assert(!version.empty());
result.insert(version);
}
return result;
@ -36,12 +36,13 @@ bool CommonPackageManager::CheckVersionInstalled(const std::string& version, int
for (vector<PackageInfo>::const_iterator it = packages.begin(); it != packages.end(); ++it)
{
LOGD("Found package: \"%s\"", it->GetFullName().c_str());
LOGD("Found package: \"%s\"", it->GetFullName().c_str());
}
if (!packages.empty())
{
result = (packages.end() != find(packages.begin(), packages.end(), target_package));
vector<PackageInfo>::const_iterator it = find(packages.begin(), packages.end(), target_package);
result = (it != packages.end());
}
LOGD("CommonPackageManager::CheckVersionInstalled() end");
return result;
@ -63,65 +64,65 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
for (vector<PackageInfo>::iterator it = all_packages.begin(); it != all_packages.end(); ++it)
{
LOGD("Check version \"%s\" compatibility with \"%s\"\n", version.c_str(), it->GetVersion().c_str());
if (IsVersionCompatible(version, it->GetVersion()))
{
LOGD("Compatible");
packages.push_back(*it);
}
else
{
LOGD("NOT Compatible");
}
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())
{
vector<PackageInfo>::iterator found = find(packages.begin(), packages.end(), target_package);
if (packages.end() != found)
{
result = found->GetInstalationPath();
}
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
{
for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
{
int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
if (PackageRating >= 0)
{
if ((PackageRating <= HardwareRating) && (PackageRating > OptRating))
{
OptRating = PackageRating;
found = it;
}
}
}
if ((-1 != OptRating) && (packages.end() != found))
vector<PackageInfo>::iterator found = find(packages.begin(), packages.end(), target_package);
if (packages.end() != found)
{
result = found->GetInstalationPath();
}
else
{
LOGI("Found package is incompatible with current hardware platform");
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
{
for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
{
int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
if (PackageRating >= 0)
{
if ((PackageRating <= HardwareRating) && (PackageRating > OptRating))
{
OptRating = PackageRating;
found = it;
}
}
}
if ((-1 != OptRating) && (packages.end() != found))
{
result = found->GetInstalationPath();
}
else
{
LOGI("Found package is incompatible with current hardware platform");
}
}
}
}
}
}
return result;

View File

@ -32,23 +32,23 @@ inline string JoinARMFeatures(int cpu_id)
if (FEATURES_HAS_NEON2 & cpu_id)
{
if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id) ||(ARCH_ARMv7 & 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)
{
if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & 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)
{
if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & 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)
{
if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & 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;
@ -60,22 +60,22 @@ inline int SplitARMFeatures(const vector<string>& features)
for (size_t i = 3; i < features.size(); i++)
{
if (FEATURES_HAS_VFPv3_NAME == features[i])
{
result |= FEATURES_HAS_VFPv3;
}
else if (FEATURES_HAS_VFPv3d16_NAME == features[i])
{
result |= FEATURES_HAS_VFPv3d16;
}
else if (FEATURES_HAS_NEON_NAME == features[i])
{
result |= FEATURES_HAS_NEON;
}
else if (FEATURES_HAS_NEON2_NAME == features[i])
{
result |= FEATURES_HAS_NEON2;
}
if (FEATURES_HAS_VFPv3_NAME == features[i])
{
result |= FEATURES_HAS_VFPv3;
}
else if (FEATURES_HAS_VFPv3d16_NAME == features[i])
{
result |= FEATURES_HAS_VFPv3d16;
}
else if (FEATURES_HAS_NEON_NAME == features[i])
{
result |= FEATURES_HAS_NEON;
}
else if (FEATURES_HAS_NEON2_NAME == features[i])
{
result |= FEATURES_HAS_NEON2;
}
}
return result;
@ -87,15 +87,15 @@ inline string JoinIntelFeatures(int cpu_id)
if (FEATURES_HAS_SSSE3 & cpu_id)
{
result = FEATURES_HAS_SSSE3_NAME;
result = FEATURES_HAS_SSSE3_NAME;
}
else if (FEATURES_HAS_SSE2 & cpu_id)
{
result = FEATURES_HAS_SSE2_NAME;
result = FEATURES_HAS_SSE2_NAME;
}
else if (FEATURES_HAS_SSE & cpu_id)
{
result = FEATURES_HAS_SSE_NAME;
result = FEATURES_HAS_SSE_NAME;
}
return result;
@ -107,18 +107,18 @@ inline int SplitIntelFeatures(const vector<string>& features)
for (size_t i = 3; i < features.size(); i++)
{
if (FEATURES_HAS_SSSE3_NAME == features[i])
{
result |= FEATURES_HAS_SSSE3;
}
else if (FEATURES_HAS_SSE2_NAME == features[i])
{
result |= FEATURES_HAS_SSE2;
}
else if (FEATURES_HAS_SSE_NAME == features[i])
{
result |= FEATURES_HAS_SSE;
}
if (FEATURES_HAS_SSSE3_NAME == features[i])
{
result |= FEATURES_HAS_SSSE3;
}
else if (FEATURES_HAS_SSE2_NAME == features[i])
{
result |= FEATURES_HAS_SSE2;
}
else if (FEATURES_HAS_SSE_NAME == features[i])
{
result |= FEATURES_HAS_SSE;
}
}
return result;
@ -130,12 +130,12 @@ inline string SplitVersion(const vector<string>& features, const string& package
if ((features.size() > 1) && ('v' == features[1][0]))
{
result = features[1].substr(1);
result += SplitStringVector(package_version, '.')[0];
result = features[1].substr(1);
result += SplitStringVector(package_version, '.')[0];
}
else
{
// TODO: Report package name format error
// TODO: Report package name format error
}
return result;
@ -158,23 +158,23 @@ inline int SplitPlatfrom(const vector<string>& features)
if (features.size() > 2)
{
string tmp = features[2];
if (PLATFORM_TEGRA_NAME == tmp)
{
result = PLATFORM_TEGRA;
}
else if (PLATFORM_TEGRA2_NAME == tmp)
{
result = PLATFORM_TEGRA2;
}
else if (PLATFORM_TEGRA3_NAME == tmp)
{
result = PLATFORM_TEGRA3;
}
string tmp = features[2];
if (PLATFORM_TEGRA_NAME == tmp)
{
result = PLATFORM_TEGRA;
}
else if (PLATFORM_TEGRA2_NAME == tmp)
{
result = PLATFORM_TEGRA2;
}
else if (PLATFORM_TEGRA3_NAME == tmp)
{
result = PLATFORM_TEGRA3;
}
}
else
{
// TODO: Report package name format error
// TODO: Report package name format error
}
return result;
@ -189,135 +189,135 @@ inline int SplitPlatfrom(const vector<string>& features)
* Example: armv7_neon, armv5_vfpv3
*/
PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::string install_path):
Version(version),
Platform(platform),
CpuID(cpu_id),
InstallPath("")
Version(version),
Platform(platform),
CpuID(cpu_id),
InstallPath("")
{
#ifndef __SUPPORT_TEGRA3
#ifndef __SUPPORT_TEGRA3
Platform = PLATFORM_UNKNOWN;
#endif
#endif
FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1);
if (PLATFORM_UNKNOWN != Platform)
{
FullName += string("_") + JoinPlatform(platform);
FullName += string("_") + JoinPlatform(platform);
}
else
{
if (ARCH_UNKNOWN != CpuID)
{
if (ARCH_X86 & CpuID)
if (ARCH_UNKNOWN != CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch x86");
FullName += string("_") + ARCH_X86_NAME;
#ifdef __SUPPORT_INTEL_FEATURES
string features = JoinIntelFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
if (ARCH_X86 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch x86");
FullName += string("_") + ARCH_X86_NAME;
#ifdef __SUPPORT_INTEL_FEATURES
string features = JoinIntelFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_X64 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch x64");
#ifdef __SUPPORT_INTEL_x64
FullName += string("_") + ARCH_X64_NAME;
#else
FullName += string("_") + ARCH_X86_NAME;
#endif
#ifdef __SUPPORT_INTEL_FEATURES
string features = JoinIntelFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_ARMv5 & CpuID)
{
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
}
else if (ARCH_ARMv6 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv6");
// NOTE: ARM v5 used instead ARM v6
//FullName += string("_") + ARCH_ARMv6_NAME;
FullName += string("_") + ARCH_ARMv5_NAME;
#ifdef __SUPPORT_ARMEABI_FEATURES
string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_ARMv7 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv7");
FullName += string("_") + ARCH_ARMv7_NAME;
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_ARMv8 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv8");
#ifdef __SUPPORT_ARMEABI_V8
FullName += string("_") + ARCH_ARMv8_NAME;
#else
FullName += string("_") + ARCH_ARMv7_NAME;
#endif
//string features = JoinARMFeatures(CpuID);
//if (!features.empty())
//{
// FullName += string("_") + features;
//}
}
#ifdef __SUPPORT_MIPS
else if (ARCH_MIPS & CpuID)
{
FullName += string("_") + ARCH_MIPS_NAME;
}
#endif
else
{
LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
}
}
#endif
}
else if (ARCH_X64 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch x64");
#ifdef __SUPPORT_INTEL_x64
FullName += string("_") + ARCH_X64_NAME;
#else
FullName += string("_") + ARCH_X86_NAME;
#endif
#ifdef __SUPPORT_INTEL_FEATURES
string features = JoinIntelFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_ARMv5 & CpuID)
{
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
}
else if (ARCH_ARMv6 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv6");
// NOTE: ARM v5 used instead ARM v6
//FullName += string("_") + ARCH_ARMv6_NAME;
FullName += string("_") + ARCH_ARMv5_NAME;
#ifdef __SUPPORT_ARMEABI_FEATURES
string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_ARMv7 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv7");
FullName += string("_") + ARCH_ARMv7_NAME;
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
#endif
}
else if (ARCH_ARMv8 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv8");
#ifdef __SUPPORT_ARMEABI_V8
FullName += string("_") + ARCH_ARMv8_NAME;
#else
FullName += string("_") + ARCH_ARMv7_NAME;
#endif
//string features = JoinARMFeatures(CpuID);
//if (!features.empty())
//{
// FullName += string("_") + features;
//}
}
#ifdef __SUPPORT_MIPS
else if (ARCH_MIPS & CpuID)
{
FullName += string("_") + ARCH_MIPS_NAME;
}
#endif
else
{
LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
}
}
else
{
LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
}
}
if (!FullName.empty())
{
InstallPath = install_path + FullName + "/lib";
InstallPath = install_path + FullName + "/lib";
}
}
PackageInfo::PackageInfo(const string& fullname, const string& install_path, string package_version):
FullName(fullname),
InstallPath(install_path)
FullName(fullname),
InstallPath(install_path)
{
LOGD("PackageInfo::PackageInfo(\"%s\", \"%s\", \"%s\")", fullname.c_str(), install_path.c_str(), package_version.c_str());
@ -326,127 +326,127 @@ PackageInfo::PackageInfo(const string& fullname, const string& install_path, str
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)
// 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())
{
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());
tmp = std::string(DEFAULT_ENGINE_INSTALL_PATH) + "/" + LIB_OPENCV_INFO_NAME;
}
else
{
LOGE("Library loading error (%x, %x): \"%s\"", name_func, revision_func, error);
tmp = install_path + "/" + LIB_OPENCV_INFO_NAME;
}
}
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;
}
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);
if (Version.empty())
{
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
}
Version = SplitVersion(features, package_version);
if (Version.empty())
{
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
}
Platform = SplitPlatfrom(features);
if (PLATFORM_UNKNOWN != Platform)
{
CpuID = 0;
}
else
{
if (features.size() < 3)
Platform = SplitPlatfrom(features);
if (PLATFORM_UNKNOWN != Platform)
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
CpuID = 0;
}
else if (ARCH_ARMv5_NAME == features[2])
{
CpuID = ARCH_ARMv5 | SplitARMFeatures(features);
}
else if (ARCH_ARMv6_NAME == features[2])
{
CpuID = ARCH_ARMv6 | SplitARMFeatures(features);
}
else if (ARCH_ARMv7_NAME == features[2])
{
CpuID = ARCH_ARMv7 | SplitARMFeatures(features);
}
else if (ARCH_X86_NAME == features[2])
{
CpuID = ARCH_X86 | SplitIntelFeatures(features);
}
else if (ARCH_X64_NAME == features[2])
{
CpuID = ARCH_X64 | SplitIntelFeatures(features);
}
#ifdef __SUPPORT_MIPS
else if (ARCH_MIPS_NAME == features[2])
{
CpuID = ARCH_MIPS;
}
#endif
else
{
if (features.size() < 3)
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
}
else if (ARCH_ARMv5_NAME == features[2])
{
CpuID = ARCH_ARMv5 | SplitARMFeatures(features);
}
else if (ARCH_ARMv6_NAME == features[2])
{
CpuID = ARCH_ARMv6 | SplitARMFeatures(features);
}
else if (ARCH_ARMv7_NAME == features[2])
{
CpuID = ARCH_ARMv7 | SplitARMFeatures(features);
}
else if (ARCH_X86_NAME == features[2])
{
CpuID = ARCH_X86 | SplitIntelFeatures(features);
}
else if (ARCH_X64_NAME == features[2])
{
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");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
}
}
}
else
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
}
}
}
else
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
}
}

View File

@ -126,7 +126,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
EXPECT_EQ(0, result.size());
}
#else
#else // armeabi
TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();

View File

@ -10,8 +10,8 @@ DEVICE_ARCH = "armeabi"
if (__name__ == "__main__"):
if (len(sys.argv) >= 3):
DEVICE_ARCH = sys.argv[1]
DEVICE_NAME = sys.argv[2]
DEVICE_ARCH = sys.argv[1]
DEVICE_NAME = sys.argv[2]
if (DEVICE_NAME != ""):
DEVICE_STR = "-s \"" + DEVICE_NAME + "\""

View File

@ -18,14 +18,14 @@ def RunTestApp(AppName):
if (__name__ == "__main__"):
if (3 == len(sys.argv)):
DEVICE_ARCH = sys.argv[1]
DEVICE_NAME = sys.argv[2]
DEVICE_ARCH = sys.argv[1]
DEVICE_NAME = sys.argv[2]
if (DEVICE_NAME != ""):
DEVICE_STR = "-s \"" + DEVICE_NAME + "\""
if (not os.path.exists(LOCAL_LOG_PATH)):
os.makedirs(LOCAL_LOG_PATH)
os.makedirs(LOCAL_LOG_PATH)
print("Waiting for device \"%s\" with arch \"%s\" ..." % (DEVICE_NAME, DEVICE_ARCH))
os.system("adb %s wait-for-device" % DEVICE_STR)

View File

@ -118,7 +118,7 @@ class AsyncServiceHelper
}
else
{
Log.d(TAG, "Wating current installation process");
Log.d(TAG, "Waiting current installation process");
InstallCallbackInterface WaitQuery = new InstallCallbackInterface() {
private LoaderCallbackInterface mUserAppCallback = Callback;
public String getPackageName()
@ -268,17 +268,21 @@ class AsyncServiceHelper
{
Log.d(TAG, "OpenCV package was not installed!");
mStatus = LoaderCallbackInterface.MARKET_ERROR;
Log.d(TAG, "Init finished with status " + mStatus);
Log.d(TAG, "Unbind from service");
mAppContext.unbindService(mServiceConnection);
Log.d(TAG, "Calling using callback");
mUserAppCallback.onManagerConnected(mStatus);
}
} catch (RemoteException e) {
e.printStackTrace();
mStatus = LoaderCallbackInterface.INIT_FAILED;
Log.d(TAG, "Init finished with status " + mStatus);
Log.d(TAG, "Unbind from service");
mAppContext.unbindService(mServiceConnection);
Log.d(TAG, "Calling using callback");
mUserAppCallback.onManagerConnected(mStatus);
}
Log.d(TAG, "Init finished with status " + mStatus);
Log.d(TAG, "Unbind from service");
mAppContext.unbindService(mServiceConnection);
Log.d(TAG, "Calling using callback");
mUserAppCallback.onManagerConnected(mStatus);
}
};

View File

@ -28,7 +28,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
/** OpenCV loader can not start Google Play Market. **/
case LoaderCallbackInterface.MARKET_ERROR:
{
Log.d(TAG, "Google Play service is not installed! You can get it here");
Log.e(TAG, "Package installation failed!");
AlertDialog MarketErrorMessage = new AlertDialog.Builder(mAppContext).create();
MarketErrorMessage.setTitle("OpenCV Manager");
MarketErrorMessage.setMessage("Package installation failed!");

View File

@ -12,6 +12,11 @@ public class OpenCVLoader
*/
public static final String OPENCV_VERSION_2_4_2 = "2.4.2";
/**
* OpenCV Library version 2.4.3.
*/
public static final String OPENCV_VERSION_2_4_3 = "2.4.3";
/**
* Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
* @return Returns true is initialization of OpenCV was successful.

View File

@ -71,7 +71,7 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -86,7 +86,7 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -140,7 +140,7 @@ public class FdActivity extends Activity implements CvCameraViewListener {
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -121,7 +121,7 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -64,7 +64,7 @@ public class Sample1Java extends Activity implements CvCameraViewListener {
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -83,7 +83,7 @@ public class Sample2NativeCamera extends Activity implements CvCameraViewListene
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -72,7 +72,7 @@ public class Sample3Native extends Activity implements CvCameraViewListener {
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {

View File

@ -98,7 +98,7 @@ public class Sample4Mixed extends Activity implements CvCameraViewListener {
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {