Added cmake file to compile Android native camera wrapper if Android source tree is available
This commit is contained in:
parent
4f86b30abc
commit
e722cb96e7
@ -863,6 +863,21 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
############## Android source tree for native camera ###############
|
||||||
|
if(ANDROID)
|
||||||
|
SET (ANDROID_SOURCE_TREE "ANDROID_SOURCE_TREE-NOTFOUND" CACHE PATH
|
||||||
|
"Path to Android source tree.
|
||||||
|
Set this variable to path to your Android sources to compile
|
||||||
|
libnative_camera_rx.x.x.so for your Android")
|
||||||
|
SET(BUILD_ANDROID_CAMERA_WRAPPER OFF)
|
||||||
|
if (ANDROID_SOURCE_TREE)
|
||||||
|
FILE(STRINGS "${ANDROID_SOURCE_TREE}/development/sdk/platform_source.properties" ANDROID_VERSION REGEX "Platform\\.Version=[0-9]+\\.[0-9]+\\.[0-9]+" )
|
||||||
|
string(REGEX REPLACE "Platform\\.Version=([0-9]+\\.[0-9]+\\.[0-9]+)" "\\1" ANDROID_VERSION "${ANDROID_VERSION}")
|
||||||
|
if(NOT "${ANDROID_VERSION}" STREQUAL "")
|
||||||
|
SET(BUILD_ANDROID_CAMERA_WRAPPER ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
################## Reference Manual ##################
|
################## Reference Manual ##################
|
||||||
set(BUILD_DOCS ON CACHE BOOL "Build OpenCV Reference Manual")
|
set(BUILD_DOCS ON CACHE BOOL "Build OpenCV Reference Manual")
|
||||||
@ -1460,7 +1475,11 @@ message(STATUS " V4L/V4L2: ${HAVE_CAMV4L}/${HAVE_CAMV4L2}")
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS " Xine: ${HAVE_XINE}")
|
message(STATUS " Xine: ${HAVE_XINE}")
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
message(STATUS " AndroidNativeCamera: build")
|
if(BUILD_ANDROID_CAMERA_WRAPPER)
|
||||||
|
message(STATUS " AndroidNativeCamera: build for Android ${ANDROID_VERSION}")
|
||||||
|
else()
|
||||||
|
message(STATUS " AndroidNativeCamera: use prebuilt libraries")
|
||||||
|
endif(BUILD_ANDROID_CAMERA_WRAPPER)
|
||||||
endif()
|
endif()
|
||||||
endif() #if(UNIX AND NOT APPLE)
|
endif() #if(UNIX AND NOT APPLE)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ SET( the_target opencv_androidcamera )
|
|||||||
ADD_LIBRARY( ${the_target} STATIC src/camera_activity.cpp )
|
ADD_LIBRARY( ${the_target} STATIC src/camera_activity.cpp )
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
add_definitions(-DCVAPI_EXPORTS)
|
add_definitions(-DCVAPI_EXPORTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES( ${the_target} ${LIBRARY_DEPS} )
|
TARGET_LINK_LIBRARIES( ${the_target} ${LIBRARY_DEPS} )
|
||||||
@ -37,16 +37,18 @@ IF (NOT BUILD_SHARED_LIBS)
|
|||||||
)
|
)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
file(GLOB camera_wrappers "${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/lib/libnative_camera_r*.so")
|
if (NOT BUILD_ANDROID_CAMERA_WRAPPER)
|
||||||
|
file(GLOB camera_wrappers "${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/lib/libnative_camera_r*.so")
|
||||||
|
|
||||||
foreach(wrapper ${camera_wrappers})
|
foreach(wrapper ${camera_wrappers})
|
||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
TARGET ${the_target}
|
TARGET ${the_target}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${LIBRARY_OUTPUT_PATH}"
|
COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${LIBRARY_OUTPUT_PATH}"
|
||||||
)
|
)
|
||||||
get_filename_component(wrapper_name "${wrapper}" NAME)
|
get_filename_component(wrapper_name "${wrapper}" NAME)
|
||||||
install(FILES "${LIBRARY_OUTPUT_PATH}/${wrapper_name}"
|
install(FILES "${LIBRARY_OUTPUT_PATH}/${wrapper_name}"
|
||||||
DESTINATION lib
|
DESTINATION lib
|
||||||
COMPONENT main)
|
COMPONENT main)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endif()
|
40
modules/androidcamera/camera_wrapper/CMakeLists.txt
Normal file
40
modules/androidcamera/camera_wrapper/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
SET (the_target native_camera_r${ANDROID_VERSION})
|
||||||
|
|
||||||
|
project(${the_target})
|
||||||
|
|
||||||
|
link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib")
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${ANDROID_SOURCE_TREE}
|
||||||
|
${ANDROID_SOURCE_TREE}/frameworks/base/include/ui
|
||||||
|
${ANDROID_SOURCE_TREE}/frameworks/base/include/surfaceflinger
|
||||||
|
${ANDROID_SOURCE_TREE}/frameworks/base/include/camera
|
||||||
|
${ANDROID_SOURCE_TREE}/frameworks/base/include/media
|
||||||
|
${ANDROID_SOURCE_TREE}/frameworks/base/include/camera
|
||||||
|
${ANDROID_SOURCE_TREE}/frameworks/base/include
|
||||||
|
${ANDROID_SOURCE_TREE}/system/core/include
|
||||||
|
${ANDROID_SOURCE_TREE}/hardware/libhardware/include
|
||||||
|
${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")
|
||||||
|
|
||||||
|
ADD_LIBRARY(${the_target} MODULE 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 )
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(${the_target} PROPERTIES
|
||||||
|
OUTPUT_NAME "${the_target}"
|
||||||
|
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS ${the_target}
|
||||||
|
RUNTIME DESTINATION bin COMPONENT main
|
||||||
|
ARCHIVE DESTINATION lib COMPONENT main
|
||||||
|
LIBRARY DESTINATION lib COMPONENT main
|
||||||
|
)
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <camera/CameraHardwareInterface.h>
|
#include <camera/CameraHardwareInterface.h>
|
||||||
#include "camera_wrapper.h"
|
#include "camera_wrapper.h"
|
||||||
#include "../camera_wrapper_connector/camera_properties.h"
|
#include "../include/camera_properties.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user