if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()
-
-ocv_parse_header2(ZLIB "${CMAKE_CURRENT_SOURCE_DIR}/zlib.h" ZLIB_VERSION PARENT_SCOPE)
-
--- /dev/null
+********
+Java API
+********
+
+
+`Java API reference external link (JavaDoc) <http://docs.opencv.org/java/>`_
\ No newline at end of file
.. toctree::
:maxdepth: 2
- service/doc/index.rst
\ No newline at end of file
+ service/doc/index.rst
+ java.rst
\ No newline at end of file
*********************************************
.. highlight:: java
-.. module:: org.opencv.android
- :platform: Android
- :synopsis: Implements OpenCV initialization callback interface.
.. class:: BaseLoaderCallback
Basic implementation of LoaderCallbackInterface. Implementation logic is described by diagram.
-.. image:: img/AndroidAppUsageModel.dia.png
+.. image:: img/AndroidAppUsageModel.png
Install Callback Interface
**************************
.. highlight:: java
-.. module:: org.opencv.android
- :platform: Android
- :synopsis: Defines callback interface for package management.
-
.. class:: InstallCallbackInterface
Callback interface for package installation or update.
Usage model for target user
---------------------------
-.. image:: img/AndroidAppUsageModel.dia.png
+.. image:: img/AndroidAppUsageModel.png
First OpenCV app\:
OpenCV Manager structure
------------------------
-.. image:: img/Structure.dia.png
\ No newline at end of file
+.. image:: img/Structure.png
\ No newline at end of file
******************
.. highlight:: java
-.. module:: org.opencv.android
- :platform: Android
- :synopsis: Implements Android dependent Java classes.
.. Class:: OpenCVLoader
Helper class provides common initialization methods for OpenCV library
*************************
.. highlight:: java
-.. module:: org.opencv.android
- :platform: Android
- :synopsis: Defines OpenCV initialization callback interface.
.. class:: LoaderCallbackInterface
Interface for callback object in case of asynchronous initialization of OpenCV
Callback method that is called in case when package installation is needed
- @param callback Answer object with approve and cancel methods and package description
+ :param callback: Answer object with approve and cancel methods and package description
Initialization status constants
-------------------------------
There is no OpenCV Manager and OpenCV libraries.
-.. image:: img/NoService.dia.png
+.. image:: img/NoService.png
Second application start
------------------------
There is OpenCV Manager service, but there is no OpenCV library.
If OpenCV library installation approved\:
-.. image:: img/LibInstallAproved.dia.png
+.. image:: img/LibInstallAproved.png
If OpenCV library installation canceled\:
-.. image:: img/LibInstallCanceled.dia.png
+.. image:: img/LibInstallCanceled.png
Regular application start
-------------------------
OpenCV Manager and OpenCV library has bee already installed.
-.. image:: img/LibInstalled.dia.png
\ No newline at end of file
+.. image:: img/LibInstalled.png
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine"
- android:versionCode="11"
- android:versionName="1.1" >
+ android:versionCode="12"
+ android:versionName="1.2" >
<uses-sdk android:minSdkVersion="8" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
$(TOP)/system/core/include
LOCAL_CFLAGS += -DPLATFORM_ANDROID
+LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
+#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
+#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
LOCAL_PRELINK_MODULE := false
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS += -DPLATFORM_ANDROID
+LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
+#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
+#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
LOCAL_MODULE := libOpenCVEngine_jni
}
else
{
- LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
+ LOGE("OpenCV version \"%s\" (%s) is not supported", String8(version).string(), norm_version.c_str());
}
return String16(path.c_str());
for (vector<PackageInfo>::iterator it = all_packages.begin(); it != all_packages.end(); ++it)
{
+ LOGD("Check version \"%s\" compatibility with \"%s\"\n", version.c_str(), it->GetVersion().c_str());
if (IsVersionCompatible(version, it->GetVersion()))
{
+ LOGD("Compatible");
packages.push_back(*it);
}
+ else
+ {
+ LOGD("NOT Compatible");
+ }
}
if (!packages.empty())
group = CommonPackageManager::IntelRating;
int HardwareRating = GetHardwareRating(platform, cpu_id, group);
+ LOGD("Current hardware platform %d, %d", platform, cpu_id);
if (-1 == HardwareRating)
{
- LOGE("Cannot calculate rating for current hardware platfrom!");
+ LOGE("Cannot calculate rating for current hardware platform!");
}
else
{
{
result = found->GetInstalationPath();
}
+ else
+ {
+ LOGI("Found package is incompatible with current hardware platform");
+ }
}
}
}
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3d16));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3));
+ result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3));
+ result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3));
result.push_back(std::pair<int, int>(PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
if (FEATURES_HAS_NEON2 & cpu_id)
{
- result = string(FEATURES_HAS_NEON2_NAME);
+ if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id) ||(ARCH_ARMv7 & cpu_id)))
+ result = string(FEATURES_HAS_NEON2_NAME);
}
else if (FEATURES_HAS_NEON & cpu_id)
{
- result = string(FEATURES_HAS_NEON_NAME);
+ if (!((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id)))
+ result = string(FEATURES_HAS_NEON_NAME);
}
else if (FEATURES_HAS_VFPv3 & cpu_id)
{
- result = string(FEATURES_HAS_VFPv3_NAME);
+ if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id))
+ result = string(FEATURES_HAS_VFPv3_NAME);
}
else if (FEATURES_HAS_VFPv3d16 & cpu_id)
{
- result = string(FEATURES_HAS_VFPv3d16_NAME);
+ if ((ARCH_ARMv5 & cpu_id) || (ARCH_ARMv6 & cpu_id))
+ result = string(FEATURES_HAS_VFPv3d16_NAME);
}
return result;
* First part is base namespace.
* Second part is version. Version starts from "v" symbol. After "v" symbol version nomber without dot symbol added.
* If platform is known third part is platform name
- * If platform is unknown it is defined by hardware capabilities using pattern: <arch>_<fpu features>_<vectorisation features>_<other features>
- * Example: armv7_vfpv3_neon, armv7_vfpv3d16_neon
+ * If platform is unknown it is defined by hardware capabilities using pattern: <arch>_<floating point and vectorization features>_<other features>
+ * Example: armv7_neon, armv5_vfpv3
*/
-PackageInfo::PackageInfo(const string& version, int platform, int cpu_id):
+PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::string install_path):
Version(version),
Platform(platform),
CpuID(cpu_id),
InstallPath("")
{
+#ifndef __SUPPORT_TEGRA3
+ Platform = PLATFORM_UNKNOWN;
+#endif
FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1);
if (PLATFORM_UNKNOWN != Platform)
{
{
if (ARCH_X86 & CpuID)
{
- LOGD("Found processor with x86 arch");
+ LOGD("PackageInfo::PackageInfo: package arch x86");
FullName += string("_") + ARCH_X86_NAME;
- // NOTE: Intel features temporary are not supported
- //string features = JoinIntelFeatures(CpuID);
- string features;
+#ifdef __SUPPORT_INTEL_FEATURES
+ string features = JoinIntelFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
+#endif
}
- if (ARCH_X64 & CpuID)
+ else if (ARCH_X64 & CpuID)
{
- LOGD("Found processor with x64 arch");
- // NOTE: Intel features temporary are not supported
- //FullName += string("_") + ARCH_X64_NAME;
- //string features = JoinIntelFeatures(CpuID);
+ LOGD("PackageInfo::PackageInfo: package arch x64");
+#ifdef __SUPPORT_INTEL_x64
+ FullName += string("_") + ARCH_X64_NAME;
+#else
FullName += string("_") + ARCH_X86_NAME;
- string features;
+#endif
+#ifdef __SUPPORT_INTEL_FEATURES
+ string features = JoinIntelFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
+#endif
}
- if (ARCH_ARMv5 & CpuID)
+ else if (ARCH_ARMv5 & CpuID)
{
- LOGD("Found processor with ARMv5 arch");
+ LOGD("PackageInfo::PackageInfo: package arch ARMv5");
FullName += string("_") + ARCH_ARMv5_NAME;
+#ifdef __SUPPORT_ARMEABI_FEATURES
string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
+#endif
}
- if (ARCH_ARMv6 & CpuID)
+ else if (ARCH_ARMv6 & CpuID)
{
- LOGD("Found processor with ARMv6 arch");
- // NOTE: ARM v6 used instead ARM v6
+ LOGD("PackageInfo::PackageInfo: package arch ARMv6");
+ // NOTE: ARM v5 used instead ARM v6
//FullName += string("_") + ARCH_ARMv6_NAME;
FullName += string("_") + ARCH_ARMv5_NAME;
- // NOTE: ARM features temporary are not supported
- //string features = JoinARMFeatures(CpuID);
- string features;
+#ifdef __SUPPORT_ARMEABI_FEATURES
+ string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
+#endif
}
- if (ARCH_ARMv7 & CpuID)
+ else if (ARCH_ARMv7 & CpuID)
{
- LOGD("Found processor with ARMv7 arch");
+ LOGD("PackageInfo::PackageInfo: package arch ARMv7");
FullName += string("_") + ARCH_ARMv7_NAME;
- // NOTE: ARM features temporary are not supported
- //string features = JoinARMFeatures(CpuID);
- string features;
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ string features = JoinARMFeatures(CpuID);
if (!features.empty())
{
FullName += string("_") + features;
}
+#endif
}
- if (ARCH_ARMv8 & CpuID)
+ else if (ARCH_ARMv8 & CpuID)
{
- LOGD("Found processor with ARMv8 arch");
+ LOGD("PackageInfo::PackageInfo: package arch ARMv8");
+#ifdef __SUPPORT_ARMEABI_V8
FullName += string("_") + ARCH_ARMv8_NAME;
- string features = JoinARMFeatures(CpuID);
- if (!features.empty())
- {
- FullName += string("_") + features;
- }
+#else
+ FullName += string("_") + ARCH_ARMv7_NAME;
+#endif
+ //string features = JoinARMFeatures(CpuID);
+ //if (!features.empty())
+ //{
+ // FullName += string("_") + features;
+ //}
+ }
+ else
+ {
+ LOGD("PackageInfo::PackageInfo: package arch unknown");
+ Version.clear();
+ CpuID = ARCH_UNKNOWN;
+ Platform = PLATFORM_UNKNOWN;
}
}
else
{
- LOGD("Found processor with unknown arch");
+ LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
}
}
+
+ if (!FullName.empty())
+ {
+ InstallPath = install_path + FullName + "/lib";
+ }
}
PackageInfo::PackageInfo(const string& fullname, const string& install_path, const string& package_version):
FullName(fullname),
InstallPath(install_path)
{
- LOGD("PackageInfo::PackageInfo(\"%s\", \"%s\")", fullname.c_str(), install_path.c_str());
+ LOGD("PackageInfo::PackageInfo(\"%s\", \"%s\", \"%s\")", fullname.c_str(), install_path.c_str(), package_version.c_str());
assert(!fullname.empty());
assert(!install_path.empty());
class PackageInfo
{
public:
- PackageInfo(const std::string& version, int platform, int cpu_id);
+ PackageInfo(const std::string& version, int platform, int cpu_id, std::string install_path = "/data/data/");
PackageInfo(const std::string& fullname, const std::string& install_path, const std::string& package_version = "0.0");
std::string GetFullName() const;
std::string GetVersion() const;
public:
ServiceStarter()
{
- PackageManager = new PackageManagerStub();
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
- PackageManager->InstalledPackages.push_back(info);
-
+ PackageManager = new PackageManagerStub();
Engine = new OpenCVEngine(PackageManager);
defaultServiceManager()->addService(IOpenCVEngine::descriptor, Engine);
{
delete PackageManager;
}
-private:
+
PackageManagerStub* PackageManager;
sp<IBinder> Engine;
};
EXPECT_EQ(OPEN_CV_ENGINE_VERSION, Version);
}
-TEST(OpenCVEngineTest, InstallVersion)
+TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();
+ Starter.PackageManager->InstalledPackages.clear();
+ Starter.PackageManager->InstallVersion("240", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
EXPECT_FALSE(NULL == Engine.get());
- bool result = Engine->InstallVersion(String16("2.4"));
- EXPECT_EQ(true, result);
+ String16 result = Engine->GetLibPathByVersion(String16("2.4"));
+ #ifdef __SUPPORT_TEGRA3
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
+ #else
+ #ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
+ #else
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
+ #endif
+ #endif
}
-TEST(OpenCVEngineTest, GetPathForExistVersion)
+TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
{
sp<IOpenCVEngine> Engine = InitConnect();
+ Starter.PackageManager->InstalledPackages.clear();
+ Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
EXPECT_FALSE(NULL == Engine.get());
- String16 result = Engine->GetLibPathByVersion(String16("2.3"));
- EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7/lib",String8(result).string());
+ String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
+ #ifdef __SUPPORT_TEGRA3
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
+ #else
+ #ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
+ #else
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
+ #endif
+ #endif
+}
+
+TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
+{
+ sp<IOpenCVEngine> Engine = InitConnect();
+ Starter.PackageManager->InstalledPackages.clear();
+ Starter.PackageManager->InstallVersion("241", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
+ EXPECT_FALSE(NULL == Engine.get());
+ String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
+ EXPECT_EQ(0, result.size());
}
TEST(OpenCVEngineTest, GetPathForUnExistVersion)
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"));
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string());
+}
+
+TEST(OpenCVEngineTest, GetPathForCompatiblePackage2)
+{
+ sp<IOpenCVEngine> Engine = InitConnect();
+ Starter.PackageManager->InstalledPackages.clear();
+ Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
+ EXPECT_FALSE(NULL == Engine.get());
+ String16 result = Engine->GetLibPathByVersion(String16("2.4"));
+#ifdef __SUPPORT_TEGRA3
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
+#else
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
+#else
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
+#endif
+#endif
+}
+
+TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
+{
+ sp<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)
{
sp<IOpenCVEngine> Engine = InitConnect();
+ Starter.PackageManager->InstalledPackages.clear();
EXPECT_FALSE(NULL == Engine.get());
- EXPECT_TRUE(Engine->InstallVersion(String16("2.5")));
- String16 result = Engine->GetLibPathByVersion(String16("2.5"));
- EXPECT_STREQ("/data/data/org.opencv.lib_v25_tegra3/lib", String8(result).string());
+ EXPECT_TRUE(Engine->InstallVersion(String16("2.4")));
+ String16 result = Engine->GetLibPathByVersion(String16("2.4"));
+#ifdef __SUPPORT_TEGRA3
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string());
+#else
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string());
+#else
+ EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
+#endif
+#endif
}
\ No newline at end of file
{
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
string name = info.GetFullName();
- EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str());
+ EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
}
TEST(PackageInfo, FullNameArmv7Neon)
{
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
+ PackageInfo info("241", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
string name = info.GetFullName();
- EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str());
- // TODO: Replace if seporate package will be exists
- //EXPECT_STREQ("org.opencv.lib_v23_armv7_neon", name.c_str());
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("org.opencv.lib_v24_armv7a_neon", name.c_str());
+#else
+ EXPECT_STREQ("org.opencv.lib_v24_armv7a", name.c_str());
+#endif
}
TEST(PackageInfo, FullNameArmv7VFPv3)
{
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
+ PackageInfo info("233", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
string name = info.GetFullName();
- EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str());
- // TODO: Replace if seporate package will be exists
- //EXPECT_STREQ("org.opencv.lib_v23_armv7_vfpv3", name.c_str());
+ EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
}
TEST(PackageInfo, FullNameArmv7VFPv3Neon)
{
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
string name = info.GetFullName();
- EXPECT_STREQ("org.opencv.lib_v23_armv7", name.c_str());
- // TODO: Replace if seporate package will be exists
- //EXPECT_STREQ("org.opencv.lib_v23_armv7_neon", name.c_str());
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
+#else
+ EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
+#endif
+}
+
+TEST(PackageInfo, FullNameArmv5)
+{
+ PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
+ string name = info.GetFullName();
+ EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
+}
+
+TEST(PackageInfo, FullNameArmv6)
+{
+ PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv6);
+ string name = info.GetFullName();
+ EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
+}
+
+TEST(PackageInfo, FullNameArmv6VFPv3)
+{
+ PackageInfo info("232", PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3);
+ string name = info.GetFullName();
+#ifdef __SUPPORT_ARMEABI_FEATURES
+ EXPECT_STREQ("org.opencv.lib_v23_armv5_vfpv3", name.c_str());
+#else
+ EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
+#endif
+}
+
+TEST(PackageInfo, FullNameTegra3)
+{
+ PackageInfo info("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
+ string name = info.GetFullName();
+ #ifdef __SUPPORT_TEGRA3
+ EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str());
+ #else
+ #ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
+ #else
+ EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
+ #endif
+ #endif
}
TEST(PackageInfo, FullNameX86SSE2)
{
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
string name = info.GetFullName();
+#ifdef __SUPPORT_INTEL_FEATURES
+ EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str());
+#else
EXPECT_STREQ("org.opencv.lib_v23_x86", name.c_str());
- // TODO: Replace if seporate package will be exists
- //EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str());
+#endif
+}
+
+TEST(PackageInfo, Armv7NeonFromFullName)
+{
+ PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon");
+ EXPECT_EQ("230", info.GetVersion());
+ EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID());
}
-TEST(PackageInfo, Armv7VFPv3NeonFromFullName)
+TEST(PackageInfo, Armv5FromFullName)
{
- PackageInfo info("org.opencv.lib_v23_armv7_vfpv3_neon", "/data/data/org.opencv.lib_v23_armv7_vfpv3_neon");
+ PackageInfo info("org.opencv.lib_v23_armv5", "/data/data/org.opencv.lib_v23_armv5");
EXPECT_EQ("230", info.GetVersion());
- EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON, info.GetCpuID());
+ EXPECT_EQ(ARCH_ARMv5, info.GetCpuID());
+}
+
+TEST(PackageInfo, Armv5VFPv3FromFullName)
+{
+ PackageInfo info("org.opencv.lib_v23_armv5_vfpv3", "/data/data/org.opencv.lib_v23_armv5_vfpv3");
+ EXPECT_EQ("230", info.GetVersion());
+ EXPECT_EQ(ARCH_ARMv5 | FEATURES_HAS_VFPv3, info.GetCpuID());
}
TEST(PackageInfo, X86SSE2FromFullName)
EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform());
}
-TEST(PackageInfo, FullNameTegra3)
-{
- PackageInfo info("230", PLATFORM_TEGRA3, 0);
- EXPECT_TRUE(!info.IsValid());
- // TODO: Replace if seporate package will be exists
- //string name = info.GetFullName();
- //EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str());
-}
-
-TEST(PackageInfo, FullNameTegra2)
-{
- PackageInfo info("230", PLATFORM_TEGRA2, 0);
- EXPECT_TRUE(!info.IsValid());
- // TODO: Replace if seporate package will be exists
- //string name = info.GetFullName();
- //EXPECT_STREQ("org.opencv.lib_v23_tegra2", name.c_str());
-}
-
TEST(PackageInfo, Comparator1)
{
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_X86);
TEST(PackageInfo, Comparator2)
{
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3);
- PackageInfo info2("org.opencv.lib_v24_armv7", "/data/data/org.opencv.lib_v24_armv7");
- // TODO: Replace if seporate package will be exists
- //PackageInfo info2("org.opencv.lib_v24_armv7_vfpv3_neon", "/data/data/org.opencv.lib_v24_armv7_vfpv3_neon");
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ PackageInfo info2("org.opencv.lib_v24_armv7a_neon", "/data/data/org.opencv.lib_v24_armv7a_neon");
+#else
+ PackageInfo info2("org.opencv.lib_v24_armv7a", "/data/data/org.opencv.lib_v24_armv7a");
+#endif
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
EXPECT_EQ(info1, info2);
}
-// TODO: Enable test if seporate package will be exists
-// TEST(PackageInfo, Comparator3)
-// {
-// PackageInfo info1("230", PLATFORM_TEGRA2, 0);
-// PackageInfo info2("org.opencv.lib_v23_tegra2", "/data/data/org.opencv.lib_v23_tegra2");
-// EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
-// EXPECT_EQ(info1, info2);
-// }
\ No newline at end of file
+#ifdef __SUPPORT_TEGRA3
+TEST(PackageInfo, Comparator3)
+{
+ PackageInfo info1("230", PLATFORM_TEGRA3, 0);
+ PackageInfo info2("org.opencv.lib_v23_tegra3", "/data/data/org.opencv.lib_v23_tegra3");
+ EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
+ EXPECT_EQ(info1, info2);
+}
+#endif
\ No newline at end of file
bool PackageManagerStub::InstallPackage(const PackageInfo& package)
{
- InstalledPackages.push_back(PackageInfo(package.GetFullName(), "/data/data/" + package.GetFullName()));
+ InstalledPackages.push_back(package);
return true;
}
TEST(PackageManager, CheckVersionInstalled)
{
PackageManagerStub pm;
- PackageInfo info("230", PLATFORM_TEGRA3, 0);
+ PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
pm.InstalledPackages.push_back(info);
- EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_TEGRA3, 0));
+ EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_UNKNOWN, ARCH_ARMv7));
}
TEST(PackageManager, InstallVersion)
{
PackageManagerStub pm;
- PackageInfo info("230", PLATFORM_TEGRA3, 0);
+ PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
pm.InstalledPackages.push_back(info);
- EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_TEGRA3, 0));
+ EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
EXPECT_EQ(2, pm.InstalledPackages.size());
- EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_TEGRA3, 0));
+ EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
}
TEST(PackageManager, GetPackagePathForArmv7)
{
PackageManagerStub pm;
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
- pm.InstalledPackages.push_back(info);
+ EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7));
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
- EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7/lib", path.c_str());
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
}
TEST(PackageManager, GetPackagePathForArmv7Neon)
{
PackageManagerStub pm;
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
- pm.InstalledPackages.push_back(info);
-
+ EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
- EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7/lib", path.c_str());
- // TODO: Replace if seporate package will be exists
- //EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7_neon/lib", path.c_str());
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str());
+#else
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
+#endif
}
TEST(PackageManager, GetPackagePathForX86)
{
PackageManagerStub pm;
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86);
- pm.InstalledPackages.push_back(info);
+ EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86));
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86);
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str());
}
TEST(PackageManager, GetPackagePathForX86SSE2)
{
PackageManagerStub pm;
- PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
- pm.InstalledPackages.push_back(info);
+ EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
+#ifdef __SUPPORT_INTEL_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str());
+#else
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str());
- // TODO: Replace if seporate package will be exists
- //EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str());
+#endif
+}
+
+TEST(PackageManager, GetPackagePathForTegra3)
+{
+ PackageManagerStub pm;
+ EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON));
+ string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
+#ifdef __SUPPORT_TEGRA3
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str());
+#else
+#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str());
+#else
+ EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
+#endif
+#endif
}
// TODO: Enable tests if seporate package will be exists
// string path = pm.GetPackagePathByVersion("240", PLATFORM_TEGRA2, 0);
// EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra2/lib", path.c_str());
// }
-//
-// TEST(PackageManager, GetPackagePathForTegra3)
-// {
-// PackageManagerStub pm;
-// PackageInfo info("230", PLATFORM_TEGRA3, 0);
-// pm.InstalledPackages.push_back(info);
-// string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, 0);
-// EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str());
-// }
+
+
Tests/PackageManagmentTest.cpp \
Tests/PackageInfoTest.cpp \
Tests/OpenCVEngineTest.cpp \
- Tests/TestMain.cpp
+ Tests/TestMain.cpp
# Tests/HardwareDetectionTest.cpp \
LOCAL_C_INCLUDES := \
$(TOP)/system/core/include
LOCAL_CFLAGS += -O0 -DGTEST_HAS_CLONE=0 -DGTEST_OS_LINUX_ANDROID=1 -DGTEST_HAS_TR1_TUPLE=0
+LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
+#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
+#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined
// Global tag for Logcat output
#undef LOG_TAG
-#define LOG_TAG "OpenCVEngine"
+#define LOG_TAG "OpenCVEngine"
#ifndef OPEN_CV_ENGINE_VERSION
#define OPEN_CV_ENGINE_VERSION 1
if(${CMAKE_VERSION} VERSION_LESS "2.8.3")
- message(STATUS WITH_CUDA flag requires CMake 2.8.3. CUDA support is disabled.)
+ message(STATUS "WITH_CUDA flag requires CMake 2.8.3 or newer. CUDA support is disabled.")
return()
endif()
ocv_clear_vars(ZLIB_FOUND)
else()
include(FindZLIB)
- if(ZLIB_VERSION_STRING)
- #cmake 2.8.2 bug - it fails to determine zlib version
- unset(ZLIB_VERSION_STRING CACHE)
- endif()
- if(ZLIB_FOUND)
- ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION "")
- endif()
if(ZLIB_FOUND AND ANDROID)
if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so")
set(ZLIB_LIBRARY z)
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib")
set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}")
+
+ ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION)
endif()
# --- libtiff (optional, should be searched after zlib) ---
if(WITH_OPENEXR)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
endif()
+
+#cmake 2.8.2 bug - it fails to determine zlib version
+if(ZLIB_FOUND)
+ ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION)
+endif()
\ No newline at end of file
endmacro()
# read single version define from the header file
-macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME SCOPE)
+macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME)
+ ocv_clear_vars(${LIBNAME}_VERSION_MAJOR
+ ${LIBNAME}_VERSION_MAJOR
+ ${LIBNAME}_VERSION_MINOR
+ ${LIBNAME}_VERSION_PATCH
+ ${LIBNAME}_VERSION_TWEAK
+ ${LIBNAME}_VERSION_STRING)
set(${LIBNAME}_H "")
if(EXISTS "${HDR_PATH}")
file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1)
endif()
+
if(${LIBNAME}_H)
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}")
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}")
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_PATCH "${${LIBNAME}_H}")
- set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${SCOPE})
- set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${SCOPE})
- set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${SCOPE})
- set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}" ${SCOPE})
+ set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${ARGN})
+ set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${ARGN})
+ set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${ARGN})
+ set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}")
# append a TWEAK version if it exists:
set(${LIBNAME}_VERSION_TWEAK "")
if("${${LIBNAME}_H}" MATCHES "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
- set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${SCOPE})
- set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${SCOPE})
+ set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${ARGN})
+ endif()
+ if(${LIBNAME}_VERSION_TWEAK)
+ set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${ARGN})
+ else()
+ set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}" ${ARGN})
endif()
- else()
- ocv_clear_vars(${LIBNAME}_VERSION_MAJOR
- ${LIBNAME}_VERSION_MAJOR
- ${LIBNAME}_VERSION_MINOR
- ${LIBNAME}_VERSION_PATCH
- ${LIBNAME}_VERSION_TWEAK
- ${LIBNAME}_VERSION_STRING)
endif()
endmacro()
endif()
endforeach()
+ file(GLOB_RECURSE _OPENCV_FILES_REF "${OpenCV_SOURCE_DIR}/android/service/doc/*.rst")
+ file(GLOB_RECURSE _OPENCV_FILES_REF_PICT "${OpenCV_SOURCE_DIR}/android/service/doc/*.png" "${OpenCV_SOURCE_DIR}/android/service/doc/*.jpg")
+ list(APPEND OPENCV_FILES_REF ${_OPENCV_FILES_REF})
+ list(APPEND OPENCV_FILES_REF_PICT ${_OPENCV_FILES_REF_PICT})
+
configure_file("${OpenCV_SOURCE_DIR}/modules/refman.rst.in" "${OpenCV_SOURCE_DIR}/modules/refman.rst" IMMEDIATE @ONLY)
file(GLOB_RECURSE OPENCV_FILES_UG user_guide/*.rst)
COMMAND ${SPHINX_BUILD} -b latex -c ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. .
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/pics ${CMAKE_CURRENT_BINARY_DIR}/doc/opencv1/pics
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR}
- COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2refman.tex
+ COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex
COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex
COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex
+ COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex
+ COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex
COMMAND ${PDFLATEX_COMPILER} opencv_user.tex
COMMAND ${PDFLATEX_COMPILER} opencv_user.tex
COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex
u'', 'manual'),
('doc/tutorials/tutorials', 'opencv_tutorials.tex', u'The OpenCV Tutorials',
u'', 'manual'),
+ ('android/refman', 'opencv2manager.tex', u'The OpenCV Manager Manual',
+ u'', 'manual'),
]
preamble ="""
How to use OpenCV library project in your application
=====================================================
-In this section we will explain how to make some existing application to use OpenCV. Starting from 2.4.2 release on Android so-called "OpenCV Manager" is used for providing applications with the best version of OpenCV. You can get more information here: :ref:`Android_OpenCV_Manager`.
+In this section we will explain how to make some existing application to use OpenCV.
+Starting from 2.4.2 release on Android so-called "OpenCV Manager" is used for providing applications with the best version of OpenCV.
+You can get more information here: :ref:`Android_OpenCV_Manager`.
Application development with async initialization
-------------------------------------------------
-Using async initialization is a preferred way for application development. It uses OpenCV Manager Android service to get OpenCV libraries.
+Using async initialization is a preferred way for application development. It uses the OpenCV Manager for access to OpenCV libraries.
-#. Add OpenCV library project to your workspace. Go to :guilabel:`File –> Import –> Existing project in your workspace`, push Browse button and select OpenCV SDK path.
+#. Add OpenCV library project to your workspace. Use menu :guilabel:`File –> Import –> Existing project in your workspace`,
+ push :guilabel:`Browse` button and select OpenCV SDK path (:file:`OpenCV-2.4.2-android-sdk/sdk`).
.. image:: images/eclipse_opencv_dependency0.png
:alt: Add dependency from OpenCV library
:align: center
-#. In application project add reference to OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``;
+#. In application project add a reference to the OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``.
.. image:: images/eclipse_opencv_dependency1.png
:alt: Add dependency from OpenCV library
:align: center
-If you want to use OpenCV Manager-based approach you need to install packages with the Service and OpenCV package for you platform. You can do it using Google Play service or manually with adb tool:
+To use OpenCV Manager-based approach you need to install packages with the `Manager` and `OpenCV binary package` for you platform.
+You can do it using Google Play Market or manually with ``adb`` tool:
.. code-block:: sh
:linenos:
adb install ./org.opencv.engine.apk
adb install ./org.opencv.lib_v24_<hardware version>.apk
-There is a very base code snippet for Async init. It shows only basis principles of library Initiation. See the "15-puzzle" OpenCV sample for details.
+There is a very base code snippet implementing the async initialization. It shows basic principles. See the "15-puzzle" OpenCV sample for details.
.. code-block:: java
:linenos:
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
- Log.i(TAG, "OpenCV loaded successfully");
- // Create and set View
- mView = new puzzle15View(mAppContext);
- setContentView(mView);
+ Log.i(TAG, "OpenCV loaded successfully");
+ // Create and set View
+ mView = new puzzle15View(mAppContext);
+ setContentView(mView);
} break;
default:
{
- super.onManagerConnected(status);
+ super.onManagerConnected(status);
} break;
}
}
}
It this case application works with OpenCV Manager in asynchronous fashion. ``OnManagerConnected`` callback will be called in UI thread, when initialization finishes.
-Please note, that it is not allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback. Load your own native libraries after OpenCV initialization.
+Please note, that it is not allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback.
+Load your own native libraries that depend on OpenCV after the successful OpenCV initialization.
Application development with static initialization
--------------------------------------------------
-According to this approach all OpenCV binaries are linked and put to your application package. It is designed mostly for development purposes.
-This way is deprecated for the production code, release package should communicate with OpenCV Manager, use the async initialization described above.
+According to this approach all OpenCV binaries are included into your application package. It is designed mostly for development purposes.
+This approach is deprecated for the production code, release package is recommended to communicate with OpenCV Manager via the async initialization described above.
-#. Add OpenCV library project to your workspace. Go to :guilabel:`File –> Import –> Existing project in your workspace`, push :guilabel:`Browse` button and select OpenCV SDK path.
+#. Add the OpenCV library project to your workspace the same way as for the async initialization above.
+ Use menu :guilabel:`File –> Import –> Existing project in your workspace`, push :guilabel:`Browse` button and select OpenCV SDK path (:file:`OpenCV-2.4.2-android-sdk/sdk`).
.. image:: images/eclipse_opencv_dependency0.png
:alt: Add dependency from OpenCV library
:align: center
-#. In application project add reference to OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``;
+#. In the application project add a reference to the OpenCV Java SDK in :guilabel:`Project –> Properties –> Android –> Library –> Add` select ``OpenCV Library - 2.4.2``;
.. image:: images/eclipse_opencv_dependency1.png
:alt: Add dependency from OpenCV library
:align: center
-#. Copy native libs to your project directory to folder :file:`libs/target_arch/`.
+#. If your application project **doesn't have a JNI part**, just copy the OpenCV native libs to your project directory to folder :file:`libs/target_arch/`.
+
+ In case of the application project **with a JNI part**, instead of manual libraries copying you need to modify your ``Android.mk`` file:
+ add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before ``"include path_to_OpenCV-2.4.2-android-sdk/sdk/native/jni/OpenCV.mk"``
-After adding depedency from OpenCV library project, Eclipse will automatically copy all needed libraries to the application package.
-To use OpenCV functionality you need to add OpenCV library initialization code before using any OpenCV specific code, for example, to the static section of ``Activity`` class.
+ .. code-block:: make
+ :linenos:
-.. code-block:: java
- :linenos:
+ OPENCV_CAMERA_MODULES:=on
+ OPENCV_INSTALL_MODULES:=on
+
+ The result should look like the following:
+
+ .. code-block:: make
+ :linenos:
+
+ include $(CLEAR_VARS)
+
+ # OpenCV
+ OPENCV_CAMERA_MODULES:=on
+ OPENCV_INSTALL_MODULES:=on
+ include ../../sdk/native/jni/OpenCV.mk
+
+ After that the OpenCV libraries will be copied to your application :file:`libs` folder during the JNI part build.
+
+ Eclipse will automatically include all the libraries from the :file:`libs` folder to the application package (APK).
- static {
- if (!OpenCVLoader.initDebug()) {
- // Report initialization error
+#. The last step of enabling OpenCV in your application is Java initialization code before call to OpenCV API.
+ It can be done, for example, in the static section of the ``Activity`` class:
+
+ .. code-block:: java
+ :linenos:
+
+ static {
+ if (!OpenCVLoader.initDebug()) {
+ // Handle initialization error
+ }
}
- }
-If you application includes other OpenCV-dependent native libraries you need to init OpenCV before them.
+ If you application includes other OpenCV-dependent native libraries you should load them **after** OpenCV initialization:
-.. code-block:: java
- :linenos:
+ .. code-block:: java
+ :linenos:
- static {
- if (OpenCVLoader.initDebug()) {
- System.loadLibrary("my_super_lib1");
- System.loadLibrary("my_super_lib2");
- } else {
- // Report initialization error
+ static {
+ if (!OpenCVLoader.initDebug()) {
+ // Handle initialization error
+ } else {
+ System.loadLibrary("my_jni_lib1");
+ System.loadLibrary("my_jni_lib2");
+ }
}
- }
-Whats next?
-===========
+What's next?
+============
Read the :ref:`Android_Binary_Package_with_NDK` tutorial to learn how to add native OpenCV code to your Android project.
#. Define the ``NDKROOT`` environment variable containing the path to Android NDK in your system (e.g. **"X:\\Apps\\android-ndk-r8"** or **"/opt/android-ndk-r8"**).
-#. CDT Builder is configured for Windows hosts, on Linux or MacOS open `Project Properties` of the projects having JNI part (`face-detection`, `Tutorial 3` and `Tutorial 4`), select :guilabel:`C/C++ Build` in the left pane, remove **".cmd"** and leave ``"${NDKROOT}/ndk-build"`` in the :guilabel:`Build command` edit box and click :guilabel:`OK`.
-
+#. | CDT Builder is already configured for **Windows** hosts,
+ | on **Linux** or **MacOS** a small modification is required:
+
+ Open `Project Properties` of the projects having JNI part (`face-detection`, `Tutorial 3` and `Tutorial 4`),
+ select :guilabel:`C/C++ Build` in the left pane,
+ remove **".cmd"** and leave ``"${NDKROOT}/ndk-build"`` in the :guilabel:`Build command` edit box and click :guilabel:`OK`.
.. image:: images/eclipse_cdt_cfg4.png
:alt: Configure CDT
include C:\Work\android-opencv\OpenCV-2.4.0\share\OpenCV\OpenCV.mk
- should be inserted into the :file:`jni/Android.mk` file right after the line
+ should be inserted into the :file:`jni/Android.mk` file **after** the line
.. code-block:: make
include $(CLEAR_VARS)
- Several variables can be used to customize OpenCV stuff, they should be set **before** the ``"include ...\OpenCV.mk"`` line:
+#. Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when your application uses the `async initialization` via the `OpenCV Manager` API.
+
+ Note: these variables should be set **before** the ``"include .../OpenCV.mk"`` line:
.. code-block:: make
:param rotMatrZ: Optional 3x3 rotation matrix around z-axis.
- :param eulerAngles: Optional three-element vector containing three Euler angles of rotation.
+ :param eulerAngles: Optional three-element vector containing three Euler angles of rotation in degrees.
The function computes a decomposition of a projection matrix into a calibration and a rotation matrix and the position of a camera.
-It optionally returns three rotation matrices, one for each axis, and three Euler angles that could be used in OpenGL.
+It optionally returns three rotation matrices, one for each axis, and three Euler angles that could be used in OpenGL. Note, there is always more than one sequence of rotations about the three principle axes that results in the same orientation of an object, eg. see [Slabaugh]_. Returned tree rotation matrices and corresponding three Euler angules are only one of the possible solutions.
The function is based on
:ocv:func:`RQDecomp3x3` .
The function computes a RQ decomposition using the given rotations. This function is used in
:ocv:func:`decomposeProjectionMatrix` to decompose the left 3x3 submatrix of a projection matrix into a camera and a rotation matrix.
-It optionally returns three rotation matrices, one for each axis, and the three Euler angles
-(as the return value)
-that could be used in OpenGL.
+It optionally returns three rotation matrices, one for each axis, and the three Euler angles in degrees (as the return value) that could be used in OpenGL. Note, there is always more than one sequence of rotations about the three principle axes that results in the same orientation of an object, eg. see [Slabaugh]_. Returned tree rotation matrices and corresponding three Euler angules are only one of the possible solutions.
.. [HH08] Hirschmuller, H. Stereo Processing by Semiglobal Matching and Mutual Information, PAMI(30), No. 2, February 2008, pp. 328-341.
+.. [Slabaugh] Slabaugh, G.G. Computing Euler angles from a rotation matrix. http://gregslabaugh.name/publications/euler.pdf
+
.. [Zhang2000] Z. Zhang. A Flexible New Technique for Camera Calibration. IEEE Transactions on Pattern Analysis and Machine Intelligence, 22(11):1330-1334, 2000.
<builder autoBuildTarget="" command="${NDKROOT}/ndk-build.cmd" enableAutoBuild="true" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.180541221" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.791069665" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.1894181736" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">\r
- <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1575527821" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
- <listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
- <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
- <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
- </option>\r
- <option id="org.eclipse.cdt.build.core.settings.holder.symbols.357964863" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
- <listOptionValue builtIn="false" value="ANDROID=1"/>\r
- </option>\r
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.588929884" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>\r
</tool>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.303359177" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">\r
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.373249505" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
- <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
<listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
+ <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include""/>\r
+ <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
</option>\r
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1424359063" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
<listOptionValue builtIn="false" value="ANDROID=1"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.1156172258" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">\r
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.149918263" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
- <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
<listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
+ <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include""/>\r
+ <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
</option>\r
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.719752707" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
<listOptionValue builtIn="false" value="ANDROID=1"/>\r
<builder autoBuildTarget="" command="${NDKROOT}/ndk-build.cmd" enableAutoBuild="true" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.1153158428" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.835006420" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.1350943194" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">\r
- <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1884803530" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
- <listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
- <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
- <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
- </option>\r
- <option id="org.eclipse.cdt.build.core.settings.holder.symbols.235531736" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
- <listOptionValue builtIn="false" value="ANDROID=1"/>\r
- </option>\r
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1640025837" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>\r
</tool>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.982773030" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">\r
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.332905639" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
<listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
+ <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include""/>\r
<listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
</option>\r
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1475512260" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1490236166" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
<listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
+ <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include""/>\r
<listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
</option>\r
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.945696849" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
<builder autoBuildTarget="" command="${NDKROOT}/ndk-build.cmd" enableAutoBuild="true" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.141883337" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.914869649" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.1504728878" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">\r
- <option id="org.eclipse.cdt.build.core.settings.holder.symbols.412041334" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">\r
- <listOptionValue builtIn="false" value="ANDROID=1"/>\r
- </option>\r
- <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1028672579" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
- <listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
- <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
- <listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
- </option>\r
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1470189286" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>\r
</tool>\r
<tool id="org.eclipse.cdt.build.core.settings.holder.260316541" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">\r
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1772035264" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
<listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
+ <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include""/>\r
<listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
</option>\r
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.159439464" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>\r
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1841493632" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${NDKROOT}/platforms/android-9/arch-arm/usr/include""/>\r
<listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include""/>\r
+ <listOptionValue builtIn="false" value=""${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include""/>\r
<listOptionValue builtIn="false" value=""${ProjDirPath}/../../sdk/native/jni/include""/>\r
</option>\r
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.608739504" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>\r