merged trunk r8815:8827

This commit is contained in:
Marina Kolpakova 2012-06-28 17:28:27 +00:00
parent b28b2428f6
commit 54ee92e3b0
20 changed files with 218 additions and 101 deletions

View File

@ -151,13 +151,8 @@ OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests"
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF ANDROID AND NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
OCV_OPTION(BUILD_ANDROID_SERVICE "TBD" OFF IF ANDROID AND ANDROID_USE_STLPORT AND ANDROID_SOURCE_TREE )
if(DEFINED BUILD_opencv_nonfree AND NOT BUILD_opencv_nonfree)
OCV_OPTION(BUILD_ANDROID_PACKAGE "TBD" OFF IF ANDROID )
else()
unset(BUILD_ANDROID_PACKAGE CACHE)
endif()
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_USE_STLPORT AND ANDROID_SOURCE_TREE )
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
# 3rd party libs
@ -231,15 +226,15 @@ else()
endif()
if(ANDROID)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
set(3P_LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
set(OPENCV_LIB_INSTALL_PATH sdk/native/libs/${ANDROID_NDK_ABI_NAME})
set(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME})
set(OPENCV_CONFIG_INSTALL_PATH sdk/native/jni)
set(OPENCV_INCLUDE_INSTALL_PATH sdk/native/jni/include)
else()
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(3P_LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH})
set(OPENCV_INCLUDE_INSTALL_PATH include)

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.lib_v@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@_@ANDROID_PACKAGE_PLATFORM@"
android:versionCode="@OPENCV_VERSION_PATCH@@ANDROID_PACKAGE_RELEASE@"
android:versionName="@OPENCV_VERSION_PATCH@.@ANDROID_PACKAGE_RELEASE@" >
<uses-sdk android:minSdkVersion="@ANDROID_SDK_VERSION@" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
</application>
</manifest>

View File

@ -1,2 +1,93 @@
#tbd
add_subdirectory(info_lib)
if(NOT ANDROID_PACKAGE_RELEASE)
set(ANDROID_PACKAGE_RELEASE 1)
endif()
if(NOT ANDROID_PACKAGE_PLATFORM)
if(ARMEABI_V7A)
if(NEON)
set(ANDROID_PACKAGE_PLATFORM armv7a_neon)
else()
set(ANDROID_PACKAGE_PLATFORM armv7a)
endif()
elseif(ARMEABI_V6)
set(ANDROID_PACKAGE_PLATFORM armv6)
elseif(ARMEABI)
set(ANDROID_PACKAGE_PLATFORM armv5)
elseif(X86)
set(ANDROID_PACKAGE_PLATFORM x86)
elseif(MIPS)
set(ANDROID_PACKAGE_PLATFORM mips)
else()
message(ERROR "Can not automatically determine the value for ANDROID_PACKAGE_PLATFORM")
endif()
endif()
if(NOT ANDROID_PACKAGE_PLATFORM_NAME)
if(ARMEABI_V7A)
if(NEON)
set(ANDROID_PACKAGE_PLATFORM_NAME "armeabi-v7a with NEON")
else()
set(ANDROID_PACKAGE_PLATFORM_NAME "armeabi-v7a")
endif()
elseif(ARMEABI_V6)
set(ANDROID_PACKAGE_PLATFORM_NAME "armeabi-v6")
elseif(ARMEABI)
set(ANDROID_PACKAGE_PLATFORM_NAME "armeabi")
elseif(X86)
set(ANDROID_PACKAGE_PLATFORM_NAME "x86")
elseif(MIPS)
set(ANDROID_PACKAGE_PLATFORM_NAME "mips")
else()
message(ERROR "Can not automatically determine the value for ANDROID_PACKAGE_PLATFORM_NAME")
endif()
endif()
if("${ANDROID_NATIVE_API_LEVEL}" MATCHES "[1-9][0-9]*$")
set(ANDROID_SDK_VERSION ${CMAKE_MATCH_0})
endif()
if(NOT ANDROID_SDK_VERSION GREATER 7)
set(ANDROID_SDK_VERSION 8)
endif()
set(PACKAGE_DIR "${OpenCV_BINARY_DIR}/package")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}" "${PACKAGE_DIR}/${ANDROID_MANIFEST_FILE}" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml" "${PACKAGE_DIR}/res/values/strings.xml" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/drawable/icon.png" "${PACKAGE_DIR}/res/drawable/icon.png" COPYONLY)
set(target_name "OpenCV_${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}_binary_pack_${ANDROID_PACKAGE_PLATFORM}")
get_target_property(opencv_java_location opencv_java LOCATION)
set(android_proj_target_files ${ANDROID_PROJECT_FILES})
ocv_list_add_prefix(android_proj_target_files "${PACKAGE_DIR}/")
android_get_compatible_target(android_proj_sdk_target ${ANDROID_SDK_VERSION})
set(APK_NAME "${PACKAGE_DIR}/bin/${target_name}-release-unsigned.apk")
file(GLOB camera_wrappers "${OpenCV_SOURCE_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}/libnative_camera_r*.so")
set(CAMERA_LIB_COMMANDS "")
foreach(wrapper ${camera_wrappers})
list(APPEND CAMERA_LIB_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${PACKAGE_DIR}/libs/${ANDROID_NDK_ABI_NAME}/")
endforeach()
add_custom_command(
OUTPUT "${APK_NAME}"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${PACKAGE_DIR}/libs"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${PACKAGE_DIR}/bin"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${PACKAGE_DIR}/gen"
COMMAND ${CMAKE_COMMAND} -E remove ${android_proj_target_files}
COMMAND ${CMAKE_COMMAND} -E make_directory "${PACKAGE_DIR}/src"
COMMAND ${CMAKE_COMMAND} -E make_directory "${PACKAGE_DIR}/libs/${ANDROID_NDK_ABI_NAME}/"
${CAMERA_LIB_COMMANDS}
COMMAND ${CMAKE_COMMAND} -E copy "${opencv_java_location}" "${PACKAGE_DIR}/libs/${ANDROID_NDK_ABI_NAME}/"
COMMAND ${ANDROID_EXECUTABLE} --silent update project --path "${PACKAGE_DIR}" --target "${android_proj_sdk_target}" --name "${target_name}"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k release
COMMAND ${CMAKE_COMMAND} -E touch "${APK_NAME}"
WORKING_DIRECTORY "${PACKAGE_DIR}"
MAIN_DEPENDENCY "${opencv_java_location}"
DEPENDS "${PACKAGE_DIR}/${ANDROID_MANIFEST_FILE}" "${PACKAGE_DIR}/res/values/strings.xml" "${PACKAGE_DIR}/res/drawable/icon.png" ${camera_wrappers}
)
add_custom_target(android_package ALL SOURCES "${APK_NAME}" )
add_dependencies(android_package opencv_java)

View File

@ -1 +0,0 @@
#tbd

View File

@ -1,17 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
src/info.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(TOP)/frameworks/base/core/jni
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libopencvinfo
include $(BUILD_SHARED_LIBRARY)

View File

@ -1,2 +0,0 @@
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-8

View File

@ -1,3 +0,0 @@
// Function return list of shared libs seporated with ";" symbol
// in load order
const char* GetLibraryList();

View File

@ -1,31 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_opencv_android_OpenCVLoader */
#ifndef _Included_org_opencv_android_OpenCVLoader
#define _Included_org_opencv_android_OpenCVLoader
#ifdef __cplusplus
extern "C" {
#endif
#undef org_opencv_android_OpenCVLoader_Success
#define org_opencv_android_OpenCVLoader_Success 0L
#undef org_opencv_android_OpenCVLoader_NoService
#define org_opencv_android_OpenCVLoader_NoService 1L
#undef org_opencv_android_OpenCVLoader_RestartRequired
#define org_opencv_android_OpenCVLoader_RestartRequired 2L
#undef org_opencv_android_OpenCVLoader_MarketError
#define org_opencv_android_OpenCVLoader_MarketError 3L
#undef org_opencv_android_OpenCVLoader_InitFailed
#define org_opencv_android_OpenCVLoader_InitFailed 255L
/*
* Class: org_opencv_android_OpenCVLoader
* Method: GetLibraryList
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,18 +0,0 @@
#include "info.h"
#include <jni.h>
#ifndef LIB_STRING
#define LIB_STRING "libtbb.so;libopencv_java.so"
#endif
const char* GetLibraryList()
{
return LIB_STRING;
}
JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv* jenv, jclass clazz)
{
jstring result = (*jenv)->NewStringUTF(jenv, LIB_STRING);
return result;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">OCV @OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@ binary pack for @ANDROID_PACKAGE_PLATFORM_NAME@</string>
</resources>

View File

@ -8,7 +8,7 @@
#define ARCH_X64_NAME "x64"
#define ARCH_ARMv5_NAME "armv5"
#define ARCH_ARMv6_NAME "armv6"
#define ARCH_ARMv7_NAME "armv7"
#define ARCH_ARMv7_NAME "armv7a"
#define ARCH_ARMv8_NAME "armv8"
#define FEATURES_HAS_VFPv3d16_NAME "vfpv3d16"

View File

@ -175,6 +175,7 @@ macro(android_get_compatible_target VAR)
endif()
endmacro()
unset(__android_project_chain CACHE)
#add_android_project(target_name ${path} NATIVE_DEPS opencv_core LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11)
macro(add_android_project target path)
# parse arguments
@ -288,7 +289,7 @@ macro(add_android_project target path)
COMMAND ${CMAKE_COMMAND} -E touch "${android_proj_bin_dir}/bin/${target}-debug.apk" # needed because ant does not update the timestamp of updated apk
WORKING_DIRECTORY "${android_proj_bin_dir}"
MAIN_DEPENDENCY "${android_proj_bin_dir}/${ANDROID_MANIFEST_FILE}"
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME})
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME} ${__android_project_chain})
else()
add_custom_command(
OUTPUT "${android_proj_bin_dir}/bin/${target}-debug.apk"
@ -296,9 +297,10 @@ macro(add_android_project target path)
COMMAND ${CMAKE_COMMAND} -E touch "${android_proj_bin_dir}/bin/${target}-debug.apk" # needed because ant does not update the timestamp of updated apk
WORKING_DIRECTORY "${android_proj_bin_dir}"
MAIN_DEPENDENCY "${android_proj_bin_dir}/${ANDROID_MANIFEST_FILE}"
DEPENDS "${OpenCV_BINARY_DIR}/bin/classes.jar" opencv_java # as we are part of OpenCV we can just force this dependency
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME})
DEPENDS "${OpenCV_BINARY_DIR}/bin/.classes.jar.dephelper" opencv_java # as we are part of OpenCV we can just force this dependency
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME} ${__android_project_chain})
endif()
set(__android_project_chain ${target} CACHE INTERNAL "auxiliary variable used for Android progects chaining")
unset(JNI_LIB_NAME)

View File

@ -4320,6 +4320,7 @@ public:
CV_WRAP_AS(setMat) void set(const string& name, const Mat& value);
CV_WRAP_AS(setMatVector) void set(const string& name, const vector<Mat>& value);
CV_WRAP_AS(setAlgorithm) void set(const string& name, const Ptr<Algorithm>& value);
template<typename _Tp> void set(const string& name, const Ptr<_Tp>& value);
void set(const char* name, int value);
void set(const char* name, double value);
@ -4328,6 +4329,7 @@ public:
void set(const char* name, const Mat& value);
void set(const char* name, const vector<Mat>& value);
void set(const char* name, const Ptr<Algorithm>& value);
template<typename _Tp> void set(const char* name, const Ptr<_Tp>& value);
CV_WRAP string paramHelp(const string& name) const;
int paramType(const char* name) const;

View File

@ -759,7 +759,8 @@ inline SVD::SVD() {}
inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); }
inline void SVD::solveZ( InputArray m, OutputArray _dst )
{
SVD svd(m);
Mat mtx = m.getMat();
SVD svd(mtx, (mtx.rows >= mtx.cols ? 0 : SVD::FULL_UV));
_dst.create(svd.vt.cols, 1, svd.vt.type());
Mat dst = _dst.getMat();
svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst);

View File

@ -3842,6 +3842,22 @@ template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const string& name)
return _create(name).ptr<_Tp>();
}
template<typename _Tp>
void Algorithm::set(const char* _name, const Ptr<_Tp>& value)
{
Ptr<Algorithm> algo_ptr = value. template ptr<cv::Algorithm>();
if (algo_ptr.empty()) {
CV_Error( CV_StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set");
}
info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr);
}
template<typename _Tp>
void Algorithm::set(const string& _name, const Ptr<_Tp>& value)
{
this->set<_Tp>(_name.c_str(), value);
}
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& _name) const
{
typename ParamType<_Tp>::member_type value;

View File

@ -75,6 +75,7 @@ protected:
bool TestVec();
bool TestMatxMultiplication();
bool TestSubMatAccess();
bool TestSVD();
bool operations1();
void checkDiff(const Mat& m1, const Mat& m2, const string& s)
@ -934,6 +935,29 @@ bool CV_OperationsTest::operations1()
return true;
}
bool CV_OperationsTest::TestSVD()
{
try
{
Mat A = (Mat_<double>(3,4) << 1, 2, -1, 4, 2, 4, 3, 5, -1, -2, 6, 7);
Mat x;
SVD::solveZ(A,x);
if( norm(A*x, CV_C) > FLT_EPSILON )
throw test_excep();
SVD svd(A, SVD::FULL_UV);
if( norm(A*svd.vt.row(3).t(), CV_C) > FLT_EPSILON )
throw test_excep();
}
catch(const test_excep&)
{
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
return false;
}
return true;
}
void CV_OperationsTest::run( int /* start_from */)
{
if (!TestMat())
@ -960,6 +984,9 @@ void CV_OperationsTest::run( int /* start_from */)
if (!TestSubMatAccess())
return;
if (!TestSVD())
return;
if (!operations1())
return;

View File

@ -248,9 +248,9 @@ if(ANDROID)
# build the library project
# normally we should do this after a native part, but for a library project we can build the java part first
add_custom_command(
OUTPUT "${OpenCV_BINARY_DIR}/bin/classes.jar"
OUTPUT "${OpenCV_BINARY_DIR}/bin/classes.jar" "${OpenCV_BINARY_DIR}/bin/.classes.jar.dephelper"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug
COMMAND ${CMAKE_COMMAND} -E touch "${OpenCV_BINARY_DIR}/bin/classes.jar" # needed because ant does not update the timestamp of updated jar
COMMAND ${CMAKE_COMMAND} -E touch "${OpenCV_BINARY_DIR}/bin/.classes.jar.dephelper" # can not rely on classes.jar because different versions of SDK update timestamp at different times
WORKING_DIRECTORY "${OpenCV_BINARY_DIR}"
DEPENDS ${lib_proj_files} ${lib_target_files} ${java_files}
COMMENT "Building OpenCV Android library project"

View File

@ -1,2 +1,6 @@
if(BUILD_ANDROID_PACKAGE)
ocv_module_disable(nonfree)
endif()
set(the_description "Functionality with possible limitations on the use")
ocv_define_module(nonfree opencv_imgproc opencv_features2d)

View File

@ -150,7 +150,37 @@ int main(int ac, char** av)
}
cout << "Try opening " << filename << " to see the serialized data." << endl;
cout << "Try opening " << filename << " to see the serialized data." << endl << endl;
//read from string
{
cout << "Read data from string\n";
string dataString =
"%YAML:1.0\n"
"mdata:\n"
" A: 97\n"
" X: 3.1415926535897931e+00\n"
" id: mydata1234\n";
MyData m;
FileStorage fs(dataString, FileStorage::READ | FileStorage::MEMORY);
cout << "attempting to read mdata_b from string\n"; //Show default behavior for empty matrix
fs["mdata"] >> m;
cout << "read mdata\n";
cout << m << endl;
}
//write to string
{
cout << "Write data to string\n";
FileStorage fs(filename, FileStorage::WRITE | FileStorage::MEMORY | FileStorage::FORMAT_YAML);
cout << "writing MyData struct\n";
MyData m(1);
fs << "mdata" << m;
cout << m << endl;
string createdString = fs.releaseAndGetString();
cout << "Created string:\n" << createdString << "\n";
}
return 0;
}