diff --git a/3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.2.so b/3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.2.so index b36b97a36a8bcfbfc7b8a8d334802a8f11877e61..8bed2ae671398b534cb658eb3b1428eab1544caf 100644 Binary files a/3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.2.so and b/3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.2.so differ diff --git a/3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so b/3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so index 28c567672b5631b40494319bc9c60af3ed3a3ad6..f4eac816ec61ea2889ac64d27c2fca6cb817db85 100644 Binary files a/3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so and b/3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so differ diff --git a/3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so b/3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so new file mode 100755 index 0000000000000000000000000000000000000000..630af9793a61847a113c200d589e827609cea26e Binary files /dev/null and b/3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so differ diff --git a/3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so b/3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so new file mode 100755 index 0000000000000000000000000000000000000000..4c3ebbc5f8119b389fc6785c299e345632597b2b Binary files /dev/null and b/3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so differ diff --git a/3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so b/3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so new file mode 100755 index 0000000000000000000000000000000000000000..998abe4894d210ad828a070411d3e6ce58a36c9b Binary files /dev/null and b/3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so differ diff --git a/3rdparty/lib/armeabi/libnative_camera_r2.2.2.so b/3rdparty/lib/armeabi/libnative_camera_r2.2.2.so index 5209ce29d000f0e0987f135a0a84089ab6fabee5..c4e5d661a194857fac596e20051c4360d23732a0 100755 Binary files a/3rdparty/lib/armeabi/libnative_camera_r2.2.2.so and b/3rdparty/lib/armeabi/libnative_camera_r2.2.2.so differ diff --git a/3rdparty/lib/armeabi/libnative_camera_r2.3.3.so b/3rdparty/lib/armeabi/libnative_camera_r2.3.3.so index af006de71bddb1f137c8456854698b65bb5e2947..2893164e34e8a56e514564dfefd960e238dd101e 100755 Binary files a/3rdparty/lib/armeabi/libnative_camera_r2.3.3.so and b/3rdparty/lib/armeabi/libnative_camera_r2.3.3.so differ diff --git a/3rdparty/lib/armeabi/libnative_camera_r3.0.1.so b/3rdparty/lib/armeabi/libnative_camera_r3.0.1.so new file mode 100755 index 0000000000000000000000000000000000000000..f1c3265d44260e2bfe9a4f9173937efd721d9931 Binary files /dev/null and b/3rdparty/lib/armeabi/libnative_camera_r3.0.1.so differ diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index b3a711a54250b840dcf794741292209878f26d8e..1faff218ead132c2577cf0c8a4397f07848baf03 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -146,6 +146,8 @@ # [~] ARM_TARGET is renamed to ANDROID_ABI # [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME # [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL +# - modified January 2012 Andrey Kamaev andrey.kamaev@itseez.com +# [+] added stlport_static support (experimental) # ------------------------------------------------------------------------------ # this one is important @@ -167,6 +169,8 @@ set( ANDROID_SUPPORTED_ABIS_x86 "x86" ) set( ANDROID_DEFAULT_NDK_API_LEVEL 8 ) set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 ) +option( ANDROID_USE_STLPORT "Experimental: use stlport_static instead of gnustl_static" FALSE ) + macro( __INIT_VARIABLE var_name ) set( __test_path 0 ) foreach( __var ${ARGN} ) @@ -255,7 +259,7 @@ endmacro() macro( __COPY_IF_DIFFERENT _source _destination ) execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_source}" "${_destination}" RESULT_VARIABLE __fileCopyProcess ) - if( NOT __fileCopyProcess EQUAL 0 ) + if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${_destination}") message( SEND_ERROR "Failed copying of ${_source} to the ${_destination}" ) endif() unset( __fileCopyProcess ) @@ -552,8 +556,13 @@ endif() if( BUILD_WITH_ANDROID_NDK ) set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" ) - set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include" ) - set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}" ) + if( ANDROID_USE_STLPORT ) + set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" ) + set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}" ) + else() + set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include" ) + set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}" ) + endif() endif() # specify the cross compiler @@ -615,15 +624,29 @@ add_definitions( -DANDROID ) # NDK flags if( ARMEABI OR ARMEABI_V7A ) # NDK also defines -ffunction-sections -funwind-tables but they result in worse OpenCV performance - set( CMAKE_CXX_FLAGS "-fPIC -Wno-psabi -frtti -fexceptions" ) - set( CMAKE_C_FLAGS "-fPIC -Wno-psabi -fexceptions" ) + set( CMAKE_CXX_FLAGS "-fPIC -Wno-psabi" ) + set( CMAKE_C_FLAGS "-fPIC -Wno-psabi" ) + if( ANDROID_USE_STLPORT ) + set( CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions" ) + set( CMAKE_C_FLAGS "-fno-rtti -fno-exceptions" ) + else() + set( CMAKE_CXX_FLAGS "-frtti -fexceptions" ) + set( CMAKE_C_FLAGS "-fexceptions" ) + endif() remove_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ ) add_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ ) # extra arm-specific flags set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) elseif( X86 ) - set( CMAKE_CXX_FLAGS "-ffunction-sections -funwind-tables -frtti -fexceptions" ) - set( CMAKE_C_FLAGS "-ffunction-sections -funwind-tables -fexceptions" ) + set( CMAKE_CXX_FLAGS "-ffunction-sections -funwind-tables" ) + set( CMAKE_C_FLAGS "-ffunction-sections -funwind-tables" ) + if( ANDROID_USE_STLPORT ) + set( CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions" ) + set( CMAKE_C_FLAGS "-fno-rtti -fno-exceptions" ) + else() + set( CMAKE_CXX_FLAGS "-frtti -fexceptions" ) + set( CMAKE_C_FLAGS "-fexceptions" ) + endif() else() set( CMAKE_CXX_FLAGS "" ) set( CMAKE_C_FLAGS "" ) @@ -678,50 +701,61 @@ endif() #linker flags list( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}" "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ) -#set( LINKER_FLAGS "-L\"${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}\" -L\"${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}\"" ) set( LINKER_FLAGS "" ) #STL -if( EXISTS "${__stlLibPath}/libgnustl_static.a" ) - __COPY_IF_DIFFERENT( "${__stlLibPath}/libgnustl_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) -elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) - __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) -elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) - __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) -elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/thumb/libstdc++.a" ) - __COPY_IF_DIFFERENT( "${__stlLibPath}/thumb/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) -elseif( EXISTS "${__stlLibPath}/libstdc++.a" ) - __COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) -endif() -if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) - set( LINKER_FLAGS "${LINKER_FLAGS} -lstdc++" ) -endif() -#gcc exception & rtti support -if( EXISTS "${__stlLibPath}/libsupc++.a" ) - __COPY_IF_DIFFERENT( "${__stlLibPath}/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) -elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" ) - __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) -elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" ) - __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) -elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" ) - __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) -elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" ) - __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) -endif() -if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) - set( LINKER_FLAGS "${LINKER_FLAGS} -lsupc++" ) -endif() +if( ANDROID_USE_STLPORT ) + if( EXISTS "${__stlLibPath}/libstlport_static.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/libstlport_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" ) + endif() + if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" ) + set( LINKER_FLAGS "${LINKER_FLAGS} -Wl,--start-group -lstlport_static" ) + endif() +else() + if( EXISTS "${__stlLibPath}/libgnustl_static.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/libgnustl_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/thumb/libstdc++.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/thumb/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + elseif( EXISTS "${__stlLibPath}/libstdc++.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + endif() + if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + set( LINKER_FLAGS "${LINKER_FLAGS} -lstdc++" ) + endif() + + #gcc exception & rtti support + if( EXISTS "${__stlLibPath}/libsupc++.a" ) + __COPY_IF_DIFFERENT( "${__stlLibPath}/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" ) + __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" ) + __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" ) + __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" ) + __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + endif() + if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + set( LINKER_FLAGS "${LINKER_FLAGS} -lsupc++" ) + endif() +endif( ANDROID_USE_STLPORT ) #cleanup for STL search unset( __stlIncludePath ) unset( __stlLibPath ) #other linker flags -__INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON ) -set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Don't all undefined symbols" FORCE ) -MARK_AS_ADVANCED( ANDROID_NO_UNDEFINED ) -if( ANDROID_NO_UNDEFINED ) - set( LINKER_FLAGS "-Wl,--no-undefined ${LINKER_FLAGS}" ) -endif() +#if( NOT ANDROID_USE_STLPORT ) + __INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON ) + set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Don't all undefined symbols" FORCE ) + MARK_AS_ADVANCED( ANDROID_NO_UNDEFINED ) + if( ANDROID_NO_UNDEFINED ) + set( LINKER_FLAGS "-Wl,--no-undefined ${LINKER_FLAGS}" ) + endif() +#endif() if( ARMEABI_V7A ) # this is *required* to use the following linker flags that routes around # a CPU bug in some Cortex-A8 implementations: @@ -819,6 +853,7 @@ endif() # ANDROID_NO_UNDEFINED : ON/OFF # ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF # LIBRARY_OUTPUT_PATH_ROOT : +# ANDROID_USE_STLPORT : ON/OFF(default) - EXPERIMENTAL!!! # Can be set only at the first run: # ANDROID_NDK # ANDROID_STANDALONE_TOOLCHAIN diff --git a/modules/androidcamera/camera_wrapper/CMakeLists.txt b/modules/androidcamera/camera_wrapper/CMakeLists.txt index e0a1458521cd0d0f99b74e47341f0d4937e51d09..9f912f099fbb3dc12f378802df81aa992c7a6afb 100644 --- a/modules/androidcamera/camera_wrapper/CMakeLists.txt +++ b/modules/androidcamera/camera_wrapper/CMakeLists.txt @@ -17,15 +17,30 @@ INCLUDE_DIRECTORIES( ${ANDROID_SOURCE_TREE}/frameworks/base/native/include ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" ) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) -ADD_LIBRARY(${the_target} MODULE camera_wrapper.h camera_wrapper.cpp) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") +SET(CMAKE_C_FLAGS_RELEASE "") +SET(CMAKE_CXX_FLAGS_RELEASE "") + +string(REPLACE "-O3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +string(REPLACE "-O3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -fno-strict-aliasing -finline-limit=64 -fuse-cxa-atexit" ) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -fno-strict-aliasing -finline-limit=64 -fuse-cxa-atexit") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack") + +ADD_LIBRARY(${the_target} SHARED camera_wrapper.h camera_wrapper.cpp) string(REGEX REPLACE "[.]" "_" LIBRARY_DEF ${ANDROID_VERSION}) add_definitions(-DANDROID_r${LIBRARY_DEF}) -target_link_libraries(${the_target} dl m stdc++ utils camera_client ui media binder cutils surfaceflinger_client supc++ log ) +target_link_libraries(${the_target} c m dl utils camera_client binder log) + +if(NOT ANDROID_VERSION VERSION_LESS "3.0.0") + target_link_libraries(${the_target} gui ) +endif() SET_TARGET_PROPERTIES(${the_target} PROPERTIES OUTPUT_NAME "${the_target}" @@ -33,4 +48,8 @@ SET_TARGET_PROPERTIES(${the_target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} ) +# force strip library after the build command +ADD_CUSTOM_COMMAND( TARGET ${the_target} POST_BUILD COMMAND ${CMAKE_STRIP} "${LIBRARY_OUTPUT_PATH}/lib${the_target}.so" ) + + install(TARGETS ${the_target} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) diff --git a/modules/androidcamera/camera_wrapper/android.3.0.1/Camera.patch b/modules/androidcamera/camera_wrapper/android.3.0.1/Camera.patch new file mode 100644 index 0000000000000000000000000000000000000000..8a771263177c285f1233dc131ef6313e8bdd82d7 --- /dev/null +++ b/modules/androidcamera/camera_wrapper/android.3.0.1/Camera.patch @@ -0,0 +1,70 @@ +*** src2.3.3/frameworks/base/include/camera/Camera.h 2011-04-04 20:18:36.718480237 +0400 +--- src_mock3.0.1/frameworks/base/include/camera/Camera.h 2012-01-15 20:51:36.000000000 +0400 +*************** +*** 20,25 **** +--- 20,27 ---- + #include + #include + ++ #include ++ + namespace android { + + class ISurface; +*************** +*** 76,81 **** +--- 78,90 ---- + CAMERA_MSG_POSTVIEW_FRAME = 0x040, + CAMERA_MSG_RAW_IMAGE = 0x080, + CAMERA_MSG_COMPRESSED_IMAGE = 0x100, ++ ++ #ifdef OMAP_ENHANCEMENT ++ ++ CAMERA_MSG_BURST_IMAGE = 0x200, ++ ++ #endif ++ + CAMERA_MSG_ALL_MSGS = 0x1FF + }; + +*************** +*** 144,150 **** +--- 153,164 ---- + public: + virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0; + virtual void postData(int32_t msgType, const sp& dataPtr) = 0; ++ #ifdef OMAP_ENHANCEMENT ++ virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr, ++ uint32_t offset=0, uint32_t stride=0) = 0; ++ #else + virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr) = 0; ++ #endif + }; + + class Camera : public BnCameraClient, public IBinder::DeathRecipient +*************** +*** 170,175 **** +--- 184,191 ---- + status_t setPreviewDisplay(const sp& surface); + status_t setPreviewDisplay(const sp& surface); + ++ // pass the SurfaceTexture object to the Camera ++ status_t setPreviewTexture(const sp& surfaceTexture); + // start preview mode, must call setPreviewDisplay first + status_t startPreview(); + +*************** +*** 215,221 **** +--- 231,242 ---- + // ICameraClient interface + virtual void notifyCallback(int32_t msgType, int32_t ext, int32_t ext2); + virtual void dataCallback(int32_t msgType, const sp& dataPtr); ++ #ifdef OMAP_ENHANCEMENT ++ virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr, ++ uint32_t offset=0, uint32_t stride=0); ++ #else + virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr); ++ #endif + + sp remote(); + diff --git a/modules/androidcamera/camera_wrapper/android.3.0.1/ICamera.patch b/modules/androidcamera/camera_wrapper/android.3.0.1/ICamera.patch new file mode 100644 index 0000000000000000000000000000000000000000..996b3e18506e9802bfed4a9ceeab005f4ce8fbc6 --- /dev/null +++ b/modules/androidcamera/camera_wrapper/android.3.0.1/ICamera.patch @@ -0,0 +1,14 @@ +*** src2.3.3/frameworks/base/include/camera/ICamera.h 2011-04-04 20:18:36.718480237 +0400 +--- src_mock3.0.1/frameworks/base/include/camera/ICamera.h 2012-01-15 20:50:30.000000000 +0400 +*************** +*** 48,53 **** +--- 48,56 ---- + // pass the buffered ISurface to the camera service + virtual status_t setPreviewDisplay(const sp& surface) = 0; + ++ // pass the preview texture. This is for 3.0 and higher versions of Android ++ setPreviewTexture(const sp& surfaceTexture) = 0; ++ + // set the preview callback flag to affect how the received frames from + // preview are handled. + virtual void setPreviewCallbackFlag(int flag) = 0; diff --git a/modules/androidcamera/camera_wrapper/android.3.0.1/README b/modules/androidcamera/camera_wrapper/android.3.0.1/README new file mode 100644 index 0000000000000000000000000000000000000000..90634cff414cb37115e22f373402753a8106bf60 --- /dev/null +++ b/modules/androidcamera/camera_wrapper/android.3.0.1/README @@ -0,0 +1,8 @@ +Building camera wrapper for Android 3.0.1: + +1) Get sources of Android 2.3.x (2.3.3 were used) +2) Apply patches provided with this instruction to frameworks/base/include/camera/ICamera.h and frameworks/base/include/camera/Camera.h +3) Get frameworks/base/include/gui/ISurfaceTexture.h and frameworks/base/include/gui/SurfaceTexture.h from Android 4.0.x (4.0.3 were used) sources and add them to your source tree. +4) Apply provided patch to the frameworks/base/include/gui/SurfaceTexture.h. +5) Pull /system/lib from your device running Andoid 3.x.x +6) Build wrapper as normal using this modified source tree. \ No newline at end of file diff --git a/modules/androidcamera/camera_wrapper/android.3.0.1/SurfaceTexture.patch b/modules/androidcamera/camera_wrapper/android.3.0.1/SurfaceTexture.patch new file mode 100644 index 0000000000000000000000000000000000000000..75572b0dfd77c10897a5d0ebb811b20ec4ef86b8 --- /dev/null +++ b/modules/androidcamera/camera_wrapper/android.3.0.1/SurfaceTexture.patch @@ -0,0 +1,37 @@ +*** src4.0.3/src/frameworks/base/include/gui/SurfaceTexture.h 2012-01-18 16:32:41.424750385 +0400 +--- src_mock3.0.1/frameworks/base/include/gui/SurfaceTexture.h 2012-01-12 21:28:14.000000000 +0400 +*************** +*** 68,75 **** + // texture will be bound in updateTexImage. useFenceSync specifies whether + // fences should be used to synchronize access to buffers if that behavior + // is enabled at compile-time. +! SurfaceTexture(GLuint tex, bool allowSynchronousMode = true, +! GLenum texTarget = GL_TEXTURE_EXTERNAL_OES, bool useFenceSync = true); + + virtual ~SurfaceTexture(); + +--- 68,74 ---- + // texture will be bound in updateTexImage. useFenceSync specifies whether + // fences should be used to synchronize access to buffers if that behavior + // is enabled at compile-time. +! SurfaceTexture(GLuint tex); + + virtual ~SurfaceTexture(); + +*************** +*** 280,286 **** + mBufferState(BufferSlot::FREE), + mRequestBufferCalled(false), + mTransform(0), +! mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), + mTimestamp(0), + mFrameNumber(0), + mFence(EGL_NO_SYNC_KHR) { +--- 279,285 ---- + mBufferState(BufferSlot::FREE), + mRequestBufferCalled(false), + mTransform(0), +! mScalingMode(0), + mTimestamp(0), + mFrameNumber(0), + mFence(EGL_NO_SYNC_KHR) { diff --git a/modules/androidcamera/camera_wrapper/camera_wrapper.cpp b/modules/androidcamera/camera_wrapper/camera_wrapper.cpp index 53af525974e5a581cb008584da820787a82e388f..44cf9b6ddcc12b264e13bcff527dd0f3629002b6 100644 --- a/modules/androidcamera/camera_wrapper/camera_wrapper.cpp +++ b/modules/androidcamera/camera_wrapper/camera_wrapper.cpp @@ -1,27 +1,43 @@ -#if !defined(ANDROID_r2_2_2) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) -#error unsupported version of Android +#if !defined(ANDROID_r2_2_2) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3) +# error Building camera wrapper for your version of Android is not supported by OpenCV. You need to modify OpenCV sources in order to compile camera wrapper for your version of Android. #endif -#include +#include +#include + +#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) +# include +#endif //defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) + #include "camera_wrapper.h" #include "../include/camera_properties.h" + +#if defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) +//Include SurfaceTexture.h file with the SurfaceTexture class +# include +# define MAGIC_OPENCV_TEXTURE_ID (0x10) +#else // defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) +//TODO: This is either 2.2 or 2.3. Include the headers for ISurface.h access +# include +#endif // defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) + #include //undef logging macro from /system/core/libcutils/loghack.h #ifdef LOGD -#undef LOGD +# undef LOGD #endif #ifdef LOGI -#undef LOGI +# undef LOGI #endif #ifdef LOGW -#undef LOGW +# undef LOGW #endif #ifdef LOGE -#undef LOGE +# undef LOGE #endif @@ -152,7 +168,7 @@ public: virtual ~CameraHandler() { - LOGD("CameraHandler destructor is called"); + LOGD("CameraHandler destructor is called"); } virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) @@ -167,7 +183,11 @@ public: #endif } - virtual void postData(int32_t msgType, const sp& dataPtr) + virtual void postData(int32_t msgType, const sp& dataPtr +#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) + ,camera_frame_metadata_t* metadata +#endif + ) { debugShowFPS(); @@ -177,8 +197,8 @@ public: return; } - if (msgType != CAMERA_MSG_PREVIEW_FRAME) - LOGE("CameraHandler::postData Recieved message %d is not equal to CAMERA_MSG_PREVIEW_FRAME (%d)", (int) msgType, CAMERA_MSG_PREVIEW_FRAME); + //if (msgType != CAMERA_MSG_PREVIEW_FRAME) + //LOGE("CameraHandler::postData Recieved message %d is not equal to CAMERA_MSG_PREVIEW_FRAME (%d)", (int) msgType, CAMERA_MSG_PREVIEW_FRAME); if ( msgType & CAMERA_MSG_RAW_IMAGE ) LOGE("CameraHandler::postData Unexpected data format: RAW\n"); @@ -209,8 +229,8 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback, #ifdef ANDROID_r2_2_2 camera = Camera::connect(); -#endif -#ifdef ANDROID_r2_3_3 +#else + /* This is 2.3 or higher. The connect method has cameraID parameter */ camera = Camera::connect(cameraId); #endif @@ -293,19 +313,33 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback, } } -#ifdef ANDROID_r2_2_2 - status_t pdstatus = camera->setPreviewDisplay(sp(0 /*new DummySurface*/)); + + status_t pdstatus; +#if defined(ANDROID_r2_2_2) + pdstatus = camera->setPreviewDisplay(sp(0 /*new DummySurface*/)); + if (pdstatus != 0) + LOGE("initCameraConnect: failed setPreviewDisplay(0) call; camera migth not work correctly on some devices"); +#elif defined(ANDROID_r2_3_3) + /* Do nothing in case of 2.3 for now */ + +#elif defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) + sp surfaceTexture = new SurfaceTexture(MAGIC_OPENCV_TEXTURE_ID); + pdstatus = camera->setPreviewTexture(surfaceTexture); if (pdstatus != 0) - LOGE("initCameraConnect: failed setPreviewDisplay(0) call; camera migth not work correcttly on some devices"); + LOGE("initCameraConnect: failed setPreviewTexture call; camera migth not work correctly"); #endif +#if !(defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)) +# if 1 ////ATTENTION: switching between two versions: with and without copying memory inside Android OS //// see the method CameraService::Client::copyFrameAndPostCopiedFrame and where it is used -#if 1 camera->setPreviewCallbackFlags( FRAME_CALLBACK_FLAG_ENABLE_MASK | FRAME_CALLBACK_FLAG_COPY_OUT_MASK);//with copy -#else +# else camera->setPreviewCallbackFlags( FRAME_CALLBACK_FLAG_ENABLE_MASK );//without copy -#endif +# endif +#else + camera->setPreviewCallbackFlags( CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK | CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK);//with copy +#endif //!(defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)) status_t resStart = camera->startPreview(); diff --git a/modules/androidcamera/src/camera_activity.cpp b/modules/androidcamera/src/camera_activity.cpp index c8a72deee78b91101ce44e6844d75cb6e0bab03b..6c77a3a2db07e340e992ca5114cf1d8d550d4aa0 100644 --- a/modules/androidcamera/src/camera_activity.cpp +++ b/modules/androidcamera/src/camera_activity.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "camera_activity.hpp" #include "camera_wrapper.h" @@ -162,10 +163,11 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib() vector listLibs; fillListWrapperLibs(folderPath, listLibs); + std::sort(listLibs.begin(), listLibs.end(), std::greater()); void * libHandle=0; string cur_path; - for(size_t i=0; i < listLibs.size(); i++) { + for(size_t i = 0; i < listLibs.size(); i++) { cur_path=folderPath + listLibs[i]; LOGD("try to load library '%s'", listLibs[i].c_str()); libHandle=dlopen(cur_path.c_str(), RTLD_LAZY);