modified highgui and ts modules and cmakelists for ios cross-compiling, added ios toolchains, added ios build tutorial
This commit is contained in:
parent
e268e0704d
commit
8c6782300a
@ -36,7 +36,7 @@ endif(NOT CMAKE_TOOLCHAIN_FILE)
|
||||
# --------------------------------------------------------------
|
||||
# Top level OpenCV project
|
||||
# --------------------------------------------------------------
|
||||
cmake_minimum_required(VERSION 2.4)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
project(OpenCV)
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
|
||||
@ -72,8 +72,11 @@ endif()
|
||||
# Build static or dynamic libs?
|
||||
# Default: dynamic libraries
|
||||
# ----------------------------------------------------------------------------
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
|
||||
|
||||
if(NOT IOS)
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
|
||||
else()
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
|
||||
endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
# Include debug info into debug libs?
|
||||
# Default: yes
|
||||
@ -327,7 +330,11 @@ endif()
|
||||
|
||||
# Build tests:
|
||||
# ===================================================
|
||||
set(BUILD_TESTS ON CACHE BOOL "Build tests")
|
||||
if(NOT IOS)
|
||||
set(BUILD_TESTS ON CACHE BOOL "Build tests")
|
||||
else()
|
||||
set(BUILD_TESTS OFF CACHE BOOL "Build tests")
|
||||
endif()
|
||||
|
||||
# Build 3rdparty libraries under unix
|
||||
# ===================================================
|
||||
@ -337,7 +344,10 @@ else()
|
||||
set(OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries")
|
||||
endif()
|
||||
|
||||
if(NOT IOS)
|
||||
include(OpenCVPCHSupport.cmake REQUIRED)
|
||||
endif()
|
||||
|
||||
include(OpenCVModule.cmake REQUIRED)
|
||||
if(ANDROID)
|
||||
include(OpenCVAndroidProject.cmake REQUIRED)
|
||||
@ -398,11 +408,13 @@ endif()
|
||||
# allow fine grained control over which libraries not to link, even if
|
||||
# they are available on the system
|
||||
# ====================================================================
|
||||
if(NOT IOS)
|
||||
set(WITH_PNG ON CACHE BOOL "Include PNG support")
|
||||
set(WITH_JPEG ON CACHE BOOL "Include JPEG support")
|
||||
set(WITH_JASPER ON CACHE BOOL "Include JPEG2K support")
|
||||
set(WITH_TIFF ON CACHE BOOL "Include TIFF support")
|
||||
set(WITH_OPENEXR ON CACHE BOOL "Include ILM support via OpenEXR")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
set(WITH_FFMPEG ON CACHE BOOL "Include FFMPEG support")
|
||||
@ -1678,7 +1690,11 @@ if(UNIX AND NOT APPLE)
|
||||
endif()
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
|
||||
if(NOT IOS)
|
||||
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
|
||||
else()
|
||||
status(" Video I/O: AVFoundation")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
|
||||
endif()
|
||||
|
@ -3,6 +3,7 @@
|
||||
.. |Author_AndreyK| unicode:: Andrey U+0020 Kamaev
|
||||
.. |Author_LeonidBLB| unicode:: Leonid U+0020 Beynenson
|
||||
.. |Author_VictorE| unicode:: Victor U+0020 Eruhimov
|
||||
.. |Author_ArtemM| unicode:: Artem U+0020 Myagkov
|
||||
.. |Author_FernandoI| unicode:: Fernando U+0020 Iglesias U+0020 Garc U+00ED a
|
||||
|
||||
|
||||
|
58
doc/tutorials/introduction/ios_install/ios_install.rst
Normal file
58
doc/tutorials/introduction/ios_install/ios_install.rst
Normal file
@ -0,0 +1,58 @@
|
||||
.. _iOS-Installation:
|
||||
|
||||
Installation in iOS
|
||||
***********************
|
||||
|
||||
Required packages
|
||||
==================
|
||||
|
||||
* GCC 4.x or later
|
||||
* CMake 2.6 or higher
|
||||
* Xcode 4.0 or higher
|
||||
|
||||
Getting the cutting-edge OpenCV from SourceForge SVN repository
|
||||
-----------------------------------------------------------------
|
||||
|
||||
Launch SVN client and checkout either
|
||||
|
||||
a. the current OpenCV snapshot from here: https://code.ros.org/svn/opencv/trunk
|
||||
|
||||
#. or the latest tested OpenCV snapshot from here: http://code.ros.org/svn/opencv/tags/latest_tested_snapshot
|
||||
|
||||
In MacOS it can be done using the following command in Terminal:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/<my_working _directory>
|
||||
svn co https://code.ros.org/svn/opencv/trunk
|
||||
|
||||
|
||||
Building OpenCV from source using CMake, using the command line
|
||||
================================================================
|
||||
|
||||
#. Create a temporary directory, which we denote as <cmake_binary_dir>, where you want to put the generated Makefiles, project files as well the object filees and output binaries
|
||||
|
||||
#. Enter the <cmake_binary_dir> and type
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cmake [<some optional parameters>] <path to the OpenCV source directory>
|
||||
|
||||
For example
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/opencv
|
||||
cd ..
|
||||
mkdir release
|
||||
cd release
|
||||
cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=../opencv/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCMAKE_INSTALL_PREFIX=../OpenCV_iPhoneOS -DCMAKE_BUILD_TYPE=RELEASE ../opencv
|
||||
|
||||
|
||||
#. Enter the created temporary directory (<cmake_binary_dir>) and proceed with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
xcodebuild -sdk iphoneos -configuration Release -target ALL_BUILD
|
||||
xcodebuild -sdk iphoneos -configuration Release -target install install
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
@ -139,10 +139,27 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
* **From where to start?**
|
||||
* **iOS**
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
=========== ======================================================
|
||||
|Install_2| **Title:** :ref:`iOS-Installation`
|
||||
|
||||
*Compatibility:* > OpenCV 2.3.1
|
||||
|
||||
*Author:* |Author_ArtemM|
|
||||
|
||||
We will learn how to setup OpenCV for using it in iOS!
|
||||
|
||||
=========== ======================================================
|
||||
|
||||
.. |Install_2| image:: images/ios4_logo.jpg
|
||||
:width: 90pt
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
============= ======================================================
|
||||
|Beginners_1| **Title:** :ref:`Display_Image`
|
||||
@ -209,6 +226,7 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
../windows_visual_studio_Opencv/windows_visual_studio_Opencv
|
||||
../android_binary_package/android_binary_package
|
||||
../android_binary_package/android_binary_package_using_with_NDK
|
||||
../ios_install/ios_install
|
||||
../display_image/display_image
|
||||
../load_save_image/load_save_image
|
||||
../how_to_write_a_tutorial/how_to_write_a_tutorial
|
161
ios/cmake/Modules/Platform/iOS.cmake
Normal file
161
ios/cmake/Modules/Platform/iOS.cmake
Normal file
@ -0,0 +1,161 @@
|
||||
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
|
||||
# files which are included with CMake 2.8.4
|
||||
# It has been altered for iOS development
|
||||
set (UNIX 1)
|
||||
set (APPLE 1)
|
||||
set (IOS 1)
|
||||
|
||||
# Darwin versions:
|
||||
# 6.x == Mac OSX 10.2
|
||||
# 7.x == Mac OSX 10.3
|
||||
# 8.x == Mac OSX 10.4
|
||||
# 9.x == Mac OSX 10.5
|
||||
# 10.x == Mac OSX 10.6 (Snow Leopard)
|
||||
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_SYSTEM_VERSION}")
|
||||
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_VERSION "${CMAKE_SYSTEM_VERSION}")
|
||||
|
||||
# Do not use the "-Wl,-search_paths_first" flag with the OSX 10.2 compiler.
|
||||
# Done this way because it is too early to do a TRY_COMPILE.
|
||||
if (NOT DEFINED HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
set (HAVE_FLAG_SEARCH_PATHS_FIRST 0)
|
||||
if ("${DARWIN_MAJOR_VERSION}" GREATER 6)
|
||||
set (HAVE_FLAG_SEARCH_PATHS_FIRST 1)
|
||||
endif ("${DARWIN_MAJOR_VERSION}" GREATER 6)
|
||||
endif (NOT DEFINED HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
# More desirable, but does not work:
|
||||
#INCLUDE(CheckCXXCompilerFlag)
|
||||
#CHECK_CXX_COMPILER_FLAG("-Wl,-search_paths_first" HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
|
||||
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||
set (CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||
set (CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||
set (CMAKE_MODULE_EXISTS 1)
|
||||
set (CMAKE_DL_LIBS "")
|
||||
|
||||
set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||
|
||||
# Hidden visibilty is required for cxx on iOS
|
||||
set (CMAKE_C_FLAGS "")
|
||||
set (CMAKE_CXX_FLAGS "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")
|
||||
|
||||
if (HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
||||
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
||||
endif (HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
|
||||
set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
||||
|
||||
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
|
||||
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
|
||||
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
|
||||
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
|
||||
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
||||
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
|
||||
# Setup iOS developer location
|
||||
if (IPHONEOS)
|
||||
set (_CMAKE_IOS_DEVELOPER_ROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
|
||||
else ()
|
||||
if (IPHONESIMULATOR)
|
||||
set (_CMAKE_IOS_DEVELOPER_ROOT "/Developer/Platforms/iPhoneSimulator.platform/Developer")
|
||||
endif ()
|
||||
endif ()
|
||||
# Find installed iOS SDKs
|
||||
file (GLOB _CMAKE_IOS_SDKS "${_CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
|
||||
|
||||
# Find and use the most recent iOS sdk
|
||||
if (_CMAKE_IOS_SDKS)
|
||||
list (SORT _CMAKE_IOS_SDKS)
|
||||
list (REVERSE _CMAKE_IOS_SDKS)
|
||||
list (GET _CMAKE_IOS_SDKS 0 _CMAKE_IOS_SDK_ROOT)
|
||||
|
||||
# Set the sysroot default to the most recent SDK
|
||||
set (CMAKE_OSX_SYSROOT ${_CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
||||
|
||||
# set the architecture for iOS - this env var sets armv6,armv7 and appears to be XCode's standard. The other found is ARCHS_UNIVERSAL_IPHONE_OS but that is armv7 only
|
||||
set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)" CACHE string "Build architecture for iOS")
|
||||
|
||||
# Set the default based on this file and not the environment variable
|
||||
set (CMAKE_FIND_ROOT_PATH ${_CMAKE_IOS_DEVELOPER_ROOT} ${_CMAKE_IOS_SDK_ROOT} CACHE string "iOS library search path root")
|
||||
|
||||
# default to searching for frameworks first
|
||||
set (CMAKE_FIND_FRAMEWORK FIRST)
|
||||
|
||||
# set up the default search directories for frameworks
|
||||
set (CMAKE_SYSTEM_FRAMEWORK_PATH
|
||||
${_CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
|
||||
${_CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
|
||||
${_CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
|
||||
)
|
||||
endif (_CMAKE_IOS_SDKS)
|
||||
|
||||
if ("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
|
||||
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
|
||||
endif ("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
|
||||
|
||||
if (NOT XCODE)
|
||||
# Enable shared library versioning. This flag is not actually referenced
|
||||
# but the fact that the setting exists will cause the generators to support
|
||||
# soname computation.
|
||||
set (CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
|
||||
endif (NOT XCODE)
|
||||
|
||||
# Xcode does not support -isystem yet.
|
||||
if (XCODE)
|
||||
set (CMAKE_INCLUDE_SYSTEM_FLAG_C)
|
||||
set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
|
||||
endif (XCODE)
|
||||
|
||||
# Need to list dependent shared libraries on link line. When building
|
||||
# with -isysroot (for universal binaries), the linker always looks for
|
||||
# dependent libraries under the sysroot. Listing them on the link
|
||||
# line works around the problem.
|
||||
set (CMAKE_LINK_DEPENDENT_LIBRARY_FILES 1)
|
||||
|
||||
set (CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w)
|
||||
set (CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w)
|
||||
|
||||
set (CMAKE_C_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> -install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set (CMAKE_CXX_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> -install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
|
||||
|
||||
set (CMAKE_CXX_CREATE_SHARED_MODULE
|
||||
"<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
|
||||
set (CMAKE_C_CREATE_SHARED_MODULE
|
||||
"<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
|
||||
set (CMAKE_C_CREATE_MACOSX_FRAMEWORK
|
||||
"<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> -install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set (CMAKE_CXX_CREATE_MACOSX_FRAMEWORK
|
||||
"<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> -install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
|
||||
|
||||
|
||||
# Add the install directory of the running cmake to the search directories
|
||||
# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up
|
||||
get_filename_component (_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
|
||||
get_filename_component (_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
|
||||
|
||||
# List common installation prefixes. These will be used for all search types
|
||||
list (APPEND CMAKE_SYSTEM_PREFIX_PATH
|
||||
# Standard
|
||||
${_CMAKE_IOS_DEVELOPER_ROOT}/usr
|
||||
${_CMAKE_IOS_SDK_ROOT}/usr
|
||||
|
||||
# CMake install location
|
||||
"${_CMAKE_INSTALL_DIR}"
|
||||
|
||||
# Project install destination.
|
||||
"${CMAKE_INSTALL_PREFIX}"
|
||||
)
|
24
ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake
Normal file
24
ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
message (STATUS "Setting up iPhoneOS toolchain")
|
||||
set (IPHONEOS TRUE)
|
||||
|
||||
# Standard settings
|
||||
set (CMAKE_SYSTEM_NAME iOS)
|
||||
# Include extra modules for the iOS platform files
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/ios/cmake/Modules")
|
||||
|
||||
# Force the compilers to gcc for iOS
|
||||
include (CMakeForceCompiler)
|
||||
CMAKE_FORCE_C_COMPILER (gcc gcc)
|
||||
CMAKE_FORCE_CXX_COMPILER (g++ g++)
|
||||
|
||||
# Skip the platform compiler checks for cross compiling
|
||||
set (CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set (CMAKE_C_COMPILER_WORKS TRUE)
|
||||
|
||||
# Search for programs in the build host directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
# for libraries and headers in the target directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
message (STATUS "iPhoneOS toolchain loaded")
|
24
ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake
Normal file
24
ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
message (STATUS "Setting up iPhoneOS toolchain")
|
||||
set (IPHONESIMULATOR TRUE)
|
||||
|
||||
# Standard settings
|
||||
set (CMAKE_SYSTEM_NAME iOS)
|
||||
# Include extra modules for the iOS platform files
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/ios/cmake/Modules")
|
||||
|
||||
# Force the compilers to gcc for iOS
|
||||
include (CMakeForceCompiler)
|
||||
CMAKE_FORCE_C_COMPILER (gcc gcc)
|
||||
CMAKE_FORCE_CXX_COMPILER (g++ g++)
|
||||
|
||||
# Skip the platform compiler checks for cross compiling
|
||||
set (CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set (CMAKE_C_COMPILER_WORKS TRUE)
|
||||
|
||||
# Search for programs in the build host directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
# for libraries and headers in the target directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
message (STATUS "iPhoneOS toolchain loaded")
|
1
ios/configure-device_xcode.sh
Executable file
1
ios/configure-device_xcode.sh
Executable file
@ -0,0 +1 @@
|
||||
cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=../opencv/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCMAKE_INSTALL_PREFIX=../OpenCV_iPhoneOS ../opencv
|
1
ios/configure-simulator_xcode.sh
Executable file
1
ios/configure-simulator_xcode.sh
Executable file
@ -0,0 +1 @@
|
||||
cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=../opencv/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake -DCMAKE_INSTALL_PREFIX=../OpenCV_iPhoneSimulator ../opencv
|
15
ios/readme.txt
Normal file
15
ios/readme.txt
Normal file
@ -0,0 +1,15 @@
|
||||
Assuming that your build directory is on the same level that opencv source,
|
||||
From the build directory run
|
||||
../opencv/ios/configure-device_xcode.sh
|
||||
or
|
||||
../opencv/ios/configure-simulator_xcode.sh
|
||||
|
||||
Then from the same folder invoke
|
||||
|
||||
xcodebuild -sdk iphoneos -configuration Release -target ALL_BUILD
|
||||
xcodebuild -sdk iphoneos -configuration Release -target install install
|
||||
|
||||
or
|
||||
|
||||
xcodebuild -sdk iphonesimulator -configuration Release -target ALL_BUILD
|
||||
xcodebuild -sdk iphonesimulator -configuration Release -target install install
|
@ -33,10 +33,13 @@ if(BUILD_JAVA_SUPPORT)
|
||||
endif()
|
||||
|
||||
add_subdirectory(video)
|
||||
|
||||
if(NOT IOS)
|
||||
add_subdirectory(traincascade)
|
||||
add_subdirectory(haartraining)
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID)
|
||||
if(NOT (ANDROID OR IOS))
|
||||
add_subdirectory(gpu)
|
||||
add_subdirectory(stitching)
|
||||
endif()
|
||||
|
@ -126,6 +126,8 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
if(NOT IOS)
|
||||
|
||||
if(NOT HAVE_QT)
|
||||
if(HAVE_GTK)
|
||||
set(highgui_srcs ${highgui_srcs} src/window_gtk.cpp)
|
||||
@ -172,6 +174,8 @@ if(UNIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif(NOT IOS)
|
||||
|
||||
foreach(P ${HIGHGUI_INCLUDE_DIRS})
|
||||
include_directories(${P})
|
||||
endforeach()
|
||||
@ -188,7 +192,7 @@ if(WITH_OPENNI AND HAVE_OPENNI)
|
||||
endif()
|
||||
|
||||
#YV
|
||||
if(APPLE)
|
||||
if(APPLE AND NOT IOS)
|
||||
add_definitions(-DHAVE_QUICKTIME=1)
|
||||
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
|
||||
add_definitions(-DHAVE_IMAGEIO=1)
|
||||
@ -205,11 +209,17 @@ if(APPLE)
|
||||
endif()
|
||||
|
||||
if(WITH_QUICKTIME)
|
||||
set(highgui_srcs ${highgui_srcs} src/cap_qt.cpp)
|
||||
else()
|
||||
set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm)
|
||||
endif()
|
||||
endif(APPLE)
|
||||
set(highgui_srcs ${highgui_srcs} src/cap_qt.cpp)
|
||||
else()
|
||||
set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm)
|
||||
endif()
|
||||
|
||||
endif(APPLE AND NOT IOS)
|
||||
|
||||
if (IOS)
|
||||
add_definitions(-DHAVE_IMAGEIO=1)
|
||||
set(highgui_srcs ${highgui_srcs} src/cap_avfoundation.mm)
|
||||
endif()
|
||||
|
||||
if(WITH_ANDROID_CAMERA)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../androidcamera/include")
|
||||
@ -346,7 +356,7 @@ if( OPENNI_LIBRARY )
|
||||
target_link_libraries(${the_target} ${OPENNI_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
if(APPLE AND NOT IOS)
|
||||
target_link_libraries(${the_target} "-lbz2 -framework Cocoa -framework QuartzCore")
|
||||
if(WITH_CARBON)
|
||||
target_link_libraries(${the_target} "-framework Carbon")
|
||||
@ -359,6 +369,10 @@ if(APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (IOS)
|
||||
target_link_libraries(${the_target} "-lbz2 -framework QuartzCore -framework CoreFoundation -framework ImageIO -framework CoreGraphics -framework AVFoundation")
|
||||
endif()
|
||||
|
||||
install(TARGETS ${the_target}
|
||||
RUNTIME DESTINATION bin COMPONENT main
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
|
||||
@ -394,7 +408,7 @@ if(BUILD_TESTS)
|
||||
source_group("Include" FILES ${test_hdrs})
|
||||
|
||||
set(the_target "opencv_test_highgui")
|
||||
|
||||
|
||||
add_executable(${the_target} ${test_srcs} ${test_hdrs})
|
||||
|
||||
add_opencv_precompiled_headers(${the_target})
|
||||
|
@ -289,7 +289,9 @@ enum
|
||||
|
||||
CV_CAP_ANDROID =1000, // Android
|
||||
|
||||
CV_CAP_XIAPI =1100 // XIMEA Camera API
|
||||
CV_CAP_XIAPI =1100, // XIMEA Camera API
|
||||
|
||||
CV_CAP_AVFOUNDATION = 1200 // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
};
|
||||
|
||||
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
|
||||
@ -397,7 +399,14 @@ enum
|
||||
CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure
|
||||
CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure
|
||||
CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %)
|
||||
CV_CAP_PROP_XI_TIMEOUT = 420 // Image capture timeout in milliseconds
|
||||
CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds
|
||||
|
||||
// Properties of cameras available through AVFOUNDATION interface
|
||||
CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001,
|
||||
CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002,
|
||||
CV_CAP_PROP_IOS_DEVICE_FLASH = 9003,
|
||||
CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004,
|
||||
CV_CAP_PROP_IOS_DEVICE_TORCH = 9005
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -136,6 +136,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#ifdef HAVE_XIMEA
|
||||
CV_CAP_XIAPI,
|
||||
#endif
|
||||
CV_CAP_AVFOUNDATION
|
||||
-1
|
||||
};
|
||||
|
||||
@ -155,7 +156,8 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
defined(HAVE_CAMV4L) || defined (HAVE_CAMV4L2) || defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_DC1394_2) || defined(HAVE_DC1394) || defined(HAVE_CMU1394) || \
|
||||
defined(HAVE_GSTREAMER) || defined(HAVE_MIL) || defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_UNICAP) || defined(HAVE_PVAPI) || defined(HAVE_OPENNI) || defined(HAVE_ANDROID_NATIVE_CAMERA)
|
||||
defined(HAVE_UNICAP) || defined(HAVE_PVAPI) || defined(HAVE_OPENNI) || defined(HAVE_ANDROID_NATIVE_CAMERA) || \
|
||||
defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
|
||||
// local variable to memorize the captured device
|
||||
CvCapture *capture;
|
||||
#endif
|
||||
@ -278,6 +280,14 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
case CV_CAP_AVFOUNDATION:
|
||||
capture = cvCreateCameraCapture_AVFoundation (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,6 +321,11 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
result = cvCreateFileCapture_QT (filename);
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_AVFoundation (filename);
|
||||
#endif
|
||||
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_Images (filename);
|
||||
|
||||
@ -339,6 +354,10 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
*/
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
if (! result)
|
||||
result = cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
if(!result)
|
||||
|
1325
modules/highgui/src/cap_avfoundation.mm
Normal file
1325
modules/highgui/src/cap_avfoundation.mm
Normal file
File diff suppressed because it is too large
Load Diff
@ -113,7 +113,11 @@ bool ImageIODecoder::readData( Mat& img )
|
||||
}
|
||||
else if( color == CV_LOAD_IMAGE_COLOR )
|
||||
{
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
#else
|
||||
colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGBLinear );
|
||||
#endif
|
||||
bpp = 4; /* CG only has 8 and 32 bit color spaces, so we waste a byte */
|
||||
alphaInfo = kCGImageAlphaNoneSkipLast;
|
||||
}
|
||||
@ -272,10 +276,20 @@ bool ImageIOEncoder::write( const Mat& img, const vector<int>& params )
|
||||
CGColorSpaceRef colorSpace;
|
||||
uchar* bitmapData = NULL;
|
||||
|
||||
if( bpp == 1 )
|
||||
if( bpp == 1 ) {
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
colorSpace = CGColorSpaceCreateDeviceGray();
|
||||
#else
|
||||
colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericGray );
|
||||
else if( bpp == 4 )
|
||||
#endif
|
||||
}
|
||||
else if( bpp == 4 ) {
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
#else
|
||||
colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGBLinear );
|
||||
#endif
|
||||
}
|
||||
if( !colorSpace )
|
||||
return false;
|
||||
|
||||
|
@ -12,8 +12,19 @@
|
||||
#ifdef HAVE_IMAGEIO
|
||||
|
||||
#include "grfmt_base.hpp"
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
|
||||
#include <MobileCoreServices/MobileCoreServices.h>
|
||||
#include <ImageIO/ImageIO.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
#include "precomp.hpp"
|
||||
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
@ -67,7 +68,6 @@ CV_IMPL int cvWaitKey (int maxWait) {return 0;}
|
||||
//*** end IphoneOS Stubs ***/
|
||||
#else
|
||||
|
||||
#include "precomp.hpp"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <iostream>
|
||||
|
@ -306,6 +306,10 @@
|
||||
#endif // _WIN32_WCE
|
||||
#elif defined __APPLE__
|
||||
#define GTEST_OS_MAC 1
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#define GTEST_OS_MAC_IOS 1
|
||||
#endif
|
||||
#elif defined __linux__
|
||||
#define GTEST_OS_LINUX 1
|
||||
#elif defined __MVS__
|
||||
|
@ -6078,7 +6078,7 @@ void InitGoogleTest(int* argc, wchar_t** argv) {
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
|
||||
#if GTEST_OS_MAC
|
||||
#if GTEST_OS_MAC && !GTEST_OS_MAC_IOS
|
||||
#include <crt_externs.h>
|
||||
#endif // GTEST_OS_MAC
|
||||
|
||||
@ -6871,7 +6871,7 @@ struct ExecDeathTestArgs {
|
||||
int close_fd; // File descriptor to close; the read end of a pipe
|
||||
};
|
||||
|
||||
#if GTEST_OS_MAC
|
||||
#if GTEST_OS_MAC && !GTEST_OS_MAC_IOS
|
||||
inline char** GetEnviron() {
|
||||
// When Google Test is built as a framework on MacOS X, the environ variable
|
||||
// is unavailable. Apple's documentation (man environ) recommends using
|
||||
|
Loading…
Reference in New Issue
Block a user